private void CheckName(string name)
{
bool isAttribute = (_lockType & ConfigurationLockType.Attribute) == ConfigurationLockType.Attribute;
if (_valid_name_hash == null)
{
_valid_name_hash = new Hashtable();
foreach (ConfigurationAttributeSchema prop in _element.Schema.AttributeSchemas)
{
_valid_name_hash.Add(prop.Name, true);
}
/* add the add/remove/clear names of the
* default collection if there is one */
if (!isAttribute)
{
ConfigurationElementCollection c = _element.GetCollection();
foreach (var addName in _element.Schema.CollectionSchema.AddElementNames.Split(','))
{
_valid_name_hash.Add(addName, true);
}
_valid_name_hash.Add(c.Schema.CollectionSchema.ClearElementName, true);
_valid_name_hash.Add(c.Schema.CollectionSchema.RemoveElementName, true);
}
string[] valid_name_array = new string[_valid_name_hash.Keys.Count];
_valid_name_hash.Keys.CopyTo(valid_name_array, 0);
_valid_names = String.Join(",", valid_name_array);
}
if (_valid_name_hash[name] == null)
throw new ServerManagerException(
String.Format("The {2} '{0}' is not valid in the locked list for this section. The following {3} can be locked: '{1}'",
name, _valid_names, isAttribute ? "attribute" : "element", isAttribute ? "attributes" : "elements"));
}