private void CheckName(string name) { var isAttribute = (_lockType & ConfigurationLockType.Attribute) == ConfigurationLockType.Attribute; if (_validNameHash == null) { _validNameHash = new Hashtable(); foreach (ConfigurationProperty prop in _element.Properties) { if (isAttribute == prop.IsElement) { continue; } _validNameHash.Add(prop.Name, true); } /* add the add/remove/clear names of the * default collection if there is one */ if (!isAttribute) { var c = _element.GetDefaultCollection(); _validNameHash.Add(c.AddElementName, true); _validNameHash.Add(c.ClearElementName, true); _validNameHash.Add(c.RemoveElementName, true); } var validNameArray = new string[_validNameHash.Keys.Count]; _validNameHash.Keys.CopyTo(validNameArray, 0); _validNames = string.Join(",", validNameArray); } if (_validNameHash[name] == null) { throw new ConfigurationErrorsException( string.Format( "The {2} '{0}' is not valid in the locked list for this section. The following {3} can be locked: '{1}'", name, _validNames, isAttribute ? "attribute" : "element", isAttribute ? "attributes" : "elements")); } }