public static void Unsubscribe(EventAggregatorSubscribtionToken token) { if (!_subscriptions.ContainsKey(token)) { return; } while (!_subscriptions.TryRemove(token, out var _)) { ; } }
public static EventAggregatorSubscribtionToken Subscribe <T>(Action <T> action) where T : EventAggregatorEventArgs { var token = new EventAggregatorSubscribtionToken(); MethodInfo method = null; #if (WINDOWS_PHONE_APP || WINDOWS_APP) // targeting UWP method = action.GetMethodInfo(); #else method = action.Method; #endif while (!_subscriptions.TryAdd(token, new ActionContainer(action.Target, method))) { ; } return(token); }