Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

Remoting Management Console

Rate me:
Please Sign up or sign in to vote.
4.96/5 (68 votes)
11 Apr 200310 min read 232K   6.6K   169  
This is a MMC Snap-in to manage a remoting host process and its configuration file. Like the COM+ catalog, the Remoting Management Console will create and administrate the host process to publish your remoting objects.
using System;
using System.Collections;

namespace Ironring.Management.MMC
{
	/// <summary>
	/// Manages event/delegate list pairs for many event.
	/// Used when an object supports many events that are 
	/// registered sparsely if at all.  This method prevents
	/// excessive overhead if no one registers for the event.
	/// </summary>
    public class EventHandlerSet : IDisposable
    {
        /// <summary>
        /// The hash table that stores event key/delegate value pairs
        /// </summary>
        protected Hashtable m_events = new Hashtable();

        /////////////////////////////////////////////////////////////////
        ///
        /// Implementation
        ///

        /// <summary>
        /// get and set events in the set
        /// </summary>
        public virtual Delegate this[object eventKey]
        {
            get { return (Delegate)m_events[eventKey]; }
            set { m_events[eventKey] = value; }
        }

        /// <summary>
        /// Adds a delegate for the indicated event key
        /// </summary>
        /// <param name="eventKey"></param>
        /// <param name="handler"></param>
        public virtual void AddHandler(object eventKey, Delegate handler)
        {
            m_events[eventKey] = Delegate.Combine((Delegate)m_events[eventKey], handler);
        }

        /// <summary>
        /// Remove the delegate with the given key
        /// </summary>
        /// <param name="eventKey"></param>
        /// <param name="handler"></param>
        public virtual void RemoveHandler(object eventKey, Delegate handler)
        {   
            m_events[eventKey] = Delegate.Remove((Delegate)m_events[eventKey], handler);
        }

        /// <summary>
        /// Fire the delegate for the event hash code 
        /// </summary>
        /// <param name="eventKey"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public virtual void Fire(object eventKey, object sender, EventArgs e)
        {
            Delegate d = (Delegate)m_events[eventKey];
            if (d != null)
            {
                object [] args = new object[] {sender, e};
                d.DynamicInvoke(args);
            }
        }

        /// <summary>
        /// cleanup 
        /// </summary>
        public void Dispose()
        {
            m_events = null;
        }
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions