public static OptionConfigurationProperty GetDefaultCollectionProperty(OptionConfigurationPropertyCollection properties) { if(properties == null || properties.Count < 1) return null; return properties.FirstOrDefault(property => property.IsDefaultCollection); }
static TracerElement() { _enabled = new OptionConfigurationProperty("enabled", typeof(bool), true); _listeners = new OptionConfigurationProperty("listeners", typeof(TraceListenerElementCollection), null); _properties = new OptionConfigurationPropertyCollection(); _properties.Add(_enabled); _properties.Add(_listeners); }
private static OptionConfigurationPropertyCollection GetOptionPropertiesFromType(Type type) { OptionConfigurationPropertyCollection properties; if(_propertyBags.TryGetValue(type, out properties)) return properties; lock(_propertyBags) { if(_propertyBags.TryGetValue(type, out properties)) return properties; properties = new OptionConfigurationPropertyCollection(); foreach(var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { var property = CreateOptionPropertyFromAttribute(propertyInfo); if(property != null) properties.Add(property); } _propertyBags[type] = properties; } return properties; }