jeudi 19 août 2021

INotifyPropertyChanged best practices: How do you specify which properties notify?

Firstly, if I have a class that implements INotifyPropertyChanged, what is the best way to communicate which properties do, or do not notify when changed? Or should the pattern be that every public property with a getter in a class that implements INotifyPropertyChanged, should notify?

In my case I'm actually creating an interface, with a bunch of properties, that I've made dependent on INotifyPropertyChanged as I want to communicate that implementations of the interface notify when some of the properties change.

Is a comment in the summary block of each property the best way to communicate this? or maybe an attribute?

eg:

interface IMachine: INotifyPropertyChanged 
{
     Color StatusLED {get;} // does notify when value changes
     bool Busy {get;} // does NOT notify when value changes (because doing so would be too hard, so needs to be polled or whatever.
}

Aucun commentaire:

Enregistrer un commentaire