コード例 #1
0
ファイル: Receptors.cs プロジェクト: babann/HOPE
        /// <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));
            });
        }
コード例 #2
0
ファイル: Receptors.cs プロジェクト: babann/HOPE
        /// <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.");
        }