SharpLibEar/Action.cs
author StephaneLenclud
Thu, 18 Aug 2016 18:49:03 +0200
changeset 241 3b5a94f31400
parent 238 c92587ddabcd
child 253 2dae7a163fff
permissions -rw-r--r--
Adding support for HID Keyboard events.
     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     public abstract class Action: Object
    13     {
    14         protected abstract void DoExecute();
    15 
    16         /// <summary>
    17         /// Allows testing from generic edit dialog.
    18         /// </summary>
    19         public void Test()
    20         {
    21             Console.WriteLine("Action test");
    22             Execute();
    23         }
    24 
    25         public void Execute()
    26         {
    27             Console.WriteLine("Action executing: " + Brief());
    28             if (!IsValid())
    29             {
    30                 Console.WriteLine($"WARNING: action invalid, aborting execution.");
    31                 return;
    32             }
    33             
    34             DoExecute();
    35         }
    36 
    37     }
    38 
    39 
    40 }