StephaneLenclud@210: // StephaneLenclud@210: StephaneLenclud@210: StephaneLenclud@210: using System; StephaneLenclud@210: using System.Collections.Generic; StephaneLenclud@210: using System.Runtime.Serialization; StephaneLenclud@210: StephaneLenclud@210: namespace SharpLib.Ear StephaneLenclud@210: { StephaneLenclud@210: [DataContract] StephaneLenclud@238: public abstract class Event : Object StephaneLenclud@210: { StephaneLenclud@231: [DataMember] StephaneLenclud@231: [AttributeObjectProperty StephaneLenclud@231: ( StephaneLenclud@231: Id = "Event.Enabled", StephaneLenclud@231: Name = "Enabled", StephaneLenclud@231: Description = "When enabled an event instance can be triggered." StephaneLenclud@231: ) StephaneLenclud@231: ] StephaneLenclud@231: public bool Enabled { get; set; } StephaneLenclud@210: Stephane@212: [DataMember] Stephane@212: public List Actions = new List(); StephaneLenclud@210: StephaneLenclud@231: StephaneLenclud@231: StephaneLenclud@210: protected Event() StephaneLenclud@210: { StephaneLenclud@231: Enabled = true; StephaneLenclud@210: } StephaneLenclud@210: StephaneLenclud@231: StephaneLenclud@231: /// StephaneLenclud@231: /// Allows testing from generic edit dialog. StephaneLenclud@231: /// StephaneLenclud@231: public void Test() StephaneLenclud@231: { StephaneLenclud@231: Console.WriteLine("Event test"); StephaneLenclud@231: Trigger(); StephaneLenclud@231: } StephaneLenclud@231: StephaneLenclud@231: StephaneLenclud@231: public void Trigger() StephaneLenclud@210: { StephaneLenclud@229: Console.WriteLine("Event triggered: " + Name); StephaneLenclud@210: foreach (Action action in Actions) StephaneLenclud@210: { StephaneLenclud@210: action.Execute(); StephaneLenclud@210: } StephaneLenclud@210: } StephaneLenclud@231: StephaneLenclud@237: // StephaneLenclud@237: public override bool Equals(object obj) StephaneLenclud@237: { StephaneLenclud@237: //Default implementation assumes event are the same if types are the same StephaneLenclud@237: bool res= obj.GetType() == GetType(); StephaneLenclud@237: return res; StephaneLenclud@237: } StephaneLenclud@231: }; StephaneLenclud@210: StephaneLenclud@210: }