本文整理汇总了C#中DummyClass.RaisePropertyChanged方法的典型用法代码示例。如果您正苦于以下问题:C# DummyClass.RaisePropertyChanged方法的具体用法?C# DummyClass.RaisePropertyChanged怎么用?C# DummyClass.RaisePropertyChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DummyClass
的用法示例。
在下文中一共展示了DummyClass.RaisePropertyChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePropertyChangedEvents
public void HandlePropertyChangedEvents()
{
bool valueChanged = false;
bool textChanged = false;
DummyClass source = new DummyClass();
PropertyObserver<DummyClass> observer = new PropertyObserver<DummyClass>(source);
observer.RegisterHandler("Value", src => valueChanged = true);
observer.RegisterHandler(src => src.Text, src => textChanged = true);
Assert.IsFalse(valueChanged);
Assert.IsFalse(textChanged);
source.Value = 10;
Assert.IsTrue(valueChanged);
Assert.IsFalse(textChanged);
valueChanged = false;
source.Text = "abc";
Assert.IsFalse(valueChanged);
Assert.IsTrue(textChanged);
textChanged = false;
source.RaisePropertyChanged();
Assert.IsTrue(valueChanged);
Assert.IsTrue(textChanged);
valueChanged = false;
textChanged = false;
observer.UnregisterHandler("Value");
source.RaisePropertyChanged();
Assert.IsFalse(valueChanged);
Assert.IsTrue(textChanged);
textChanged = false;
observer.UnregisterHandler(src => src.Text);
source.RaisePropertyChanged();
Assert.IsFalse(valueChanged);
Assert.IsFalse(textChanged);
}
示例2: SourceIsWeakReference
public void SourceIsWeakReference()
{
bool valueChanged = false;
bool textChanged = false;
DummyClass source = new DummyClass();
PropertyObserver<DummyClass> observer = new PropertyObserver<DummyClass>(source);
observer.RegisterHandler("Value", src => valueChanged = true);
observer.RegisterHandler(src => src.Text, src => textChanged = true);
source.RaisePropertyChanged();
Assert.IsTrue(valueChanged);
Assert.IsTrue(textChanged);
Assert.IsFalse(_dummyClassFinalized);
source = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Assert.IsTrue(_dummyClassFinalized);
observer.UnregisterHandler("Value");
observer.UnregisterHandler(src => src.Text);
}