1234567891011121314151617181920212223242526272829303132333435 |
- using System.Reflection;
- using Jint.Native;
- namespace Jint.Runtime.Descriptors.Specialized
- {
- public sealed class ClrDataDescriptor : PropertyDescriptor
- {
- private readonly PropertyInfo _propertyInfo;
- private readonly object _item;
- private JsValue? _value;
- public ClrDataDescriptor(Engine engine, PropertyInfo propertyInfo, object item)
- {
- _propertyInfo = propertyInfo;
- _item = item;
- _value = JsValue.FromObject(engine, _propertyInfo.GetValue(_item, null));
- Writable = propertyInfo.CanWrite;
- }
- public override JsValue? Value
- {
- get
- {
- return _value;
- }
- set
- {
- _value = value;
- _propertyInfo.SetValue(_item, _value.GetValueOrDefault().ToObject(), null);
- }
- }
- }
- }
|