-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.cs
66 lines (57 loc) · 2.13 KB
/
Log.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
namespace ru.mofrison.GlobalEvent
{
public class Log
{
/// <summary>
/// Base class for log messages
/// </summary>
public class Message : GlobalEvent<Message>
{
public string Text { get; }
/// <summary>
/// Base class constructor
/// </summary>
/// <param name="text">Message text</param>
protected Message(string text) => Text = text;
/// <summary>
/// The method required to send the global event
/// </summary>
/// <param name="text">Message text</param>
public static void Send(string text) => Handle(new Message(text));
}
/// <summary>
/// A more complex example of global event implementation. Adds only unique methods as delegates.
/// </summary>
public sealed class Warning : GlobalEvent<Warning>
{
public string Text { get; }
/// <summary>
/// Class constructor
/// </summary>
/// <param name="text">Message text</param>
private Warning(string text) => Text = text;
/// <summary>
/// The method required to send the global event
/// </summary>
/// <param name="text">Warning message text</param>
public static void Send(string text) => Handle(new Warning(text));
}
/// <summary>
/// A more complex example of global event implementation. Adds only unique methods as delegates.
/// </summary>
public sealed class Error : GlobalEvent<Error>
{
public string Text { get; }
/// <summary>
/// Class constructor
/// </summary>
/// <param name="text">Message text</param>
private Error(string text) => Text = text;
/// <summary>
/// The method required to send the global event
/// </summary>
/// <param name="text">Error message text</param>
public static void Send(string text) => Handle(new Error(text));
}
}
}