Ejemplo n.º 1
0
 public static void AddListener(EventListenerDelegate del, P prio)
 {
     if (!PriorityLookup.ContainsKey(prio))
     {
         PriorityLookup[prio] = new List <EventListenerDelegate>();
     }
     if (PriorityLookup[prio].Contains(del))
     {
         throw new System.Exception("Delegate is already listening to this event.");
     }
     PriorityLookup[prio].Add(del);
 }
Ejemplo n.º 2
0
 public static void RemoveListener(EventListenerDelegate del, P prio)
 {
     if (!PriorityLookup.ContainsKey(prio))
     {
         throw new System.Exception("Attempting to remove delegate listener in priority that has no delegate listeners.");
     }
     if (!PriorityLookup[prio].Contains(del))
     {
         throw new System.Exception("Attempting to remove delegate listener that is not subscribed to this event.");
     }
     PriorityLookup[prio].Remove(del);
 }
Ejemplo n.º 3
0
 public static void Raise(T data)
 {
     if (CorrectOrderedP == null)
     {
         CorrectOrderedP = new List <int>();
         foreach (int x in Enum.GetValues(typeof(P)))
         {
             CorrectOrderedP.Add(x);
         }
         CorrectOrderedP.Sort();
     }
     foreach (int x in CorrectOrderedP)
     {
         P val = (P)Enum.ToObject(typeof(P), x);
         if (!PriorityLookup.ContainsKey(val))
         {
             continue;
         }
         foreach (var del in PriorityLookup[val])
         {
             del(data);
         }
     }
 }