示例#1
0
 /// <summary>
 /// Add delegate for callback if a object of the given type unregisters itsself
 /// </summary>
 /// <param name="theCallback"></param>
 public static void RegisterRemoveEvent <T>(System.Action <object, System.EventArgs> theCallback)
 {
     if (theCallback == null)
     {
         return;
     }
     System.Type theType = typeof(T);
     if (!itsListEventsRemove.ContainsKey(theType))
     {
         itsListEventsRemove[theType] = new KGFDelegate();
     }
     itsListEventsRemove[theType] += theCallback;
 }
    /// <summary>
    /// Add delegate for callback if a object of the given type registers itsself and unregisters it after the first found object
    /// </summary>
    /// <param name="theCallback"></param>
    public static void RegisterAddOnceEvent <T>(Action <object, EventArgs> theCallback)
    {
        if (theCallback == null)
        {
            return;
        }
        Type theType = typeof(T);

        if (!itsListEventsAddOnce.ContainsKey(theType))
        {
            itsListEventsAddOnce[theType] = new KGFDelegate();
        }
        itsListEventsAddOnce[theType] += theCallback;
    }