static internal V8PropertyAttributes _CreateAccessorProxies(V8Engine engine, string name, GetterAccessor getter, SetterAccessor setter, V8PropertyAttributes attributes, V8AccessControl access, ref NativeGetterAccessor _Getter, ref NativeSetterAccessor _Setter) { if (name.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(name), "Cannot be null, empty, or only whitespace."); } if (attributes == V8PropertyAttributes.Undefined) { attributes = V8PropertyAttributes.None; } if (attributes < 0) { throw new InvalidOperationException("'attributes' has an invalid value."); } if (access < 0) { throw new InvalidOperationException("'access' has an invalid value."); } if (getter != null && _Getter == null) { _Getter = (_this, _name) => // (only need to set this once on first use) { try { return(getter != null?getter(_this, _name) : null); } catch (Exception ex) { return(engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } } } ; if (setter != null && _Setter == null) { _Setter = (_this, _name, _val) => // (only need to set this once on first use) { try { return(setter != null?setter(_this, _name, _val) : null); } catch (Exception ex) { return(engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } } } ; return(attributes); }
// -------------------------------------------------------------------------------------------------------------------- protected HandleProxy *_NamedPropertyGetter(string propertyName, ref ManagedAccessorInfo info) { try { var obj = _Engine._GetObjectWeakReference(info.ManagedObjectID); if (obj == null) { return(null); } var mo = obj.Reset() as IV8ManagedObject; // (this acts also as a test because native object wrappers are also supported) return(mo != null?mo.NamedPropertyGetter(ref propertyName) : null); } catch (Exception ex) { return(_Engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } }
// -------------------------------------------------------------------------------------------------------------------- protected HandleProxy *_NamedPropertyGetter(string propertyName, ref ManagedAccessorInfo info) { try { var obj = _Engine._GetExistingObject(info.ManagedObjectID); if (obj == null) { return(null); } var mo = obj as IV8ManagedObject; var result = mo != null?mo.NamedPropertyGetter(ref propertyName) : null; return(result); } catch (Exception ex) { return(_Engine.CreateError(Exceptions.GetFullErrorMessage(ex), JSValueType.ExecutionError)); } }