Notify (keyword)
From The Oxygene Language Wiki
(Redirected from Property Notifications)
This is a Language topic about Oxygene
Language Topics Introduction | Structured Overview | Grammar | Keywords | Functions
Property Notification
When notify is used on properties, the class will implicitly implement the System.ComponentModel.INotifyPropertyChanged and System.ComponentModel.INotifyPropertyChanging interface (if available, when linking against .NET 3.5, otherwise it will not be exposed) and invoke the event defined in that interface when the property itself is modified.
By default, it will pass the name of the property as defined in the class, however, notify supports a string parameter to change the name of the property passed to the event.
Defining
type ValueClass = class public property Value: Integer; notify; property Name: string; notify 'ValueName'; end;
Using
var v: ValueClass; v.PropertyChanged += method (sender: Object; args: PropertyChangedEventArgs) begin MessageBox.Show(String.Format('Someone changed the {0} property', args.PropertyName)); end;
Compatibility Remarks
- If you have .NET 2.0 SP1 on your machine, Oxygene will use INotifyPropertyChanging as well
This can cause problems on target machines that do not have SP1 for .Net 2.0 installed.
In those cases, having a VM with just .NET 2.0 and the Oxygene compiler would be a workaround to ensure that your app does not need SP1.