AspNetEdit.Editor.ComponentModel.EventBindingService.CreateUniqueMethodName C# (CSharp) Method

CreateUniqueMethodName() public method

public CreateUniqueMethodName ( IComponent component, System.ComponentModel.EventDescriptor e ) : string
component IComponent
e System.ComponentModel.EventDescriptor
return string
        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");
        }