private static ConfigurationPropertyCollection CreatePropertyBagFromType(Type type) {
Debug.Assert(type != null, "type != null");
// For ConfigurationElement derived classes - get the per-type validator
if (typeof(ConfigurationElement).IsAssignableFrom(type)) {
ConfigurationValidatorAttribute attribValidator = Attribute.GetCustomAttribute(type, typeof(ConfigurationValidatorAttribute)) as ConfigurationValidatorAttribute;
if (attribValidator != null) {
ConfigurationValidatorBase validator = attribValidator.ValidatorInstance;
if (validator != null) {
CachePerTypeValidator(type, validator);
}
}
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
foreach (PropertyInfo propertyInformation in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
ConfigurationProperty newProp = CreateConfigurationPropertyFromAttributes(propertyInformation);
if (newProp != null) {
properties.Add(newProp);
}
}
return properties;
}
private static ConfigurationProperty CreateConfigurationPropertyFromAttributes(PropertyInfo propertyInformation) {