private void PropertySet(object sender, CfrV8AccessorSetEventArgs e) { var prop = PropertyMap.FirstOrDefault(p => p.Key == e.Name).Value; if (prop != null) { object value = ReadV8Value(e.Value, prop.PropertyType); prop.SetMethod.Invoke(this, new object[] { value }); e.SetReturnValue(true); return; } var field = FieldMap.FirstOrDefault(f => f.Key == e.Name).Value; if (field != null) { object value = ReadV8Value(e.Value, field.FieldType); field.SetValue(this, value); e.SetReturnValue(true); return; } e.Exception = $"There is no property named { e.Name }."; e.SetReturnValue(false); }
internal void RaisePropertySet(CfrV8AccessorSetEventArgs e) { var h = PropertySet; if (h == null) { //TODO: this causes the browser to crash. //so for the time being, we silently ignore //set requests when there is no application //defined set event. //e.Exception = "Property is readonly."; e.SetReturnValue(true); } else { if (WillInvoke) { Browser.RenderThreadInvoke((MethodInvoker)(() => h.Invoke(this, e))); } else { h.Invoke(this, e); } } }
void v8Accessor_Set(object sender, CfrV8AccessorSetEventArgs e) { JSProperty property; if (jsProperties.TryGetValue(e.Name, out property)) { ((JSDynamicProperty)property).RaisePropertySet(e); } else { //this should never be reached e.SetReturnValue(false); } }