GetterFunctionInstance.cs 659 B

12345678910111213141516171819202122232425
  1. using System;
  2. using Jint.Native;
  3. using Jint.Native.Function;
  4. namespace Jint.Runtime.Interop
  5. {
  6. /// <summary>
  7. /// Represents a FunctionInstance wrapping a Clr getter.
  8. /// </summary>
  9. public sealed class GetterFunctionInstance: FunctionInstance
  10. {
  11. private readonly Func<JsValue, JsValue> _getter;
  12. public GetterFunctionInstance(Engine engine, Func<JsValue, JsValue> getter)
  13. : base(engine, "get", null, null, false)
  14. {
  15. _getter = getter;
  16. }
  17. public override JsValue Call(JsValue thisObject, JsValue[] arguments)
  18. {
  19. return _getter(thisObject);
  20. }
  21. }
  22. }