Class PropertyChanges
PropertyChanges is a class for managing property subscriptions both global and per instance.
Global(Un)Subscribe
methods may be used for global subscriptions (for all-instances)
and FirePropertyChanged(INotifyPropertyChangedInvoker, String, Object, Object) should be used to fire both per-instance and global PropertyChanged events.
Usually used in conjunction with Fody PropertyChangedNotificationInterceptor.Intercept
which may be implemented as:
public static class PropertyChangedNotificationInterceptor2
{
public static void Intercept(INotifyPropertyChangedInvoker invoker, string propertyName, object? before, object? after) => PropertyChanges.FirePropertyChanged(invoker, propertyName, before, after);
}
Read more about property changes in README.md.
Inheritance
Namespace: Eco.Core.PropertyHandling
Assembly: Eco.Core.dll
Syntax
public static class PropertyChanges : Object
Methods
FirePropertyChanged(INotifyPropertyChangedInvoker, MemberChangedBeforeAfterEventArgs)
Fires both per-instance (using InvokePropertyChanged) and global property change events.
Declaration
public static void FirePropertyChanged(this INotifyPropertyChangedInvoker invoker, MemberChangedBeforeAfterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
INotifyPropertyChangedInvoker | invoker | |
MemberChangedBeforeAfterEventArgs | args |
FirePropertyChanged(INotifyPropertyChangedInvoker, String, Object, Object)
Fires both per-instance (using InvokePropertyChanged) and global property change events. If before
and after
both null
it assumes that no before/after values available.
Declaration
public static void FirePropertyChanged(this INotifyPropertyChangedInvoker invoker, string propertyName, object before, object after)
Parameters
Type | Name | Description |
---|---|---|
INotifyPropertyChangedInvoker | invoker | |
System.String | propertyName | |
System.Object | before | |
System.Object | after |
FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
If source
is INotifyPropertyChangedInvoker then invokes InvokePropertyChanged which fires per-instance property changes. Anyway fires global property change events.
Declaration
public static void FirePropertyChanged(this object source, MemberChangedBeforeAfterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.Object | source | |
MemberChangedBeforeAfterEventArgs | args |
FirePropertyChanged(Object, String)
If source
is INotifyPropertyChangedInvoker then invokes InvokePropertyChanged which fires per-instance property changes. Anyway fires global property change events.
Declaration
public static void FirePropertyChanged(this object source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | source | |
System.String | propertyName |
FirePropertyChanged(Object, String, Object, Object)
If source
is INotifyPropertyChangedInvoker then invokes InvokePropertyChanged which fires per-instance property changes. Anyway fires global property change events.
Declaration
public static void FirePropertyChanged(this object source, string propertyName, object before, object after)
Parameters
Type | Name | Description |
---|---|---|
System.Object | source | |
System.String | propertyName | |
System.Object | before | |
System.Object | after |
GlobalSubscribe(Type, PropertyChangedBeforeAfterEventHandler)
Subscribes for all notified properties changes on all instances of type
.
Declaration
public static void GlobalSubscribe(Type type, PropertyChangedBeforeAfterEventHandler action)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
PropertyChangedBeforeAfterEventHandler | action |
GlobalSubscribe(Type, String, PropertyChangedBeforeAfterEventHandler)
Subscribes for propertyName
changes on all instances of type
.
Declaration
public static void GlobalSubscribe(Type type, string propertyName, PropertyChangedBeforeAfterEventHandler action)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
System.String | propertyName | |
PropertyChangedBeforeAfterEventHandler | action |
GlobalUnsubscribe(Type, PropertyChangedBeforeAfterEventHandler)
Unsubscribes from all notified properties changes on all instances of type
.
Declaration
public static void GlobalUnsubscribe(Type type, PropertyChangedBeforeAfterEventHandler action)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
PropertyChangedBeforeAfterEventHandler | action |
GlobalUnsubscribe(Type, String, PropertyChangedBeforeAfterEventHandler)
Unsubscribes from propertyName
changes on all instances of type
.
Declaration
public static void GlobalUnsubscribe(Type type, string propertyName, PropertyChangedBeforeAfterEventHandler action)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
System.String | propertyName | |
PropertyChangedBeforeAfterEventHandler | action |
IsNotifyingProperty(PropertyInfo)
Return true if the property has an attribute that will make it notify through fody.
Declaration
public static bool IsNotifyingProperty(this PropertyInfo prop)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.PropertyInfo | prop |
Returns
Type | Description |
---|---|
System.Boolean |