Esempio n. 1
0
        public BridgeUpdater GetResetUpdater()
        {
            var bridgeUpdater = new BridgeUpdater(ClearAllJavascriptCollection).CheckForRemove(Items);

            Items.Clear();
            return(bridgeUpdater);
        }
Esempio n. 2
0
        public BridgeUpdater GetReplaceUpdater(IJsCsGlue glue, int index)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, 1, glue));
            var old           = ReplaceAndReturnOld(index, glue.AddRef());

            return(bridgeUpdater.CheckForRemove(old));
        }
Esempio n. 3
0
        public BridgeUpdater GetRemoveUpdater(int index)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, 1));
            var old           = Items[index];

            Items.RemoveAt(index);
            return(CheckForRemove(bridgeUpdater, old));
        }
Esempio n. 4
0
        public BridgeUpdater GetReplaceUpdater(IJsCsGlue glue, int index)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, 1, glue));
            var old           = Items[index];

            Items[index] = glue.AddRef();
            return(CheckForRemove(bridgeUpdater, old));
        }
Esempio n. 5
0
 private static BridgeUpdater CheckForRemove(BridgeUpdater updater, IJsCsGlue glue)
 {
     if (glue.Release())
     {
         updater.Remove(glue);
     }
     return(updater);
 }
Esempio n. 6
0
        public BridgeUpdater GetReplaceUpdater(List <IJsCsGlue> glues, int index)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, glues.Count, glues));

            glues.ForEach(glue => glue.AddRef());
            var oldChildren = glues.Select((glue, idx) => ReplaceAndReturnOld(index + idx, glue));

            return(bridgeUpdater.CheckForRemove(oldChildren));
        }
Esempio n. 7
0
        public BridgeUpdater GetResetUpdater()
        {
            var bridgeUpdater = new BridgeUpdater(ClearAllJavascriptCollection);

            foreach (var item in Items)
            {
                CheckForRemove(bridgeUpdater, item);
            }
            Items.Clear();
            return(bridgeUpdater);
        }
Esempio n. 8
0
 private static BridgeUpdater CheckForRemove(BridgeUpdater updater, List <IJsCsGlue> glues)
 {
     glues.ForEach(glue =>
     {
         if (glue.Release())
         {
             updater.Remove(glue);
         }
     });
     return(updater);
 }
Esempio n. 9
0
        public BridgeUpdater GetRemoveUpdater(int index, int count)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, count));
            var oldChildren   = Enumerable.Range(0, count).Select(_ =>
            {
                var old = Items[index];
                Items.RemoveAt(index);
                return(old);
            }).ToList();

            return(CheckForRemove(bridgeUpdater, oldChildren));
        }
Esempio n. 10
0
        public BridgeUpdater GetReplaceUpdater(List <IJsCsGlue> glues, int index)
        {
            var bridgeUpdater = new BridgeUpdater(viewModelUpdater => Splice(viewModelUpdater, index, glues.Count, glues));

            var oldChildren = glues.Select((glue, idx) =>
            {
                var currentIndex    = index + idx;
                var old             = Items[currentIndex];
                Items[currentIndex] = glue.AddRef();
                return(old);
            }).ToList();

            return(CheckForRemove(bridgeUpdater, oldChildren));
        }
Esempio n. 11
0
        public BridgeUpdater GetUpdaterChangeOnCSharpContext(AttributeUpdater propertyUpdater, IJsCsGlue glue)
        {
            var update = PrivateUpdateGlueProperty(propertyUpdater, glue);

            BridgeUpdater updater;

            if (!update.AddedProperty)
            {
                updater = new BridgeUpdater(viewModelUpdater => viewModelUpdater.UpdateProperty(CachableJsValue,
                                                                                                propertyUpdater.PropertyName, glue.GetJsSessionValue(), !glue.IsBasic()));
            }
            else
            {
                updater = new BridgeUpdater(viewModelUpdater => viewModelUpdater.AddProperty(CachableJsValue,
                                                                                             propertyUpdater.PropertyName, glue.GetJsSessionValue()));
            }

            return(updater.CheckForRemove(update.OldReference));
        }
Esempio n. 12
0
        public BridgeUpdater GetUpdater(AttibuteUpdater propertyUpdater, IJsCsGlue glue)
        {
            var update = PrivateUpdateGlueProperty(propertyUpdater, glue);

            BridgeUpdater updater;

            if (!update.AddedProperty)
            {
                updater = new BridgeUpdater(viewModelUpdater => viewModelUpdater.UpdateProperty(CachableJsValue,
                                                                                                propertyUpdater.PropertyName, glue.GetJsSessionValue(), !glue.IsBasic()));
            }
            else
            {
                updater = new BridgeUpdater(viewModelUpdater => viewModelUpdater.AddProperty(CachableJsValue,
                                                                                             propertyUpdater.PropertyName, glue.GetJsSessionValue()));
            }

            return(updater.Remove(update.ToBeCleaned));
        }
Esempio n. 13
0
        public void UpdateEventArgsFromJavascript(CollectionChanges.CollectionChanges collectionChanges, BridgeUpdater updater)
        {
            if (!(CValue is IList list))
            {
                return;
            }

            collectionChanges.IndividualChanges.ForEach(c => ReplayChanges(c, list));

            collectionChanges.IndividualChanges.Where(ch => ch.CollectionChangeType == CollectionChangeType.Add)
            .ForEach(ch => ch.Object.AddRef());

            collectionChanges.IndividualChanges.Where(ch => ch.CollectionChangeType == CollectionChangeType.Remove)
            .ForEach(ch => CheckForRemove(updater, ch.Object));
        }