public void Unsubscribe(IEventReference eventReference) { EventReference typedEventReference = eventReference as EventReference; if (eventReference == null) { return; } bool found = eventHandlers.TryGetValue(typedEventReference.Type, out List <EventReference> eventReferenceList); if (!found) { return; } eventReferenceList.Remove(typedEventReference); }
public IEventReference Subscribe <T>(Action <T> action) where T : class { Type type = typeof(T); bool found = eventHandlers.TryGetValue(type, out List <EventReference> eventReferenceList); if (!found) { eventReferenceList = new List <EventReference>(); eventHandlers.Add(type, eventReferenceList); } EventReference eventReference = new EventReference(type, (object obj) => action.Invoke(obj as T)); eventReferenceList.Add(eventReference); return(eventReference); }