StephaneLenclud@210: // StephaneLenclud@210: StephaneLenclud@210: StephaneLenclud@210: using System; Stephane@212: using System.Collections.Generic; StephaneLenclud@210: using System.Runtime.Serialization; StephaneLenclud@210: using System.Threading; StephaneLenclud@210: StephaneLenclud@210: namespace SharpLib.Ear StephaneLenclud@210: { StephaneLenclud@210: [DataContract] StephaneLenclud@238: public abstract class Action: Object StephaneLenclud@210: { StephaneLenclud@228: protected abstract void DoExecute(); StephaneLenclud@223: StephaneLenclud@231: /// StephaneLenclud@231: /// Allows testing from generic edit dialog. StephaneLenclud@231: /// StephaneLenclud@231: public void Test() StephaneLenclud@231: { StephaneLenclud@231: Console.WriteLine("Action test"); StephaneLenclud@231: Execute(); StephaneLenclud@231: } StephaneLenclud@231: StephaneLenclud@223: public void Execute() StephaneLenclud@223: { StephaneLenclud@229: Console.WriteLine("Action executing: " + Brief()); StephaneLenclud@239: if (!IsValid()) StephaneLenclud@239: { StephaneLenclud@239: Console.WriteLine($"WARNING: action invalid, aborting execution."); StephaneLenclud@239: return; StephaneLenclud@239: } StephaneLenclud@239: StephaneLenclud@223: DoExecute(); StephaneLenclud@223: } StephaneLenclud@210: StephaneLenclud@210: } StephaneLenclud@210: StephaneLenclud@210: StephaneLenclud@210: }