コード例 #1
0
        private void OnChildPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
        {
            var subscription = NotifySubscribers.FirstOrDefault(pair => pair.Value.Equals(sender));
            var args         = new NotifyRouter.ChildPropertyChangedEventArgs(propertyChangedEventArgs.PropertyName)
            {
                ParentPropertyName = subscription.Key,
                Value = sender.GetType().GetProperty(propertyChangedEventArgs.PropertyName).GetValue(sender)
            };

            ChildPropertyChanged?.Invoke(sender, args);
        }
コード例 #2
0
 private void SetNotifyRouting <T>(ref T oldValue, T newValue, string propertyName)
 {
     if (oldValue is INotifyPropertyChanged notifyOldValue)
     {
         if (NotifySubscribers.ContainsKey(propertyName))
         {
             NotifySubscribers[propertyName].PropertyChanged -= OnChildPropertyChanged;
         }
     }
     SubscribeChildNotifications(newValue, propertyName);
 }
コード例 #3
0
        private void SubscribeChildNotifications <T>(T newValue, string propertyName)
        {
            if (newValue is INotifyPropertyChanged notifyNewValue)
            {
                if (!NotifySubscribers.ContainsKey(propertyName))
                {
                    NotifySubscribers.Add(propertyName, notifyNewValue);
                }

                notifyNewValue.PropertyChanged += OnChildPropertyChanged;
            }
        }
コード例 #4
0
        //call the event
        public void Notify(string name)
        {
            list.Add(name);

            //instantiate the delegate
            NotifySubscribers ns = new NotifySubscribers((l) =>
            {
                Console.WriteLine("Welcome {0}", name);
            });

            //bind the delegate to the event
            EventNotify += ns;
        }
コード例 #5
0
 public void UnSubscribeForVideo(NotifySubscribers subscriber)
 {
     NotifySubsribersHandler -= subscriber;
 }