| patterns/observer/template-with-events/subject-only.cs - Template of the Subject class. | Lecture 5 - slide 44 : 45 Program 1 |
using System.Collections;
namespace Templates.Observer {
public delegate void Notification(SubjectState ss);
public class Subject {
// Subject instance variable
private event Notification observerNotifier;
public void AddNotifier(Notification n){
observerNotifier += n;
}
public void RemoveNotifier(Notification n){
observerNotifier -= n;
}
public void Notify(){
observerNotifier(new SubjectState());
}
}
public class SubjectState {
// Selected state of the subject
}
}