/// <summary> /// Removes a receptor from the system. Before being removed, the receptor's Terminate() /// method is called so that it can do whatever cleanup is required. /// </summary> /// <param name="receptor"></param> public void Remove(IReceptor receptor) { receptor.Instance.Terminate(); // TODO: If our collections were IReceptor, then we wouldn't need the "as". receptors.Remove(receptor as Receptor); registeredReceptorMap.Remove(receptor); protocolReceptorMap.ForEach(kvp => kvp.Value.Remove(receptor as Receptor)); ReceptorRemoved.Fire(this, new ReceptorEventArgs(receptor)); // TODO: Refactor out of this code. // TODO: Add a "RemovedReceptor" event. Say("Receptor " + receptor.Name + " removed."); }
protected void OnReceptorRemoved(object sender, ReceptorEventArgs args) { // Forward to other listeners. ReceptorRemoved.Fire(this, args); UpdatePermeability(); }