5 using System.Collections.Generic;
6 using System.Diagnostics;
7 using System.Runtime.Serialization;
8 using System.Threading.Tasks;
10 namespace SharpLib.Ear
13 [AttributeObject(Id = "Event", Name = "User Event", Description = "An event that can be triggered by users.")]
14 public class Event : Object
17 [AttributeObjectProperty
21 Description = "When enabled an event instance can be triggered."
24 public bool Enabled { get; set; } = true;
27 [AttributeObjectProperty
31 Description = "Given event name. Can be used to trigger it."
34 public string Name { get; set; } = "";
37 public List<Action> Actions = new List<Action>();
40 protected override void DoConstruct()
44 // TODO: Construct properties too
45 foreach (Action a in Actions)
54 /// Allows testing from generic edit dialog.
56 public async void Test()
58 Trace.WriteLine("Event test");
63 public async Task Trigger()
65 Trace.WriteLine("Event triggered: " + AttributeName);
66 foreach (Action action in Actions)
68 await action.Execute();
73 public override bool Equals(object obj)
75 //Default implementation assumes event are the same if types are the same
76 bool res= obj.GetType() == GetType();