本文整理汇总了C#中Parent.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Parent.GetProperty方法的具体用法?C# Parent.GetProperty怎么用?C# Parent.GetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parent
的用法示例。
在下文中一共展示了Parent.GetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SequenceOfChanges
public void SequenceOfChanges()
{
var parent = new Parent { Child = new Child("c") };
var propertyChanges = new List<string>();
var changes = new List<EventArgs>();
var expected = new List<EventArgs>();
using (var tracker = Track.Changes(parent, ReferenceHandling.Structural))
{
tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
tracker.Changed += (_, e) => changes.Add(e);
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
parent.Name = "Poppa";
Assert.AreEqual(1, tracker.Changes);
CollectionAssert.AreEqual(new[] { "Changes" }, propertyChanges);
var parentNode = ChangeTrackerNode.GetOrCreate(parent, tracker.Settings, false).Value;
expected.Add(RootChangeEventArgs.Create(parentNode, new PropertyChangeEventArgs(parent, parent.GetProperty("Name"))));
CollectionAssert.AreEqual(expected, changes, EventArgsComparer.Default);
parent.Child = new Child("Child");
Assert.AreEqual(2, tracker.Changes);
CollectionAssert.AreEqual(new[] { "Changes", "Changes" }, propertyChanges);
expected.Add(RootChangeEventArgs.Create(parentNode, new PropertyChangeEventArgs(parent, parent.GetProperty("Child"))));
CollectionAssert.AreEqual(expected, changes, EventArgsComparer.Default);
parent.Child.Parent = parent;
Assert.AreEqual(3, tracker.Changes);
CollectionAssert.AreEqual(new[] { "Changes", "Changes", "Changes" }, propertyChanges);
expected.Add(new PropertyGraphChangedEventArgs<ChangeTrackerNode>(parentNode, parent.GetProperty("Child"), RootChangeEventArgs.Create(ChangeTrackerNode.GetOrCreate(parent.Child, tracker.Settings, false).Value, new PropertyChangeEventArgs(parent.Child, parent.Child.GetProperty("Parent")))));
CollectionAssert.AreEqual(expected, changes, EventArgsComparer.Default);
parent.Name += "meh";
Assert.AreEqual(4, tracker.Changes);
CollectionAssert.AreEqual(new[] { "Changes", "Changes", "Changes", "Changes" }, propertyChanges);
expected.Add(RootChangeEventArgs.Create(parentNode, new PropertyChangeEventArgs(parent, parent.GetProperty("Name"))));
CollectionAssert.AreEqual(expected, changes, EventArgsComparer.Default);
}
}
示例2: ParentNameChanges
public void ParentNameChanges()
{
var parent = new Parent { Child = new Child("") };
parent.Child.Parent = parent;
var propertyChanges = new List<string>();
var changes = new List<EventArgs>();
using (var tracker = Track.Changes(parent, ReferenceHandling.Structural))
{
tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
tracker.Changed += (_, e) => changes.Add(e);
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(changes);
parent.Name += "abc";
Assert.AreEqual(1, tracker.Changes);
CollectionAssert.AreEqual(new[] { "Changes" }, propertyChanges);
var expected = new[] { RootChangeEventArgs.Create(ChangeTrackerNode.GetOrCreate(parent, tracker.Settings, false).Value, new PropertyChangeEventArgs(parent, parent.GetProperty(nameof(parent.Name)))) };
CollectionAssert.AreEqual(expected, changes, EventArgsComparer.Default);
}
}