Gorgon
Show / Hide Table of Contents

Class PropertyMonitor

A base class used to monitor properties for changes.

Inheritance
object
PropertyMonitor
ContentFileExplorerDirectoryEntry
ContentFileExplorerFileEntry
ViewModelBase<T, THs>
Implements
INotifyPropertyChanging
INotifyPropertyChanged
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Editor
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class PropertyMonitor : INotifyPropertyChanging, INotifyPropertyChanged

Properties

| Edit this page View Source

UsePropertyNameValidation

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 Source

NotifyAllPropertiesChanged()

Function to notify that all properties on this type have changed their values.

Declaration
public void NotifyAllPropertiesChanged()
| Edit this page View Source

NotifyAllPropertiesChanging()

Function to notify that all properties on this type are changing their values.

Declaration
public void NotifyAllPropertiesChanging()
| Edit this page View Source

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 propertyName is NULL (Nothing in VB.Net).

ArgumentEmptyException

Thrown when the propertyName is empty.

| Edit this page View Source

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 propertyName is NULL (Nothing in VB.Net).

ArgumentEmptyException

Thrown when the propertyName is empty.

| Edit this page View Source

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.

| Edit this page View Source

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 Source

PropertyChanged

Event triggered when a property is changed.

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
PropertyChangedEventHandler
| Edit this page View Source

PropertyChanging

Event triggered before a property is changed.

Declaration
public event PropertyChangingEventHandler PropertyChanging
Event Type
Type Description
PropertyChangingEventHandler

Implements

INotifyPropertyChanging
INotifyPropertyChanged

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author