コード例 #1
0
        private void propertyChanged(object sender, PropertyChangedEventArgs e)
        {
            Contract.Requires(sender != null);
            Contract.Requires(e != null);
            var propertyInfo = sender.GetType().GetProperty(e.PropertyName);

            Contract.Requires(propertyInfo != null, $"No public property '{e.PropertyName}' could not be found on an instance of type '{sender.GetType().FullName}'");

            if (IncludeDeep(sender, e.PropertyName))
            {
                if (!(e is IPropertyMutatedEventArgs m))
                {
                    throw new ContractException("For view model properties that have nested viewmodels, the old value needs to be accessible (for unregistering). ");
                }
                // Alternatively, we may store the old values ourselves.
                // A potential bug (or it's more like an assumption) is this:
                // Suppose a property is mutated, but it's property changed event invocation is suspended, then it is modified again, and then the event is raised.
                // Here I'm assuming that the old value is then the original value, not the intermediate value, because I still need to unregister the original value

                if (m.OldValue != null)
                {
                    this.unregisterViewModel(m.OldValue);
                }
                if (m.NewValue != null)
                {
                    this.registerViewmodelAndAddCompleteStateAsChanges(m.NewValue);
                }
            }

            if (IncludeProperty(sender, propertyInfo))
            {
                var value = propertyInfo.GetValue(sender);
                this.AddChange(PropertyChange.Create(idProvider[sender], e.PropertyName, value));
            }
        }
コード例 #2
0
ファイル: Reflection.cs プロジェクト: JeroenBos/BrowserApp
            public void Accept(INotifyPropertyChanged container)
            {
                int containerId = this.idProvider[container];

                foreach (var propertyInfo in GetIncludedProperties(container))
                {
                    object value = propertyInfo.GetValue(container);
                    this.changes.Add(PropertyChange.Create(containerId, propertyInfo.Name, value, idProvider));
                }
            }
コード例 #3
0
 public void Execute(object parameter)
 {
     System.Threading.Thread.Sleep(3000);
     userSession.RegisterChange(PropertyChange.Create(0, "prop", 1));
 }