SharpLibEar/ManagerEventAction.cs
changeset 234 0c75dec19d39
parent 233 2b9541e54f7d
child 235 ba14a29944c4
     1.1 --- a/SharpLibEar/ManagerEventAction.cs	Mon Aug 15 12:11:26 2016 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,78 +0,0 @@
     1.4 -//
     1.5 -
     1.6 -
     1.7 -using System;
     1.8 -using System.Collections.Generic;
     1.9 -using System.ComponentModel;
    1.10 -using System.Linq;
    1.11 -using System.Reflection;
    1.12 -using System.Runtime.Serialization;
    1.13 -using SharpLib.Utils;
    1.14 -
    1.15 -namespace SharpLib.Ear
    1.16 -{
    1.17 -    [TypeConverter(typeof(TypeConverterJson<ManagerEventAction>))]
    1.18 -    [DataContract]
    1.19 -    public class ManagerEventAction
    1.20 -    {
    1.21 -        public static ManagerEventAction Current = null;
    1.22 -        //public IDictionary<string, Type> ActionTypes;
    1.23 -        //public IDictionary<string, Type> EventTypes;
    1.24 -
    1.25 -        /// <summary>
    1.26 -        /// Our events instances.
    1.27 -        /// </summary>
    1.28 -        [DataMember]
    1.29 -        public List<Event> Events;
    1.30 -
    1.31 -
    1.32 -
    1.33 -
    1.34 -        public ManagerEventAction()
    1.35 -        {
    1.36 -            Init();
    1.37 -        }
    1.38 -
    1.39 -        /// <summary>
    1.40 -        /// Executes after internalization took place.
    1.41 -        /// </summary>
    1.42 -        public void Init()
    1.43 -        {
    1.44 -            if (Events == null)
    1.45 -            {
    1.46 -                Events = new List<Event>();
    1.47 -            }
    1.48 -            
    1.49 -        }
    1.50 -
    1.51 -        /// <summary>
    1.52 -        /// 
    1.53 -        /// </summary>
    1.54 -        /// <param name="aEventType"></param>
    1.55 -        public void TriggerEvent<T>() where T: class
    1.56 -        {
    1.57 -            //Only trigger enabled events matching the desired type
    1.58 -            foreach (Event e in Events.Where(e => e.GetType() == typeof(T) && e.Enabled))
    1.59 -            {
    1.60 -                e.Trigger();
    1.61 -            }
    1.62 -        }
    1.63 -
    1.64 -
    1.65 -        /// <summary>
    1.66 -        /// 
    1.67 -        /// </summary>
    1.68 -        /// <param name="aAction"></param>
    1.69 -        public void RemoveAction(Action aAction)
    1.70 -        {
    1.71 -            foreach (Event e in Events)
    1.72 -            {
    1.73 -                if (e.Actions.Remove(aAction))
    1.74 -                {
    1.75 -                    //We removed our action, we are done here.
    1.76 -                    return;
    1.77 -                }
    1.78 -            }
    1.79 -        }
    1.80 -    }
    1.81 -}
    1.82 \ No newline at end of file