GetterFunctionInstance.cs 629 B

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