Exemplo n.º 1
0
        public TriggerOnEntryNotifier(PropertyChangedEventHandler handler, INotifierPropertyEntry entry, TriggerPath path)
            : base(path, handler)
        {
            entry.PropertyChanged += Handler;
            _onDispose             = () => entry.PropertyChanged -= Handler;

            if (Path == null)
            {
                return;
            }

            void NextHandler(object sender, PropertyChangedEventArgs arg)
            {
                _next?.Dispose();
                if (arg is NotifierPropertyChangedEventArgs notifierArg)
                {
                    _next = notifierArg.NewValue != null?Subscribe(notifierArg.NewValue) : null;
                }
            }

            entry.RegisterValue += NextHandler;
            _onDispose          += () => entry.RegisterValue -= NextHandler;
            _onDispose          += () => _next?.Dispose();

            if (!entry.IsSet)
            {
                entry.Update();
            }

            var value = entry.GetValue();

            NextHandler(null, new NotifierPropertyChangedEventArgs(entry, null, value));
        }
 public NotifierPropertyChangedEventArgs(INotifierPropertyEntry entry, object oldValue, object newValue) : base(entry.Property.Name)
 {
     Entry    = entry;
     OldValue = oldValue;
     NewValue = newValue;
 }