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

            Items.Clear();
            return(bridgeUpdater);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo n.º 5
0
 private static BridgeUpdater CheckForRemove(BridgeUpdater updater, IJsCsGlue glue)
 {
     if (glue.Release())
     {
         updater.Remove(glue);
     }
     return(updater);
 }
Exemplo 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));
        }
Exemplo n.º 7
0
        public BridgeUpdater GetResetUpdater()
        {
            var bridgeUpdater = new BridgeUpdater(ClearAllJavascriptCollection);

            foreach (var item in Items)
            {
                CheckForRemove(bridgeUpdater, item);
            }
            Items.Clear();
            return(bridgeUpdater);
        }
Exemplo n.º 8
0
 private static BridgeUpdater CheckForRemove(BridgeUpdater updater, List <IJsCsGlue> glues)
 {
     glues.ForEach(glue =>
     {
         if (glue.Release())
         {
             updater.Remove(glue);
         }
     });
     return(updater);
 }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }