32 if (numberProducer ==
null)
34 throw new ArgumentNullException(
"numberProducer",
"The ObserverForDecimal constructor requires a valid INumberProducer object.");
51 Console.WriteLine(
" Decimal : {0}", number);
78 if (numberProducer ==
null)
80 throw new ArgumentNullException(
"numberProducer",
"The ObserverForHexaDecimal constructor requires a valid INumberProducer object.");
98 Console.WriteLine(
" Hexadecimal: 0x{0:X8}", number);
125 if (numberProducer ==
null)
127 throw new ArgumentNullException(
"numberProducer",
"The ObserverForBinary constructor requires a valid INumberProducer object.");
146 StringBuilder output =
new StringBuilder();
147 uint mask = (uint)1 << 31;
149 for (uint index = 0; index < 32; ++index)
151 if ((number & mask) != 0)
162 Console.WriteLine(
" Binary : {0}", output);
Represents an observer that prints out the current number from the Subject in binary.
ObserverForBinary(INumberProducer numberProducer)
Constructor.
INumberProducer _numberProducer
The number producer from which to get the current number.
Represents an observer that prints out the current number from the Subject in decimal.
ObserverForDecimal(INumberProducer numberProducer)
Constructor.
INumberProducer _numberProducer
The number producer from which to get the current number.
Represents an observer that prints out the current number from the Subject in hexadecimal.
ObserverForHexaDecimal(INumberProducer numberProducer)
Constructor.
INumberProducer _numberProducer
The number producer from which to get the current number.
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#.