Class NotifyPropertyChangeBase
Base class for all types that implement a property change notification pattern via either INotifyPropertyChanged or INotifyPropertyChanging.
Inheritance
Inherited Members
Namespace: TheXDS.MCART.Types.Base
Assembly: MCART.Mvvm.dll
Syntax
public abstract class NotifyPropertyChangeBase : INotifyPropertyChangeBase, IRefreshable
Constructors
| Edit this page View SourceNotifyPropertyChangeBase()
Initializes a new instance of the NotifyPropertyChangeBase
Declaration
protected NotifyPropertyChangeBase()
Methods
| Edit this page View SourceChange<T>(ref T, T, string)
Changes the value of a property's backing field, invoking a property change notification.
Declaration
protected bool Change<T>(ref T field, T value, string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
T | field | Backing field to be updated. |
T | value | New value to be set onto the backing field. |
string | propertyName | Property name. Must be ommitted, as it's determined at compile time. Implementors of this class must decorate this parameter with the CallerMemberNameAttribute attribute. |
Returns
Type | Description |
---|---|
bool | true if the value of the backing field has changed; that is, if the original and the new values are considered different. false is returned otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of the backing field for the property. |
OnDoChange<T>(ref T, T, string)
Performs the actual value change on a backing field for a property.
Declaration
protected abstract void OnDoChange<T>(ref T field, T value, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
T | field | Backing field to be updated. |
T | value | New value to be set onto the backing field. |
string | propertyName | Name of the property. |
Type Parameters
Name | Description |
---|---|
T | Type of the backing field for the property. |
OnInitialize(IPropertyBroadcastSetup)
When overriden in a derived class, allows the configuration of property change broadcast and notification triggers
Declaration
protected virtual void OnInitialize(NotifyPropertyChangeBase.IPropertyBroadcastSetup broadcastSetup)
Parameters
Type | Name | Description |
---|---|---|
NotifyPropertyChangeBase.IPropertyBroadcastSetup | broadcastSetup | Internal instance used to configure the property change broadcast and notification triggers. |
RaisePropertyChangeEvent(in string, in PropertyChangeNotificationType)
Raises the appropriate property change notification event.
Declaration
protected abstract void RaisePropertyChangeEvent(in string propertyName, in PropertyChangeNotificationType notificationType)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | Property name for the event to be triggered. |
PropertyChangeNotificationType | notificationType | Type of property change notification. |
Refresh()
Refreshes the state of this object.
Declaration
public virtual void Refresh()
Subscribe(Expression<Func<object?>>, PropertyChangeObserver)
Subscribes a delegate to be executed when a specific property changes its value.
Declaration
public void Subscribe(Expression<Func<object?>> propertySelector, PropertyChangeObserver callback)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<object>> | propertySelector | Expression that selects the property to subscribe the action for. |
PropertyChangeObserver | callback | Action to execute when the property changes its value. |
Subscribe(PropertyInfo?, PropertyChangeObserver)
Subscribes a delegate to be executed when a specific property changes its value.
Declaration
public void Subscribe(PropertyInfo? property, PropertyChangeObserver callback)
Parameters
Type | Name | Description |
---|---|---|
PropertyInfo | property | Property to subscribe the action for. |
PropertyChangeObserver | callback | Action to execute when the property changes its value. |
Subscribe(PropertyChangeObserver)
Subscribes a delegate to be executed when any property changes its value.
Declaration
public void Subscribe(PropertyChangeObserver callback)
Parameters
Type | Name | Description |
---|---|---|
PropertyChangeObserver | callback | Action to execute when the property changes its value. |
Unsubscribe(Expression<Func<object?>>)
Removes all previously subscribed actions for the specified property.
Declaration
public bool Unsubscribe(Expression<Func<object?>> propertySelector)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<object>> | propertySelector | Expression that selects the property to unsubscribe the previously subscribed actions for. |
Returns
Type | Description |
---|---|
bool |
Unsubscribe(PropertyInfo?)
Removes all previously subscribed actions for the specified property.
Declaration
public bool Unsubscribe(PropertyInfo? property)
Parameters
Type | Name | Description |
---|---|---|
PropertyInfo | property | Property for which to remove all subscribed observers. If null is passed, all global subcribers for this instance will be removed. |
Returns
Type | Description |
---|---|
bool | true if there was a previously registered callback to invoke when the specified property changed its value and has beed removed successfully, false otherwise. |
Unsubscribe(PropertyChangeObserver)
Removes the previously subscribed property change observer.
Declaration
public void Unsubscribe(PropertyChangeObserver callback)
Parameters
Type | Name | Description |
---|---|---|
PropertyChangeObserver | callback | Delegeta to unsubscribe. |