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
protected abstract void DoExecute();
16
17
public void Execute()
18
19
Console.WriteLine("Action executing: " + Brief());
20
DoExecute();
21
}
22
23
public string Name {
24
//Get the name of this object action attribute
25
get { return Utils.Reflection.GetAttribute<AttributeAction>(GetType()).Name; }
26
private set { }
27
28
29
public virtual string Brief()
30
31
return Name;
32
33
34
public int CompareTo(object obj)
35
36
//Sort by action name
37
return Utils.Reflection.GetAttribute<AttributeAction>(GetType()).Name.CompareTo(obj.GetType());
38
39
40
private static IEnumerable<Type> DerivedTypes()
41
42
return SharpLib.Utils.Reflection.GetDerivedTypes<Action>();
43
44
45
46
47
48