Class NotificationBinder
- Namespace
- Nucs.JsonSettings.Autosave
- Assembly
- Nucs.JsonSettings.Autosave.dll
Takes care of binding nested objects that implement INotifyCollectionChanged and/or INotifyPropertyChanged.
[Serializable]
public class NotificationBinder : IDisposable
- Inheritance
-
NotificationBinder
- Implements
- Inherited Members
Remarks
Attached by EnableAutosave() to any settings instance that itself implements
INotifyPropertyChanged -- the NotifiyingJsonSettings base, a
[NotifyChangesMixin]-woven class (whose interface exists only after the weave), or
a hand-written implementation. Keying on the interface rather than on the notifying
base class is what lets mixin classes participate: their ObservableCollection
properties save on in-place Add/Remove like any other notifier's.
Constructors
NotificationBinder(JsonSettings)
public NotificationBinder(JsonSettings settings)
Parameters
settingsJsonSettings
NotificationBinder(NotifiyingJsonSettings)
Kept for source and binary compatibility with older callers; the notifying base is just one of the shapes the JsonSettings overload accepts.
public NotificationBinder(NotifiyingJsonSettings settings)
Parameters
settingsNotifiyingJsonSettings
Methods
CanHandleProperty(string)
public bool CanHandleProperty(string propName)
Parameters
propNamestring
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Resync()
Re-reads every monitored property and rebinds the ones whose value was replaced.
public void Resync()
Remarks
Runs on the settings' AfterRepopulate event (subscribed in the constructor) after every populate: collection properties deserialize with Replace semantics, and the replace the deserializer performs only reaches OnPropertyChanged(object, PropertyChangedEventArgs) when the class raises PropertyChanged from its setters. A plain [Autosave] class on the notifying base without the [NotifyChanges] aspect raises nothing during a populate and would otherwise be left subscribed to collections the settings object no longer holds -- every in-place edit after a Load() silently unpersisted. Must not save: it runs inside the load pipeline (the event fires from a finally, so also while a failed populate unwinds), where a save would commit a half-loaded object.