Class WatchSubMemberAttribute
When put on a property, will create subscriptions watching a given sub-property to change, and trigger the corresponding method or event.
Inherited Members
Namespace: Eco.Core.PropertyHandling
Assembly: Eco.Core.dll
Syntax
public class WatchSubMemberAttribute : WatchBaseAttribute
Remarks
Declaring class must implement INotifyPropertyChanged, so that it can watch when the prop changes. Declaring class must also implement ISubscriptions, allowing this service to property track subscriptions when they are made and remove them upon destroy.
Constructors
WatchSubMemberAttribute(Boolean, String)
Declaration
public WatchSubMemberAttribute(bool watchAllSubProps, string callback)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | watchAllSubProps | |
System.String | callback |
WatchSubMemberAttribute(String, String, SubPropWatcherFlag)
Whenever the given sub property is changed/triggered, call the given callback.
Declaration
public WatchSubMemberAttribute(string subPropName, string callback, SubPropWatcherFlag flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | subPropName | |
System.String | callback | |
SubPropWatcherFlag | flags |
WatchSubMemberAttribute(String, String, Type, SubPropWatcherFlag)
Declaration
public WatchSubMemberAttribute(string subPropName, string callback, Type memberTypeMustDerive, SubPropWatcherFlag flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | subPropName | |
System.String | callback | |
System.Type | memberTypeMustDerive | |
SubPropWatcherFlag | flags |
WatchSubMemberAttribute(Type, String, String, SubPropWatcherFlag)
Declaration
public WatchSubMemberAttribute(Type rootType, string subPropName, string callback, SubPropWatcherFlag flags)
Parameters
Type | Name | Description |
---|---|---|
System.Type | rootType | |
System.String | subPropName | |
System.String | callback | |
SubPropWatcherFlag | flags |
Fields
Callback
The name of the method on 'this' that we want to call. Can be either an event or a method.
Declaration
public readonly string Callback
Field Value
Type | Description |
---|---|
System.String |
Flags
Flags customizing behavior of this attribute.
Declaration
public readonly SubPropWatcherFlag Flags
Field Value
Type | Description |
---|---|
SubPropWatcherFlag |
Properties
DontTriggerWhenRootPropSetToNull
When true callback won't be called when root property is set to null.
Declaration
public bool DontTriggerWhenRootPropSetToNull { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This flag can only be used when callback expects to receive new value of sub property as parameter and sub proeprty is of value type (so null can't be passed) and is mandatory in such cases to explicitly show that different behavior for value types will be used.
Methods
GetCallback(MemberInfo, out Type)
Returns callback delegate based on the value of Callback field.
Declaration
public override PropertyChangedBeforeAfterEventHandler GetCallback(MemberInfo memberWithAttribute, out Type expectedCallbackParam)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MemberInfo | memberWithAttribute | Member to which this attribute is applied. |
System.Type | expectedCallbackParam | Type of expected callback parameter if any. |
Returns
Type | Description |
---|---|
PropertyChangedBeforeAfterEventHandler |