public OptionInfo(object key, string name, Type type, MemberInfo memberInfo, CommandOptionAttribute attribute, CommandOptionChoicesAttribute choicesAttribute)
			{
				this.Key = key;
				this.Name = name;
				this.Type = type;
				this.MemberInfo = memberInfo;
				this.Attribute = attribute;
				this.ChoicesAttribute = choicesAttribute;
			}
Beispiel #2
0
        protected virtual void AddCommandLineOption(MemberInfo[] memberInfos)
        {
            foreach (var memberInfo in memberInfos)
            {
                var attributes = (CommandOptionAttribute[])memberInfo.GetCustomAttributes(typeof(CommandOptionAttribute), true);

                if (attributes.Length <= 0)
                {
                    continue;
                }

                var attribute = attributes[0];

                var name = attribute.Name;

                if (name == "")
                {
                    name = memberInfo.Name;
                }

                var type = attribute.Type;

                if (type == null)
                {
                    type = memberInfo.GetMemberReturnType();
                }

                object key = name;

                if (attribute.UnnamedOptionIndex >= 0)
                {
                    key = attribute.UnnamedOptionIndex;
                }

                CommandOptionChoicesAttribute choicesAttribute = null;

                var choicesAttributes = (CommandOptionChoicesAttribute[])memberInfo.GetCustomAttributes(typeof(CommandOptionChoicesAttribute), true);

                if (choicesAttributes.Length > 0)
                {
                    choicesAttribute = choicesAttributes[0];
                }

                this.keyTypeMap[key] = new OptionInfo(key, name, type, memberInfo, attribute, choicesAttribute);
            }
        }
Beispiel #3
0
 public OptionInfo(object key, string name, Type type, MemberInfo memberInfo, CommandOptionAttribute attribute, CommandOptionChoicesAttribute choicesAttribute)
 {
     this.Key              = key;
     this.Name             = name;
     this.Type             = type;
     this.MemberInfo       = memberInfo;
     this.Attribute        = attribute;
     this.ChoicesAttribute = choicesAttribute;
 }