Class PropertyMonitor
A base class used to monitor properties for changes.
Inheritance
Inherited Members
Namespace: Gorgon.Editor
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class PropertyMonitor : INotifyPropertyChanging, INotifyPropertyChanged
Properties
| Edit this page View SourceUsePropertyNameValidation
Property to set or return whether to use property name validation when evaluating property changes.
Declaration
public static bool UsePropertyNameValidation { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
For DEBUG builds, users should set this value to true so that any mis-type of a property name can be caught.
Methods
| Edit this page View SourceNotifyAllPropertiesChanged()
Function to notify that all properties on this type have changed their values.
Declaration
public void NotifyAllPropertiesChanged()
NotifyAllPropertiesChanging()
Function to notify that all properties on this type are changing their values.
Declaration
public void NotifyAllPropertiesChanging()
NotifyPropertyChanged(string)
Function to notify when a property has been changed.
Declaration
public void NotifyPropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | Name of the property to change. |
Remarks
This method used to notify when a property has changed outside of the property setter, or if a property other than the current property has changed inside of a property setter. The
user can specify the name of the property manually through the propertyName
parameter.
Do not use this method in the setter for the property that is notifying. In that case, call the OnPropertyChanged(string) method instead.
warning
If the name of the property has changed, then calls to this method must be changed to reflect the new property name. Otherwise, functionality will break as the notification will point to an invalid property. To that end, applications should use the C# nameof operator when passing a property name to this method.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
NotifyPropertyChanging(string)
Function to notify before a property is changed.
Declaration
public void NotifyPropertyChanging(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | Name of the property to change. |
Remarks
This method is used to notify before a property is changed outside of the property setter, or if a property other than the current property is changing inside of a property setter. The
user can specify the name of the property manually through the propertyName
parameter.
Do not use this method in the setter for the property that is notifying. In that case, call the OnPropertyChanging(string) method instead.
warning
If the name of the property has changed, then calls to this method must be changed to reflect the new property name. Otherwise, functionality will break as the notification will point to an invalid property. To that end, applications should use the C# nameof operator when passing a property name to this method.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
OnPropertyChanged(string)
Function to notify when a property has been changed within a property setter.
Declaration
protected void OnPropertyChanged(string propertyName = "")
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | [Automatically set by the compiler] The name of the property that called this method. |
Remarks
Unlike the NotifyPropertyChanged(string), this method will automatically determine the name of the property that called it. Therefore, the user should not set the
propertyName
parameter manually.
OnPropertyChanging(string)
Function to notify when a property is about to be changed within a property setter.
Declaration
protected void OnPropertyChanging(string propertyName = "")
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | [Automatically set by the compiler] The name of the property that called this method. |
Remarks
Unlike the NotifyPropertyChanging(string), this method will automatically determine the name of the property that called it. Therefore, the user should not set the
propertyName
parameter manually.
Events
| Edit this page View SourcePropertyChanged
Event triggered when a property is changed.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |
PropertyChanging
Event triggered before a property is changed.
Declaration
public event PropertyChangingEventHandler PropertyChanging
Event Type
Type | Description |
---|---|
PropertyChangingEventHandler |