SharpLibEar/ActionCallback.cs
author StephaneLenclud
Sun, 21 Aug 2016 16:30:58 +0200
changeset 248 0220cb84df58
parent 223 f6272f65d8fc
child 258 e237c2e33545
permissions -rw-r--r--
Fixing EAR event edition.
EAR HID event now displays 'Press a key' if not valid.
StephaneLenclud@210
     1
//
StephaneLenclud@210
     2
StephaneLenclud@210
     3
using System.Runtime.Serialization;
StephaneLenclud@210
     4
StephaneLenclud@210
     5
StephaneLenclud@210
     6
namespace SharpLib.Ear
StephaneLenclud@210
     7
{
StephaneLenclud@210
     8
    [DataContract]
StephaneLenclud@210
     9
    public abstract class ActionCallback : Action
StephaneLenclud@210
    10
    {
StephaneLenclud@210
    11
        public delegate void Delegate();
StephaneLenclud@210
    12
StephaneLenclud@210
    13
        private readonly Delegate iCallback;
StephaneLenclud@210
    14
StephaneLenclud@210
    15
        public ActionCallback(Delegate aCallback = null)
StephaneLenclud@210
    16
        {
StephaneLenclud@210
    17
            iCallback = aCallback;
StephaneLenclud@210
    18
        }
StephaneLenclud@210
    19
StephaneLenclud@228
    20
        protected override void DoExecute()
StephaneLenclud@210
    21
        {
StephaneLenclud@210
    22
            if (iCallback != null)
StephaneLenclud@210
    23
            {
StephaneLenclud@210
    24
                iCallback.Invoke();
StephaneLenclud@210
    25
            }            
StephaneLenclud@210
    26
        }
StephaneLenclud@210
    27
    }
StephaneLenclud@210
    28
StephaneLenclud@210
    29
}