GetterFunctionInstance.cs 735 B

1234567891011121314151617181920212223242526
  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 static readonly JsString _name = new JsString("get");
  12. private readonly Func<JsValue, JsValue> _getter;
  13. public GetterFunctionInstance(Engine engine, Func<JsValue, JsValue> getter)
  14. : base(engine, _name, FunctionThisMode.Global)
  15. {
  16. _getter = getter;
  17. }
  18. public override JsValue Call(JsValue thisObject, JsValue[] arguments)
  19. {
  20. return _getter(thisObject);
  21. }
  22. }
  23. }