public void AddEventListener(IPsdzEventListener psdzEventListener) { if (psdzEventListener == null) { return; } IDictionary <IPsdzEventListener, PsdzEventService.PsdzEventListenerClient> obj = this.eventListenerClients; lock (obj) { if (!this.eventListenerClients.ContainsKey(psdzEventListener)) { PsdzEventService.PsdzEventListenerClient psdzEventListenerClient = new PsdzEventService.PsdzEventListenerClient(psdzEventListener, this.binding, this.endpointAddress); psdzEventListenerClient.StartListening(); this.eventListenerClients.Add(psdzEventListener, psdzEventListenerClient); } } }
public void RemoveEventListener(IPsdzEventListener psdzEventListener) { if (psdzEventListener == null) { return; } IDictionary <IPsdzEventListener, PsdzEventService.PsdzEventListenerClient> obj = this.eventListenerClients; lock (obj) { if (this.eventListenerClients.ContainsKey(psdzEventListener)) { PsdzEventService.PsdzEventListenerClient psdzEventListenerClient = this.eventListenerClients[psdzEventListener]; psdzEventListenerClient.StopListening(); psdzEventListenerClient.Close(); this.eventListenerClients.Remove(psdzEventListener); } } }