SharpLibEar/Action.cs
author StephaneLenclud
Thu, 25 Aug 2016 00:42:09 +0200
changeset 253 2dae7a163fff
parent 239 dd7770b97916
child 258 e237c2e33545
permissions -rw-r--r--
Published v1.0.0.0
Updating Harmony library to v0.4.0 for keep alive support.
Improved logs mechanism.
     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 }