C# Class Catel.Data.ChangeNotificationWrapper

Wrapper for an object that implements the INotifyPropertyChanged and INotifyCollectionChanged. This class is thread-safe and uses weak events to prevent memory leaks.
Show file Open project: Catel/Catel Class Usage Examples

Public Methods

Method Description
ChangeNotificationWrapper ( object value ) : System

Initializes a new instance of the ChangeNotificationWrapper class.

IsUsefulForObject ( object obj ) : bool

Determines whether creating a ChangeNotificationWrapper is useful for the specified object. An object is considered usable when it implements either INotifyPropertyChanged or INotifyCollectionChanged.

OnObjectCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void

Called when the target object raises the INotifyCollectionChanged.CollectionChanged event.

This method is public to allow the usage of the WeakEventListener, do not call this method yourself.

OnObjectCollectionItemPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when the target object raises the INotifyPropertyChanged.PropertyChanged event of an object that is located inside the collection being monitored.

This method is public to allow the usage of the WeakEventListener, do not call this method yourself.

OnObjectPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when the target object raises the INotifyPropertyChanged.PropertyChanged event.

This method is public to allow the usage of the WeakEventListener, do not call this method yourself.

SubscribeNotifyChangedEvents ( object value, ICollection parentCollection ) : void

Subscribes to the notify changed events.

UnsubscribeFromAllEvents ( ) : void

Unsubscribes from all events.

UnsubscribeNotifyChangedEvents ( object value, ICollection parentCollection ) : void

Unsubscribes from the notify changed events.

No need to check for weak events, they are unsubscribed automatically.

UpdateCollectionSubscriptions ( ICollection collection ) : void

Updates all the collection subscriptions. This method is internally used when a notifiable collection raises the NotifyCollectionChangedAction.Reset event.

Private Methods

Method Description
SubscribeNotifyChangedEvent ( object value, EventChangeType eventChangeType, ICollection parentCollection ) : void
UnsubscribeNotifyChangedEvent ( object value, EventChangeType eventChangeType, ICollection parentCollection ) : void

Method Details

ChangeNotificationWrapper() public method

Initializes a new instance of the ChangeNotificationWrapper class.
The is null or whitespace.
public ChangeNotificationWrapper ( object value ) : System
value object The value.
return System

IsUsefulForObject() public static method

Determines whether creating a ChangeNotificationWrapper is useful for the specified object. An object is considered usable when it implements either INotifyPropertyChanged or INotifyCollectionChanged.
public static IsUsefulForObject ( object obj ) : bool
obj object The object to check.
return bool

OnObjectCollectionChanged() public method

Called when the target object raises the INotifyCollectionChanged.CollectionChanged event.
This method is public to allow the usage of the WeakEventListener, do not call this method yourself.
public OnObjectCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void
sender object The sender.
e System.Collections.Specialized.NotifyCollectionChangedEventArgs The instance containing the event data.
return void

OnObjectCollectionItemPropertyChanged() public method

Called when the target object raises the INotifyPropertyChanged.PropertyChanged event of an object that is located inside the collection being monitored.
This method is public to allow the usage of the WeakEventListener, do not call this method yourself.
public OnObjectCollectionItemPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
return void

OnObjectPropertyChanged() public method

Called when the target object raises the INotifyPropertyChanged.PropertyChanged event.
This method is public to allow the usage of the WeakEventListener, do not call this method yourself.
public OnObjectPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
return void

SubscribeNotifyChangedEvents() public method

Subscribes to the notify changed events.
public SubscribeNotifyChangedEvents ( object value, ICollection parentCollection ) : void
value object The object to subscribe to.
parentCollection ICollection If not null, this is a collection item which should use .
return void

UnsubscribeFromAllEvents() public method

Unsubscribes from all events.
public UnsubscribeFromAllEvents ( ) : void
return void

UnsubscribeNotifyChangedEvents() public method

Unsubscribes from the notify changed events.
No need to check for weak events, they are unsubscribed automatically.
public UnsubscribeNotifyChangedEvents ( object value, ICollection parentCollection ) : void
value object The object to unsubscribe from.
parentCollection ICollection The parent collection.
return void

UpdateCollectionSubscriptions() public method

Updates all the collection subscriptions. This method is internally used when a notifiable collection raises the NotifyCollectionChangedAction.Reset event.
public UpdateCollectionSubscriptions ( ICollection collection ) : void
collection ICollection
return void