diff -r 8c5cf2228e9a -r 4c706feaf706 SharpLibEar/Event.cs --- a/SharpLibEar/Event.cs Sun Jul 31 12:03:52 2016 +0200 +++ b/SharpLibEar/Event.cs Fri Aug 12 20:25:05 2016 +0200 @@ -8,26 +8,54 @@ namespace SharpLib.Ear { [DataContract] - public abstract class MEvent + [KnownType("DerivedTypes")] + public abstract class Event { - public string Name { get; protected set; } - public string Description { get; protected set; } + [DataMember] + [AttributeObjectProperty + ( + Id = "Event.Enabled", + Name = "Enabled", + Description = "When enabled an event instance can be triggered." + ) + ] + public bool Enabled { get; set; } - public abstract void Trigger(); - }; - - [DataContract] - public abstract class Event : MEvent - { [DataMember] public List Actions = new List(); + public string Name + { + //Get the name of this object attribute + get { return Utils.Reflection.GetAttribute(GetType()).Name; } + private set { } + } + + public string Description + { + //Get the description of this object attribute + get { return Utils.Reflection.GetAttribute(GetType()).Description; } + private set { } + } + + protected Event() { - + Enabled = true; } - public override void Trigger() + + /// + /// Allows testing from generic edit dialog. + /// + public void Test() + { + Console.WriteLine("Event test"); + Trigger(); + } + + + public void Trigger() { Console.WriteLine("Event triggered: " + Name); foreach (Action action in Actions) @@ -35,6 +63,15 @@ action.Execute(); } } - } + + /// + /// So that data contract knows all our types. + /// + /// + private static IEnumerable DerivedTypes() + { + return SharpLib.Utils.Reflection.GetDerivedTypes(); + } + }; } \ No newline at end of file