private SetObjectTemplateAccessor ( |
||
proxy | ||
managedObjectID | ||
name | string | |
getter | ManagedAccessorGetter | |
setter | ManagedAccessorSetter | |
access | V8AccessControl | |
attributes | V8PropertyAttributes | |
return | void |
/// <summary> /// Calls the V8 'SetAccessor()' function on the underlying native 'v8::ObjectTenplate' instance to create a property that is controlled by "getter" and "setter" callbacks. /// <para>Note: This is template related, which means all objects created from this template will be affected by these special properties.</para> /// </summary> public void SetAccessor(string name, GetterAccessor getter, SetterAccessor setter, V8PropertyAttributes attributes = V8PropertyAttributes.None, V8AccessControl access = V8AccessControl.Default) { attributes = V8NativeObject._CreateAccessorProxies(Engine, name, getter, setter, attributes, access, ref _Getter, ref _Setter); Getter = getter; Setter = setter; V8NetProxy.SetObjectTemplateAccessor(_NativeObjectTemplateProxy, -1, name, _Getter, _Setter, access, attributes); }
// -------------------------------------------------------------------------------------------------------------------- /// <summary> /// Calls the V8 'SetAccessor()' function on the underlying native 'v8::ObjectTenplate' instance to create a property that is controlled by "getter" and "setter" callbacks. /// <para>Note: This is template related, which means all objects created from this template will be affected by these special properties.</para> /// </summary> public void SetAccessor(string name, V8NativeObjectPropertyGetter getter, V8NativeObjectPropertySetter setter, V8PropertyAttributes attributes = V8PropertyAttributes.None, V8AccessControl access = V8AccessControl.Default) { if (name.IsNullOrWhiteSpace()) { throw new ArgumentNullException("name (cannot be null, empty, or only whitespace)"); } var engine = Engine; V8NetProxy.SetObjectTemplateAccessor(_NativeObjectTemplateProxy, -1, name, _Engine._StoreAccessor <ManagedAccessorGetter>(_NativeObjectTemplateProxy->ObjectID, "get_" + name, (HandleProxy * _this, string propertyName) => { try { using (InternalHandle hThis = _this) { return(getter != null ? getter(hThis, propertyName) : null); } } catch (Exception ex) { return(engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } }), _Engine._StoreAccessor <ManagedAccessorSetter>(_NativeObjectTemplateProxy->ObjectID, "set_" + name, (HandleProxy * _this, string propertyName, HandleProxy * value) => { try { using (InternalHandle hThis = _this) { return(setter != null ? setter(hThis, propertyName, value) : null); } } catch (Exception ex) { return(engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } }), access, attributes); }