Пример #1
0
 public static void UnsubscribeAll(IMediatorListener obj)
 {
     foreach (var listener in Listeners.Values)
     {
         listener.RemoveAll(x => !x.IsAlive || x.Target == null || x.Target == obj);
     }
 }
Пример #2
0
        public static void Unsubscribe(string message, IMediatorListener obj)
        {
            if (!Listeners.ContainsKey(message))
            {
                return;
            }
            var l = Listeners[message];

            l.RemoveAll(x => !x.IsAlive || x.Target == null || x.Target == obj);
        }
    //It is faster to use ForEach do to event uses a nullCe

    /// <summary>
    /// Adds a objects that wants to listen to called events
    /// </summary>
    /// <param name="listener"></param>
    public static void AddListener(IMediatorListener listener)
    {
        if (listeners.Contains(listener))
        {
            return;
        }

        listeners.Add(listener);
        AddListener(listener.OnMediatorMessageReceived);
    }
Пример #4
0
 public static void Subscribe(Enum message, IMediatorListener obj)
 {
     Listeners.AddValue(message.ToString(), new WeakReference(obj));
 }
Пример #5
0
 public static void UnsubscribeAll(IMediatorListener obj)
 {
     foreach (var listener in Listeners.Values)
     {
         listener.RemoveAll(x => !x.IsAlive || x.Target == null || x.Target == obj);
     }
 }
Пример #6
0
 public static void Unsubscribe(string message, IMediatorListener obj)
 {
     if (!Listeners.ContainsKey(message)) return;
     var l = Listeners[message];
     l.RemoveAll(x => !x.IsAlive || x.Target == null || x.Target == obj);
 }
Пример #7
0
 public static void Subscribe(Enum message, IMediatorListener obj)
 {
     Listeners.AddValue(message.ToString(), new WeakReference(obj));
 }
 /// <summary>
 /// Removes a object that listened to called events
 /// </summary>
 /// <param name="listener"></param>
 public static void RemoveListener(IMediatorListener listener)
 {
     listeners.Remove(listener);
     RemoveListener(listener.OnMediatorMessageReceived);
 }