Beispiel #1
0
        /// <summary>
        /// Create section info described by sectionProperty.
        /// </summary>
        /// <param name="sectionProperty">Property describing section.</param>
        /// <returns>Section info.</returns>
        internal static SectionInfo CreateSectionInfo(PropertyInfo sectionProperty)
        {
            var options = new List <OptionInfo>();

            var infoAttr    = ReflectionUtils.GetAttribute <SectionInfoAttribute>(sectionProperty);
            var commentAttr = ReflectionUtils.GetAttribute <DefaultCommentAttribute>(sectionProperty);

            var sectionID   = resolveID(infoAttr.ID, sectionProperty);
            var sectionName = new QualifiedSectionName(sectionID);

            foreach (var optionProperty in GetOptionProperties(sectionProperty.PropertyType))
            {
                var optionInfo = CreateOptionInfo(sectionName, optionProperty);
                options.Add(optionInfo);
            }

            return(new SectionInfo(sectionName, sectionProperty, infoAttr.IsOptional, commentAttr.CommentText, options));
        }
Beispiel #2
0
        /// <summary>
        /// Create option info described by optionProperty. Option is placed in section with sectionName.
        /// </summary>
        /// <param name="sectionName">Name of parent section.</param>
        /// <param name="optionProperty">Property describing option.</param>
        /// <returns>Option info.</returns>
        internal static OptionInfo CreateOptionInfo(QualifiedSectionName sectionName, PropertyInfo optionProperty)
        {
            var infoAttr    = ReflectionUtils.GetAttribute <OptionInfoAttribute>(optionProperty);
            var commentAttr = ReflectionUtils.GetAttribute <DefaultCommentAttribute>(optionProperty);
            var rangeAttr   = ReflectionUtils.GetAttribute <RangeAttribute>(optionProperty);


            var optionID   = resolveID(infoAttr.ID, optionProperty);
            var optionName = new QualifiedOptionName(sectionName, optionID);

            var expectedType = optionProperty.PropertyType;

            var defaultValue = createDefaultObject(optionProperty, infoAttr.DefaultValue);

            return(new OptionInfo(
                       optionName, expectedType, optionProperty.Name,
                       defaultValue, infoAttr.IsOptional,
                       commentAttr.CommentText,
                       rangeAttr.LowerBound, rangeAttr.UpperBound
                       ));
        }
Beispiel #3
0
        /// <summary>
        /// Get qualified name for option with given sectionID and optionID.
        /// </summary>
        /// <param name="sectionID">ID of section, where option is defined.</param>
        /// <param name="optionID">ID of option</param>
        /// <returns>Qualified name for option with optionID in section with sectionID.</returns>
        public static QualifiedName ForOption(string sectionID, string optionID)
        {
            var sectionName = new QualifiedSectionName(sectionID);

            return(new QualifiedOptionName(sectionName, optionID));
        }