/// <summary> /// Add the specified access listener to this server. The listener is called /// every time there is a remote call to the WITSML server. /// </summary> /// <param name="accessListener">Listener to add. If the listener is already /// added to this server, this call has no effect. Non-null. /// </param> public void addAccessListener(WitsmlAccessListener accessListener) { if (accessListener == null) { throw new ArgumentException("accessListener cannot be null"); } // Check if it is there already foreach (WeakReference reference in accessListeners) { if (accessListener.Equals(reference.Target)) { return; } } accessListeners.Add(new WeakReference(accessListener)); }
/// <summary> /// Remove the specified access listener from this server. /// </summary> /// <param name="accessListener"> /// Listener to remove. Non-null. If the instance /// has not been previously added as a listener /// to this server, this call has no effect. /// </param> public void removeAccessListener(WitsmlAccessListener accessListener) { if (accessListener == null) { throw new ArgumentException("accessListener cannot be null"); } foreach (var i in accessListeners) { WeakReference reference = i as WeakReference; WitsmlAccessListener listener = reference.Target as WitsmlAccessListener; if (listener.Equals(accessListener)) { accessListeners.Remove(i); break; } } }