Exemplo n.º 1
0
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            IValueChangedNotificationResult <bool> leftChange = null;

            if (sources.Count >= 1 && sources[0].Source == Left)
            {
                leftChange = sources[0] as IValueChangedNotificationResult <bool>;
            }
            else if (sources.Count >= 2 && sources[1].Source == Left)
            {
                leftChange = sources[1] as IValueChangedNotificationResult <bool>;
            }

            if (leftChange != null)
            {
                if (leftChange.NewValue)
                {
                    Right.Successors.Unset(this);
                }
                else
                {
                    Right.Successors.Set(this);
                }
            }
            return(base.Notify(sources));
        }
Exemplo n.º 2
0
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            IValueChangedNotificationResult <T> targetChange = null;

            foreach (var change in sources)
            {
                if (change.Source == Target)
                {
                    targetChange = change as IValueChangedNotificationResult <T>;
                    break;
                }
            }

            if (targetChange != null)
            {
                listener.Unsubscribe();
                AttachCollectionChangeListener(targetChange.NewValue);
                RenewFunction();
            }

            var oldValue = Value;
            var result   = base.Notify(sources);

            if (result.Changed)
            {
                var disposable = oldValue as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        private void NotifyOuterKey(IValueChangedNotificationResult <TKey> keyChange, List <TResult> added, List <TResult> removed)
        {
            var value = (TaggedObservableValue <TKey, TOuter>)keyChange.Source;
            var group = groups[keyChange.OldValue];

            group.OuterElements.Remove(value);

            if (group.InnerKeys.Count != 0)
            {
                var result = group.OuterElements[value];
                removed.Add(result.Value);
                result.Successors.Unset(this);
            }

            if (!groups.TryGetValue(value.Value, out group))
            {
                group = new KeyGroup();
                groups.Add(value.Value, group);
            }

            var newResult = resultSelector.InvokeTagged(value.Tag, group.InnerElements, value.Tag);

            newResult.Successors.Set(this);
            group.OuterElements.Add(value, newResult);
            if (group.InnerKeys.Count != 0)
            {
                added.Add(newResult.Value);
            }
        }
Exemplo n.º 4
0
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            IValueChangedNotificationResult <T>        targetChange = null;
            IValueChangedNotificationResult <TElement> valueChange  = null;

            if (sources.Count == 1)
            {
                if (sources[0].Source == Target)
                {
                    targetChange = sources[0] as IValueChangedNotificationResult <T>;
                }
                else
                {
                    valueChange = sources[0] as IValueChangedNotificationResult <TElement>;
                }
            }
            else if (sources.Count == 2)
            {
                if (sources[0].Source == Target)
                {
                    targetChange = sources[0] as IValueChangedNotificationResult <T>;
                    valueChange  = sources[1] as IValueChangedNotificationResult <TElement>;
                }
                else
                {
                    targetChange = sources[1] as IValueChangedNotificationResult <T>;
                    valueChange  = sources[0] as IValueChangedNotificationResult <TElement>;
                }
            }

            if (targetChange != null && valueChange != null)
            {
                RemoveAction(targetChange.OldValue, valueChange.OldValue);
                AddAction(targetChange.NewValue, valueChange.NewValue);
                return(new ValueChangedNotificationResult <T>(this, targetChange.OldValue, targetChange.NewValue));
            }
            else if (targetChange != null)
            {
                RemoveAction(targetChange.OldValue, Value.Value);
                AddAction(targetChange.NewValue, Value.Value);
                return(new ValueChangedNotificationResult <T>(this, targetChange.OldValue, targetChange.NewValue));
            }
            else if (valueChange != null)
            {
                RemoveAction(Target.Value, valueChange.OldValue);
                AddAction(Target.Value, valueChange.NewValue);
                return(new ValueChangedNotificationResult <T>(this, Target.Value, Target.Value));
            }
            else
            {
                return(UnchangedNotificationResult.Instance);
            }
        }
Exemplo n.º 5
0
        private void NotifyInnerKey(IValueChangedNotificationResult <TKey> keyChange, List <TResult> added, List <TResult> removed)
        {
            var value = (TaggedObservableValue <TKey, TInner>)keyChange.Source;
            var group = groups[keyChange.OldValue];

            group.InnerKeys.Remove(value);
            if (group.InnerKeys.Count == 0)
            {
                removed.AddRange(group.OuterElements.Values.Select(r => r.Value));
            }

            if (!groups.TryGetValue(value.Value, out group))
            {
                group = new KeyGroup();
                groups.Add(value.Value, group);
            }
            group.InnerKeys.Add(value);
            if (group.InnerKeys.Count == 1)
            {
                added.AddRange(group.OuterElements.Values.Select(r => r.Value));
            }
        }
Exemplo n.º 6
0
        private void NotifyInnerKey(IValueChangedNotificationResult <TKey> keyChange, List <TResult> replaceAdded, List <TResult> replaceRemoved)
        {
            var value = (TaggedObservableValue <TKey, TInner>)keyChange.Source;
            var group = groups[keyChange.OldValue];

            group.InnerKeys.Remove(value);
            foreach (var outer in group.OuterKeys)
            {
                replaceRemoved.Add(DetachResult(group, outer.Tag, value.Tag));
            }

            if (!groups.TryGetValue(value.Value, out group))
            {
                group = new KeyGroup();
                groups.Add(value.Value, group);
            }
            group.InnerKeys.Add(value);

            foreach (var outer in group.OuterKeys)
            {
                replaceAdded.Add(AttachResult(group, outer.Tag, value.Tag));
            }
        }
Exemplo n.º 7
0
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            IValueChangedNotificationResult <T> targetChange = null;

            if (sources.Count >= 1 && sources[0].Source == Target)
            {
                targetChange = sources[0] as IValueChangedNotificationResult <T>;
            }
            else if (sources.Count == 2 && sources[1].Source == Target)
            {
                targetChange = sources[1] as IValueChangedNotificationResult <T>;
            }

            if (targetChange != null)
            {
                listener.Unsubscribe();
                AttachPropertyChangeListener(targetChange.NewValue);
            }

            Apply();
            Value.Value = MemberGet(Target.Value);
            return(new ValueChangedNotificationResult <T>(this, targetChange.OldValue, targetChange.NewValue));
        }