SharpLibEar/Action.cs
author Stephane Lenclud
Sun, 24 Jul 2016 13:30:08 +0200
changeset 212 1a0791daa243
parent 211 96f8b4dc4300
child 220 e5910d7b6a81
permissions -rw-r--r--
Actions persistence working.
     1 //
     2 
     3 
     4 using System;
     5 using System.Collections.Generic;
     6 using System.Runtime.Serialization;
     7 using System.Threading;
     8 
     9 namespace SharpLib.Ear
    10 {
    11     [DataContract]
    12     [KnownType("DerivedTypes")]
    13     public abstract class Action: IComparable
    14     {
    15         public abstract void Execute();
    16 
    17         public string Name {
    18             //Get the name of this object action attribute
    19             get { return Utils.Reflection.GetAttribute<AttributeAction>(GetType()).Name; }
    20             private set { }
    21         }
    22 
    23         public int CompareTo(object obj)
    24         {
    25             //Sort by action name
    26             return Utils.Reflection.GetAttribute<AttributeAction>(GetType()).Name.CompareTo(obj.GetType());            
    27         }
    28 
    29         private static IEnumerable<Type> DerivedTypes()
    30         {
    31             return SharpLib.Utils.Reflection.GetDerivedTypes<Action>();
    32         }
    33 
    34     }
    35 
    36 
    37 }