SharpLibEar/Action.cs
author StephaneLenclud
Thu, 25 Aug 2016 13:34:05 +0200
changeset 255 c57b8ac80fc6
parent 239 dd7770b97916
child 258 e237c2e33545
permissions -rw-r--r--
Published v1.0.2.0.
Fixed Harmony async issue prevent the config to be fetched.
     1 //
     2 
     3 
     4 using System;
     5 using System.Collections.Generic;
     6 using System.Diagnostics;
     7 using System.Runtime.Serialization;
     8 using System.Threading;
     9 
    10 namespace SharpLib.Ear
    11 {
    12     [DataContract]
    13     public abstract class Action: Object
    14     {
    15         protected abstract void DoExecute();
    16 
    17         /// <summary>
    18         /// Allows testing from generic edit dialog.
    19         /// </summary>
    20         public void Test()
    21         {
    22             Trace.WriteLine("Action test");
    23             Execute();
    24         }
    25 
    26         public void Execute()
    27         {
    28             Trace.WriteLine("Action executing: " + Brief());
    29             if (!IsValid())
    30             {
    31                 Trace.WriteLine($"WARNING: action invalid, aborting execution.");
    32                 return;
    33             }
    34             
    35             DoExecute();
    36         }
    37 
    38     }
    39 
    40 
    41 }