Пример #1
0
 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);
     }
 }
Пример #2
0
 public void UpdateOnUiContext(BridgeUpdater updater, ObjectChangesListener off)
 {
     updater.CleanAfterChangesOnUiThread(off, _SessionCache);
 }
Пример #3
0
        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);
            }
        }