Пример #1
0
        public static OptionInfo GetOptionPropertyInfo(PropertyInfo property, object parentObj, string path, GroupAttribute groupAttrib)
        {
            string shortName = null;
            string longName  = null;

            var optionAttrib = property.GetCustomAttribute <OptionAttribute>();

            if (optionAttrib != null)
            {
                shortName = optionAttrib.ShortName;
                longName  = optionAttrib.LongName;
            }
            else
            {
                shortName = null;
                longName  = property.Name.ToLower();
            }

            var optionPath = string.Empty;

            if (path != null)
            {
                optionPath = path + "-";
            }

            if (shortName != null)
            {
                shortName = "-" + optionPath + shortName;
            }

            if (longName != null)
            {
                longName = "--" + optionPath + longName;
            }

            return(new OptionInfo(parentObj, property, optionAttrib, groupAttrib, shortName, longName));
        }
Пример #2
0
 public OptionInfo(object obj, PropertyInfo propertyInfo, OptionAttribute optionAttribute, GroupAttribute groupAttribute, string formattedShortName, string formattedLongName)
 {
     Object             = obj;
     PropertyInfo       = propertyInfo;
     OptionAttribute    = optionAttribute;
     GroupAttribute     = groupAttribute;
     FormattedShortName = formattedShortName;
     FormattedLongName  = formattedLongName;
 }