Adding Delay action to replace our Sleep action.
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;
28 /// TODO: Should the name property be moved to our EAR Object?
31 [AttributeObjectProperty
35 Description = "Given event name. Can be used to trigger it."
38 public string Name { get; set; } = "";
42 public List<Action> Actions = new List<Action>();
45 protected override void DoConstruct()
49 //Make sure our name is not null
55 // TODO: Construct properties too
56 foreach (Action a in Actions)
65 /// Allows testing from generic edit dialog.
67 public async void Test()
69 Trace.WriteLine("Event test");
74 public async Task Trigger()
76 Trace.WriteLine("Event triggered: " + AttributeName);
77 foreach (Action action in Actions)
79 await action.Execute();
84 public override bool Equals(object obj)
86 //Default implementation assumes event are the same if types are the same
87 bool res= obj.GetType() == GetType();