-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (40 loc) · 1.49 KB
/
Program.cs
File metadata and controls
49 lines (40 loc) · 1.49 KB
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
39
40
41
42
43
44
45
46
47
48
49
using System;
namespace ObserverPattern2
{
public class CurrencyUnknownException : Exception
{
internal CurrencyUnknownException() { }
}
class Program
{
public static EuroCurrency[] Week = new EuroCurrency[]
{
new EuroCurrency(92.29m, Convert.ToDateTime("22.04.2021")),
new EuroCurrency(92.04m, Convert.ToDateTime("23.04.2021")),
new EuroCurrency(90.46m, Convert.ToDateTime("24.04.2021")),
new EuroCurrency(90.44m, Convert.ToDateTime("27.04.2021")),
null,
new EuroCurrency(90.46m, Convert.ToDateTime("28.04.2021")),
new EuroCurrency(90.42m, Convert.ToDateTime("29.04.2021")),
new EuroCurrency(90.15m, Convert.ToDateTime("30.04.2021")),
};
static void Main(string[] args)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
// provider
EuroCurrencyStock stock = new EuroCurrencyStock();
// subscribers
EuroObserver observer1 = new EuroObserver();
stock.Subscribe(observer1);
foreach (var currency in Week)
{
System.Threading.Thread.Sleep(1500);
if (currency == null)
observer1.OnError(new CurrencyUnknownException());
else
observer1.OnNext(currency);
}
observer1.OnCompleted();
}
}
}