private async void CSharpPropertyChanged(object sender, PropertyChangedEventArgs e) { var pn = e.PropertyName; var propertyAccessor = new PropertyAccessor(sender, pn, _Logger); if (!propertyAccessor.IsGettable) return; var currentfather = _SessionCache.GetCached(sender) as JsGenericObject; if (currentfather == null) return; var nv = propertyAccessor.Get(); var oldbridgedchild = currentfather.Attributes[pn]; if (Object.Equals(nv, oldbridgedchild.CValue)) return; await RegisterAndDo(() => _JSObjectBuilder.UnsafelMap(nv), (child) => currentfather.ReRoot(pn, child) ); }
public void OnJavaScriptObjectChanges(IJavascriptObject objectchanged, string propertyName, IJavascriptObject newValue) { try { var res = _SessionCache.GetGlobalCached(objectchanged) as JsGenericObject; if (res == null) return; var propertyAccessor = new PropertyAccessor(res.CValue, propertyName, _Logger); if (!propertyAccessor.IsSettable) { _Logger.Info(() => $"Unable to set C# from javascript object: property: {propertyName} is readonly."); return; } var targetType = propertyAccessor.GetTargetType(); var glue = GetCachedOrCreateBasic(newValue, targetType); using (_IsListening ? _ListenerRegister.GetPropertySilenter(res.CValue) : null) { propertyAccessor.Set(glue.CValue); res.UpdateCSharpProperty(propertyName, glue); } } catch (Exception e) { _Logger.Error(() =>$"Unable to update ViewModel from View, exception raised: {e.Message}"); } }