public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            ValueChangedNotificationResult <T> targetChange = null;

            foreach (var change in sources)
            {
                if (change.Source == Target)
                {
                    targetChange = change as ValueChangedNotificationResult <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);
        }
예제 #2
0
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            ValueChangedNotificationResult <T>        targetChange = null;
            ValueChangedNotificationResult <TElement> valueChange  = null;

            if (sources.Count == 1)
            {
                if (sources[0].Source == Target)
                {
                    targetChange = sources[0] as ValueChangedNotificationResult <T>;
                }
                else
                {
                    valueChange = sources[0] as ValueChangedNotificationResult <TElement>;
                }
            }
            else if (sources.Count == 2)
            {
                if (sources[0].Source == Target)
                {
                    targetChange = sources[0] as ValueChangedNotificationResult <T>;
                    valueChange  = sources[1] as ValueChangedNotificationResult <TElement>;
                }
                else
                {
                    targetChange = sources[1] as ValueChangedNotificationResult <T>;
                    valueChange  = sources[0] as ValueChangedNotificationResult <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);
            }
        }
        public override INotificationResult Notify(IList <INotificationResult> sources)
        {
            ValueChangedNotificationResult <T> targetChange = null;

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

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

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