-
Notifications
You must be signed in to change notification settings - Fork 7
Home
mik3c edited this page May 29, 2016
·
16 revisions
Using MIST from Nuget.org
- Install MIST build components (available from nuget.org) in the project containing classes for which you would like notification to be automatically implemented.
Install-Package Mathtone.MIST
- If you unload and Edit the project file, it should contain a build task similar to the following:The location of the Mathtone.MIST.Builder assembly is the default and can be changed by modifying your local Nuget.config file (If you install MIST via the nuget package, this should be handled for you).
<UsingTask TaskName="Mathtone.MIST.NotificationWeaverBuildTask" AssemblyFile="$(ProjectDir)..\packages\Mathtone.MIST.1.0.1\tools\Mathtone.MIST.Builder.dll" /> <Target Name="AfterBuild"> <NotificationWeaverBuildTask TargetPath="$(TargetPath)" DebugMode="True" /> </Target>
Apply notification attributes
- Use the "NotifierAttribute", "NotifyAttribute" and "NotifyTargetAttributte"
Typical usage scenario:
public class NotifierBase : INotifyPropertyChanged {
[NotifyTarget]
protected void RaisePropertyChanged(string propertyName) {
var method = PropertyChanged;
if (method != null) {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
[Notifier(NotificationMode.Implicit)]
public class ImplicitTestNotifier : NotifierBase {
public string Property1 { get; set; }
public string Property2 { get; set; }
public string Property3 { get; set; }
[SupressNotify]
public string Supressed { get; set; }
[Notify("Prop1And2", "Property1", "Property2")]
public string Prop1And2 { get; set; }
}
[Notifier]
public class ExplicitTestNotifier : NotifierBase {
[Notify]
public string Property1 { get; set; }
[Notify]
public string Property2 { get; set; }
[Notify]
public string Property3 { get; set; }
public string Supressed { get; set; }
[Notify("Prop1And2", "Property1", "Property2")]
public string Prop1And2 { get; set; }
}
If it's all wired up correctly, you should see a message in the build output window: "Lightly Misting: <your project output>" at build time. Happy coding!