public void OnUiContext(ObjectChangesListener off) { var currentfather = _JsUpdateHelper.GetCached <JsGenericObject>(_Sender); if (currentfather == null) { return; } var propertyUpdater = currentfather.GetPropertyUpdater(_PropertyName); if (!propertyUpdater.IsValid) { return; } _NewValue = propertyUpdater.GetCurrentChildValue(); if (!propertyUpdater.HasChanged(_NewValue)) { return; } _NewJsValue = _JsUpdateHelper.Map(_NewValue); if (_NewJsValue == null) { return; } _BridgeUpdater = currentfather.GetUpdater(propertyUpdater, _NewJsValue); _JsUpdateHelper.UpdateOnUiContext(_BridgeUpdater, off); }
public async void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes) { try { var res = _SessionCache.GetCached(changes.Collection) as JsArray; if (res == null) { return; } var collectionChanges = res.GetChanger(changes, this); var updater = new BridgeUpdater(_SessionCache); await Context.RunOnUiContextAsync(() => { UpdateCollection(res, res.CValue, collectionChanges, updater); }); if (!updater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }); } catch (Exception exception) { LogJavascriptSetException(exception); } }
private async Task UpdateOnJavascriptContextWithMapping(BridgeUpdater updater, IJsCsGlue value) { _BuilderStrategy.UpdateJavascriptValue(value); await InjectInHtmlSession(value); updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }
private async Task UpdateOnJavascriptContextWithMapping(BridgeUpdater updater, IJsCsGlue value) { UpdateJavascriptValue(value); await _SessionMapper.InjectInHtmlSession(value); RunUpdaterOnJsContext(updater); }
public async void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes) { try { var res = _SessionCache.GetCached(changes.Collection) as JSArray; if (res == null) { return; } var collectionChanges = res.GetChanger(changes, this); var updater = new BridgeUpdater(); await Context.RunOnUIContextAsync(() => { UpdateCollection(res, res.CValue, collectionChanges, updater); }); if (!updater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); }); } catch (Exception e) { _Logger.Error(() => $"Unable to update ViewModel from View, exception raised: {e.Message}"); } }
public void UpdateOnJavascriptContext(BridgeUpdater updater, IJsCsGlue value) { if (value != null) { UpdateJavascriptValue(value); } UpdateOnJavascriptContext(updater); }
private async Task UpdateOnJavascriptContextWithMapping(BridgeUpdater updater, IList <IJsCsGlue> values) { values.ForEach(UpdateJavascriptValue); foreach (var jsCsGlue in values) { await _SessionMapper.InjectInHtmlSession(jsCsGlue); } RunUpdaterOnJsContext(updater); }
private void UpdateOnJavascriptContextAllContext(BridgeUpdater updater, IJsCsGlue value) { if (Context.JavascriptFrameworkIsMappingObject) { DispatchInJavascriptContext(() => UpdateOnJavascriptContextWithMapping(updater, value)); return; } DispatchInJavascriptContext(() => UpdateOnJavascriptContextWithoutMapping(updater, value)); }
public void OnUiContext(ObjectChangesListener off) { var array = _JsUpdateHelper.GetCached <JsArray>(_Sender); if (array == null) { return; } _BridgeUpdater = GetBridgeUpdater(array); _JsUpdateHelper.UpdateOnUiContext(_BridgeUpdater, off); }
public async void UpdateOnJavascriptContext(BridgeUpdater updater, IList <IJsCsGlue> values) { if (values != null && values.Count > 0) { values.ForEach(UpdateJavascriptValue); foreach (var jsCsGlue in values) { await UpdateJavascriptObject(jsCsGlue); } } UpdateOnJavascriptContext(updater); }
public void UpdateOnJavascriptContext(BridgeUpdater updater, IJsCsGlue value) { if (value == null) { RunUpdaterOnJsContext(updater); return; } if (_Context.JavascriptFrameworkIsMappingObject) { UpdateOnJavascriptContextWithMapping(updater, value).DoNotWait(); return; } UpdateOnJavascriptContextWithoutMapping(updater, value); }
public void UpdateOnJavascriptContext(BridgeUpdater updater, IList <IJsCsGlue> values) { if (values == null || values.Count == 0) { RunUpdaterOnJsContext(updater); return; } if (_Context.JavascriptFrameworkIsMappingObject) { UpdateOnJavascriptContextWithMapping(updater, values).DoNotWait(); return; } UpdateOnJavascriptContextWithoutMapping(updater, values); }
private void OnExit(IJSCSGlue exiting, BridgeUpdater context) { exiting.ApplyOnListenable(_ListenerRegister.Off); if ((context == null) || (exiting.Type != JsCsGlueType.Object)) { return; } _SessionCache.RemoveFromCSharpToJs(exiting); context.RequestJSCacheRemove(exiting); if (!exiting.CValue.GetType().HasReadWriteProperties()) { return; } context.RequestUnlisten(exiting.JSValue); }
private Task UpdateFromCSharpChanges(Func <BridgeUpdater> updaterBuilder, bool needToCheckListener) { CheckUIContext(); BridgeUpdater updater = null; using (var relisten = needToCheckListener ? ReListen(): null) { updater = Update(updaterBuilder, relisten); } if (!updater.HasUpdatesOnJavascriptContext) { return(TaskHelper.Ended()); } return(RunInJavascriptContext(() => { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); })); }
private Task <IJSCSGlue> UpdateFromCSharpChanges(object newCSharpObject, Func <IJSCSGlue, BridgeUpdater> updaterBuilder) { CheckUIContext(); var value = _JSObjectBuilder.Map(newCSharpObject); if (value == null) { return(null); } BridgeUpdater updater = null; using (var relisten = value.IsBasicNotNull()? null : ReListen()) { updater = Update(() => updaterBuilder(value), relisten); } if (!_IsLoaded) { return(Task.FromResult(value)); } return(RunInJavascriptContext(async() => { _BuilderStrategy.UpdateJavascriptValue(value); if (_Context.JavascriptFrameworkIsMappingObject) { await InjectInHTMLSession(value); } updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); return value; })); }
private void RunUpdaterOnJsContext(BridgeUpdater updater) { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); }
private void UpdateOnJavascriptContextWithoutMapping(BridgeUpdater updater, IJsCsGlue value) { UpdateJavascriptValue(value); RunUpdaterOnJsContext(updater); }
public PropertyJsContextUpdater(IJsUpdateHelper jsUpdateHelper, BridgeUpdater bridgeUpdater, IJsCsGlue newJsValue) { _BridgeUpdater = bridgeUpdater; _NewJsValue = newJsValue; _JsUpdateHelper = jsUpdateHelper; }
private void UpdateOnJavascriptContext(BridgeUpdater updater, IJsCsGlue value) { _BuilderStrategy.UpdateJavascriptValue(value); updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }
private static Tuple <BridgeUpdater, List <IJsCsGlue> > FromBridge(BridgeUpdater bridgeUpdater) => Tuple.Create <BridgeUpdater, List <IJsCsGlue> >(bridgeUpdater, null);
private void UpdateOnJavascriptContextWithoutMapping(BridgeUpdater updater, IEnumerable <IJsCsGlue> values) { values.ForEach(UpdateJavascriptValue); RunUpdaterOnJsContext(updater); }
public async void OnJavaScriptObjectChanges(IJavascriptObject objectchanged, string propertyName, IJavascriptObject newValue) { try { var currentfather = _SessionCache.GetCached(objectchanged) as JsGenericObject; if (currentfather == null) { return; } var propertyUpdater = currentfather.GetPropertyUpdater(propertyName); if (!propertyUpdater.IsSettable) { LogReadOnlyProperty(propertyName); return; } var targetType = propertyUpdater.TargetType; var glue = GetCachedOrCreateBasic(newValue, targetType); var bridgeUpdater = new BridgeUpdater(_SessionCache); await Context.RunOnUiContextAsync(() => { using (_ListenerRegister.GetPropertySilenter(currentfather.CValue, propertyName)) { var oldValue = propertyUpdater.GetCurrentChildValue(); try { propertyUpdater.Set(glue.CValue); } catch (Exception exception) { LogSetError(propertyName, targetType, glue.CValue, exception); } var actualValue = propertyUpdater.GetCurrentChildValue(); if (Object.Equals(actualValue, glue.CValue)) { var old = currentfather.UpdateGlueProperty(propertyUpdater, glue); bridgeUpdater.Remove(old); bridgeUpdater.CleanAfterChangesOnUiThread(_ListenerRegister.Off); return; } if (!Object.Equals(oldValue, actualValue)) { OnCSharpPropertyChanged(currentfather.CValue, new PropertyChangedEventArgs(propertyName)); } } }); if (!bridgeUpdater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { bridgeUpdater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }); } catch (Exception exception) { LogJavascriptSetException(exception); } }
public void UpdateOnJavascriptContext(BridgeUpdater updater) { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater, _SessionCache); }
public ReListener(IUpdatableJSCSGlueCollection updatableGlueCollection, BridgeUpdater updater) { _UpdatableGlueCollection = updatableGlueCollection; _Old = _UpdatableGlueCollection.GetAllChildren(); _BridgeUpdater = updater; }
public void UpdateOnJavascriptContext(BridgeUpdater updater, IList <IJsCsGlue> values) { values?.ForEach(UpdateJavascriptValue); UpdateOnJavascriptContext(updater); }
public CollectionsContextUpdater(IJsUpdateHelper jsUpdateHelper, BridgeUpdater bridgeUpdater, List <IJsCsGlue> newJsValues) { _BridgeUpdater = bridgeUpdater; _NewJsValues = newJsValues; _JsUpdateHelper = jsUpdateHelper; }
public void UpdateOnUiContext(BridgeUpdater updater, ObjectChangesListener off) { updater.CleanAfterChangesOnUiThread(off, _SessionCache); }
private void UpdateCollection(JsArray array, object collection, CollectionChanges.CollectionChanges change, BridgeUpdater updater) { try { using (_ListenerRegister.GetColllectionSilenter(collection)) { array.UpdateEventArgsFromJavascript(change, updater); } updater.CleanAfterChangesOnUiThread(_ListenerRegister.Off); } catch (Exception exception) { LogJavascriptSetException(exception); } }
private IExitContext ReListen(BridgeUpdater updater = null) => new ReListener(this, updater);
public void SetBridgeUpdater(BridgeUpdater bridgeUpdater) { _BridgeUpdater = bridgeUpdater; }