blob: f8264614facf48bce985790099b7b5e9879bd17a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.WixBA
{
using System;
using System.ComponentModel;
using System.Diagnostics;
/// <summary>
/// It provides support for property change notifications.
/// </summary>
public abstract class PropertyNotifyBase : INotifyPropertyChanged
{
/// <summary>
/// Initializes a new instance of the <see cref="PropertyNotifyBase"/> class.
/// </summary>
protected PropertyNotifyBase()
{
}
/// <summary>
/// Raised when a property on this object has a new value.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Warns the developer if this object does not have a public property with the
/// specified name. This method does not exist in a Release build.
/// </summary>
/// <param name="propertyName">Property name to verify.</param>
[Conditional("DEBUG")]
[DebuggerStepThrough]
public void VerifyPropertyName(string propertyName)
{
// Verify that the property name matches a real, public, instance property
// on this object.
if (null == TypeDescriptor.GetProperties(this)[propertyName])
{
Debug.Fail(String.Concat("Invalid property name: ", propertyName));
}
}
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="propertyName">The property that has a new value.</param>
protected virtual void OnPropertyChanged(string propertyName)
{
this.VerifyPropertyName(propertyName);
PropertyChangedEventHandler handler = this.PropertyChanged;
if (null != handler)
{
PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
}
}
|