Example #1
0
        public void SetUp()
        {
            _serverUpdateStream = new Subject <Either <FullUpdate, DeltaUpdate> >();

            _dictionaryModificationStream = _serverUpdateStream
                                            .Select(either =>
            {
                if (either.IsLeft)
                {
                    return(DictionaryModification.Replace(either.Left.Values["key"], (Update)either.Left));
                }
                else
                {
                    return(DictionaryModification.Upset(either.Right.Values["key"], (Update)either.Right));
                }
            });

            _observableDictionary = _dictionaryModificationStream.ToObservableDictionary((key, existing, update) =>
            {
                var fullUpdate = new FullUpdate(key)
                {
                    Values = new Dictionary <string, string>(existing.Values)
                };

                foreach (var kvp in update)
                {
                    fullUpdate.Values[kvp.Key] = kvp.Value;
                }

                return(fullUpdate);
            });
        }
Example #2
0
        public void SetUp()
        {
            _serverUpdateStream = new Subject<Either<FullUpdate, DeltaUpdate>>();

            _dictionaryModificationStream = _serverUpdateStream
                .Select(either =>
                {
                    if (either.IsLeft)
                    {
                        return DictionaryModification.Replace(either.Left.Values["key"], (Update)either.Left);
                    }
                    else
                    {
                        return DictionaryModification.Upset(either.Right.Values["key"], (Update)either.Right);
                    }
                });

            _observableDictionary = _dictionaryModificationStream.ToObservableDictionary((key, existing, update) =>
            {
                var fullUpdate = new FullUpdate(key)
                {
                    Values = new Dictionary<string, string>(existing.Values)
                };

                foreach (var kvp in update)
                {
                    fullUpdate.Values[kvp.Key] = kvp.Value;
                }

                return fullUpdate;
            });
        }