MethodAccessor.cs 915 B

12345678910111213141516171819202122232425262728
  1. using Jint.Runtime.Descriptors;
  2. namespace Jint.Runtime.Interop.Reflection;
  3. internal sealed class MethodAccessor : ReflectionAccessor
  4. {
  5. private readonly Type _targetType;
  6. private readonly MethodDescriptor[] _methods;
  7. public MethodAccessor(Type targetType, MethodDescriptor[] methods) : base(null!)
  8. {
  9. _targetType = targetType;
  10. _methods = methods;
  11. }
  12. public override bool Writable => false;
  13. protected override object? DoGetValue(object target, string memberName) => null;
  14. protected override void DoSetValue(object target, string memberName, object? value)
  15. {
  16. }
  17. public override PropertyDescriptor CreatePropertyDescriptor(Engine engine, object target, string memberName, bool enumerable = true)
  18. {
  19. return new(new MethodInfoFunction(engine, _targetType, target, memberName, _methods), PropertyFlag.Configurable | PropertyFlag.NonData);
  20. }
  21. }