1
//
2
3
4
using System;
5
using System.Collections.Generic;
6
using System.Runtime.Serialization;
7
8
namespace SharpLib.Ear
9
{
10
[DataContract]
11
public abstract class Event : Object
12
13
[DataMember]
14
[AttributeObjectProperty
15
(
16
Id = "Event.Enabled",
17
Name = "Enabled",
18
Description = "When enabled an event instance can be triggered."
19
)
20
]
21
public bool Enabled { get; set; }
22
23
24
public List<Action> Actions = new List<Action>();
25
26
27
28
protected Event()
29
30
Enabled = true;
31
}
32
33
34
/// <summary>
35
/// Allows testing from generic edit dialog.
36
/// </summary>
37
public void Test()
38
39
Console.WriteLine("Event test");
40
Trigger();
41
42
43
44
public void Trigger()
45
46
Console.WriteLine("Event triggered: " + Name);
47
foreach (Action action in Actions)
48
49
action.Execute();
50
51
52
53
54
public override bool Equals(object obj)
55
56
//Default implementation assumes event are the same if types are the same
57
bool res= obj.GetType() == GetType();
58
return res;
59
60
};
61
62