Beispiel #1
0
        /// <summary>
        /// Remove the receptor without generating remove events or terminating the receptor.
        /// </summary>
        protected void InternalRemove(IReceptor receptor)
        {
            receptors.Remove(receptor as Receptor);
            registeredReceptorMap.Remove(receptor);

            protocolReceptorMap.ForEach(kvp =>
            {
                IReceptorConnection conn = kvp.Value.SingleOrDefault(rc => rc.Receptor == receptor);
                conn.IfNotNull(c => kvp.Value.Remove(c));
            });
        }
Beispiel #2
0
        /// <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 =>
            {
                IReceptorConnection conn = kvp.Value.SingleOrDefault(rc => rc.Receptor == receptor);
                conn.IfNotNull(c => kvp.Value.Remove(c));
            });

            ReceptorRemoved.Fire(this, new ReceptorEventArgs(receptor));

            // TODO: Refactor out of this code.
            // TODO: Add a "RemovedReceptor" event.
            Say("Receptor " + receptor.Name + " removed.");
        }