public static void AddAnnotation(this XmlSchemaAnnotated annotatedType, Type type, ConfigurationPropertyAttribute configProperty) { annotatedType.Annotation = new XmlSchemaAnnotation(); // human documentation var descriptionAtts = TypeParser.GetAttributes <DescriptionAttribute>(type); var xmlDocumentation = type.GetXmlDocumentation(); var typeName = type.FullName; ApplyAnnotation(annotatedType, descriptionAtts, configProperty, xmlDocumentation, typeName, typeName); }
CreateConfigurationProperties(Configuration defaultObject) { SafeType <Configuration> config = SafeType <Configuration> .Get(defaultObject); ConfigurationPropertiesImpl properties = new ConfigurationPropertiesImpl(); IList <ConfigurationPropertyImpl> temp = new List <ConfigurationPropertyImpl>(); IDictionary <string, PropertyInfo> descs = GetFilteredProperties(config); foreach (PropertyInfo desc in descs.Values) { String name = desc.Name; // get the configuration options.. ConfigurationPropertyAttribute options = GetPropertyOptions(desc); // use the options to set internal properties.. int order = 0; String helpKey = name + ".help"; String displKey = name + ".display"; bool confidential = false; bool required = false; if (options != null) { // determine the display and help keys.. if (!StringUtil.IsBlank(options.HelpMessageKey)) { helpKey = options.HelpMessageKey; } if (!StringUtil.IsBlank(options.DisplayMessageKey)) { displKey = options.DisplayMessageKey; } // determine the order.. order = options.Order; required = options.Required; confidential = options.Confidential; } Type type = desc.PropertyType; if (!FrameworkUtil.IsSupportedConfigurationType(type)) { const String MSG = "Property type ''{0}'' is not supported."; throw new ArgumentException(String.Format(MSG, type)); } Object value = desc.GetValue(defaultObject, null); ConfigurationPropertyImpl prop = new ConfigurationPropertyImpl(); prop.IsConfidential = confidential; prop.IsRequired = required; prop.DisplayMessageKey = displKey; prop.HelpMessageKey = helpKey; prop.Name = name; prop.Order = order; prop.Value = value; prop.ValueType = type; prop.Operations = options == null ? null : TranslateOperations(options.Operations); temp.Add(prop); } properties.Properties = (temp); return(properties); }
/// <summary> /// Provides standard documentation for a type in the form of XmlSchemaDocumentation objects /// </summary> public static void AddAnnotation(this XmlSchemaAnnotated annotatedType, PropertyInfo property, ConfigurationPropertyAttribute configProperty) { annotatedType.Annotation = new XmlSchemaAnnotation(); // human documentation var descriptionAtts = TypeParser.GetAttributes <DescriptionAttribute>(property); var xmlDocumentation = property.GetXmlDocumentation(); var fullName = property.PropertyType.FullName; var typeName = String.Format("{0}{1}", property.DeclaringType.FullName, property.Name); ApplyAnnotation(annotatedType, descriptionAtts, configProperty, xmlDocumentation, typeName, fullName); }