SharpLibEar/Action.cs
author StephaneLenclud
Tue, 26 Jul 2016 15:05:57 +0200
changeset 220 e5910d7b6a81
parent 212 1a0791daa243
child 223 f6272f65d8fc
permissions -rw-r--r--
Adding support for enumerated action property edition.
     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 virtual string Brief()
    24         {
    25             return Name;
    26         }
    27 
    28         public int CompareTo(object obj)
    29         {
    30             //Sort by action name
    31             return Utils.Reflection.GetAttribute<AttributeAction>(GetType()).Name.CompareTo(obj.GetType());            
    32         }
    33 
    34         private static IEnumerable<Type> DerivedTypes()
    35         {
    36             return SharpLib.Utils.Reflection.GetDerivedTypes<Action>();
    37         }
    38 
    39     }
    40 
    41 
    42 }