/// <summary> /// Subscribe an action with object for string key. /// </summary> /// <param name="key">String key for subscribe action name.</param> /// <param name="action">Action to call with object</param> public static void Subscribe(string key, Action <object> action) { if (key == null) { throw new ArgumentNullException(nameof(key), "KEY argument should have value"); } SubscribersWithData?.Add(new Tuple <string, Action <object> >(key, action)); }
public static void Subscribe(object receiver, string key, Action <object> action) { if (key == null) { throw new ArgumentNullException(nameof(key), "KEY argument should have value"); } var listOfSubs = Subscribers?.Where(k => k.Item1 == receiver && k.Item2 == key).FirstOrDefault(); if (listOfSubs != null) { throw new Exception("reciever already subscribed"); } SubscribersWithData?.Add(new Tuple <object, string, Action <object> >(receiver, key, action)); }