20using System.Collections.Generic;
110 private List<IObserverNumberChanged>
_observers =
new List<IObserverNumberChanged>();
Represents the Subject in this example, in this case, a class that contains a single number that is u...
List< IObserverNumberChanged > _observers
The list of observers subscribed to this class instance.
uint _number
The number being maintained.
void _NotifyNumberChanged()
Helper method to notify all observers that the number has changed.
void Update()
Update the number then notify all observers.
Represents a Subject that takes observers implementing the IObserverNumberChanged interface.
void SubscribeToNumberChanged(IObserverNumberChanged observer)
void UnsubscribeFromNumberChanged(IObserverNumberChanged observer)
Represents the Subject to the observers. This is the minimum needed by observers to get access to the...
uint FetchNumber()
Return the current value from the Subject.
Represents an observer to the Subject class. An observer implements this interface and then subscribe...
void NumberChanged()
This is called whenever the number in the ObserverSubject_NumberProducer object is changed.
The namespace containing all Design Pattern Examples implemented in C#.