public string CreateUniqueMethodName(IComponent component, EventDescriptor e)
{
if (component.Site == null || component.Site.Name == null)
throw new ArgumentException ("IComponent must be sited and named");
//TODO: check component.Site.Name is valid as start of method name
string trialPrefix = component.Site.Name + "_" + e.Name;
string trialValue = trialPrefix;
for (int suffix = 1; suffix <= int.MaxValue; suffix++)
{
if (!eventHandlers.ContainsKey (trialValue))
return trialValue;
trialValue = trialPrefix + suffix.ToString ();
}
throw new Exception ("Tried method names up to " + trialValue + " and all already existed");
}