Introduction
This collection allows the developer to call any number of events from a centralized source.
Using the code
Simply instantiate the EventDictionary
class as you would a regular Dictionary
class, and pass in an EventHandler
using the EventDictionary.Add
method.
using System;
using System.Collections.Generic;
public class EventDictionary : Dictionary<string, EventHandler>
{
...
public void Add(EventHandler e)
{
if (e == null)
throw new ArgumentException("Event Handler cannot be null.",
"e");
string s = e.Target.GetType().GetEvents()[0].ToString();
base.Add(s.Substring(s.LastIndexOf(" ") + 1), e);
}
}