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.
StephaneLenclud@210
     1
//
StephaneLenclud@210
     2
StephaneLenclud@210
     3
StephaneLenclud@210
     4
using System;
Stephane@212
     5
using System.Collections.Generic;
StephaneLenclud@253
     6
using System.Diagnostics;
StephaneLenclud@210
     7
using System.Runtime.Serialization;
StephaneLenclud@210
     8
using System.Threading;
StephaneLenclud@210
     9
StephaneLenclud@210
    10
namespace SharpLib.Ear
StephaneLenclud@210
    11
{
StephaneLenclud@210
    12
    [DataContract]
StephaneLenclud@238
    13
    public abstract class Action: Object
StephaneLenclud@210
    14
    {
StephaneLenclud@228
    15
        protected abstract void DoExecute();
StephaneLenclud@223
    16
StephaneLenclud@231
    17
        /// <summary>
StephaneLenclud@231
    18
        /// Allows testing from generic edit dialog.
StephaneLenclud@231
    19
        /// </summary>
StephaneLenclud@231
    20
        public void Test()
StephaneLenclud@231
    21
        {
StephaneLenclud@253
    22
            Trace.WriteLine("Action test");
StephaneLenclud@231
    23
            Execute();
StephaneLenclud@231
    24
        }
StephaneLenclud@231
    25
StephaneLenclud@223
    26
        public void Execute()
StephaneLenclud@223
    27
        {
StephaneLenclud@253
    28
            Trace.WriteLine("Action executing: " + Brief());
StephaneLenclud@239
    29
            if (!IsValid())
StephaneLenclud@239
    30
            {
StephaneLenclud@253
    31
                Trace.WriteLine($"WARNING: action invalid, aborting execution.");
StephaneLenclud@239
    32
                return;
StephaneLenclud@239
    33
            }
StephaneLenclud@239
    34
            
StephaneLenclud@223
    35
            DoExecute();
StephaneLenclud@223
    36
        }
StephaneLenclud@210
    37
StephaneLenclud@210
    38
    }
StephaneLenclud@210
    39
StephaneLenclud@210
    40
StephaneLenclud@210
    41
}