public IDisposable Subscribe <TE>(IObserver <TE> observer) { _semaphore.Wait(); var pair = new ObserverPair(observer); try { if (_observers.ContainsKey(typeof(TE)) && _observers[typeof(TE)] is object) { _observers[typeof(TE)].Add(pair); } else { _observers[typeof(TE)] = new List <ObserverPair> { pair } }; } finally { _semaphore.Release(); } return(new UnSubscriber <TE>(_observers, pair)); }
public UnSubscriber(Dictionary <Type, List <ObserverPair> > observers, ObserverPair observer) { _observers = observers; _observer = observer; }