1
2
3
4
5
6 using System;
7 using System.Collections;
8 using System.Windows.API;
9 using System.Concepts;
10
11 namespace System.Windows
12 {
13 public class EmptyEventArgs
14 {
15 }
16
17 public class Event<Handler, Args = EmptyEventArgs>
18 {
19 public nothrow void AddHandler(Handler handler)
20 {
21 if (Find(handlers.CBegin(), handlers.CEnd(), handler) == handlers.CEnd())
22 {
23 handlers.Add(handler);
24 }
25 }
26 public nothrow void RemoveHandler(Handler handler)
27 {
28 handlers.Remove(handler);
29 }
30 public nothrow const List<Handler>& Handlers() const
31 {
32 return handlers;
33 }
34 public void Fire() where Args is EmptyEventArgs
35 {
36 for (Handler handler : handlers)
37 {
38 handler();
39 }
40 }
41 public void Fire(Args& args)
42 {
43 for (Handler handler : handlers)
44 {
45 handler(args);
46 }
47 }
48 private List<Handler> handlers;
49 }
50 }