-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathBoss.cs
More file actions
38 lines (30 loc) · 680 Bytes
/
Boss.cs
File metadata and controls
38 lines (30 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace ObserverPattern;
internal class Boss : ISubject
{
private readonly IList<Observer> _observers = new List<Observer>();
public void Attach(Observer observer)
{
_observers.Add(observer);
}
public void Detach(Observer observer)
{
_observers.Remove(observer);
}
public void Notify()
{
foreach (var observer in _observers)
{
observer.Update();
}
}
public string SubjectState { get; set; }
}
internal class NewBoss : ISubject
{
public event Action Update;
public void Notify()
{
Update?.Invoke();
}
public string SubjectState { get; set; }
}