public void Add(PortableDispatcher dispatcher, PropertyChangedEventHandler eventHandler) { EventHandlersForDispatcher handlersForDispatcher = _list.FirstOrDefault(i => i.Dispatcher == dispatcher); if (handlersForDispatcher == null) { handlersForDispatcher = new EventHandlersForDispatcher(dispatcher); _list.Add(handlersForDispatcher); } // If the event handler isn't in the list yet, add it if (!handlersForDispatcher.Contains(eventHandler)) { handlersForDispatcher.Add(eventHandler); } }
public static PortableDispatcher GetCurrentDispatcher() { if (ObtainDispatcherFunction == null) { throw new NullReferenceException("ObtainDispatcherFunction cannot be null"); } PortableDispatcher d = ObtainDispatcherFunction(); if (d == null) { throw new NullReferenceException("ObtainDispatcherFunction must return an initialized dispatcher."); } return(d); }
public EventHandlersForDispatcher(PortableDispatcher dispatcher) { Dispatcher = dispatcher; }