상속: BaseOptionAttribute
예제 #1
0
        //[Fact]
        //public void RetrieveNotExistentShortOption()
        //{
        //    var shortOi = _optionMap["y"];
        //    shortOi.Should().BeNull();
        //}
        //[Fact]
        //public void RetrieveNotExistentLongOption()
        //{
        //    var longOi = _optionMap["nomorebugshere"];
        //    longOi.Should().BeNull();
        //}
        private static OptionMap CreateMap(ref OptionMap map, IDictionary<string, OptionInfo> optionCache)
        {
            if (map == null)
            {
                map = new OptionMap (3, new CommandLineParserSettings (true));
            }

            var attribute1 = new OptionAttribute('p', "pretend");
            var attribute2 = new OptionAttribute("newuse");
            var attribute3 = new OptionAttribute('D', null);

            var option1 = attribute1.CreateOptionInfo();
            var option2 = attribute2.CreateOptionInfo();
            var option3 = attribute3.CreateOptionInfo();

            map[attribute1.UniqueName] = option1;
            map[attribute2.UniqueName] = option2;
            map[attribute3.UniqueName] = option3;

            if (optionCache != null)
            {
                optionCache[attribute1.UniqueName] = option1;
                optionCache[attribute1.UniqueName] = option2;
                optionCache[attribute2.UniqueName]= option3;
            }

            return map;
        }
예제 #2
0
 public void AppendOption(string shortName, string longName)
 {
     var oa = new OptionAttribute(shortName, longName);
     var oi = oa.CreateOptionInfo();
     _optionMap[oa.UniqueName] = oi;
     _options.Add(oi);
     _names.Add(oa.UniqueName);
 }
예제 #3
0
 public OptionInfo(OptionAttribute attribute, FieldInfo field)
 {
     this.required = attribute.Required;
     this.helpText = attribute.HelpText;
     this.shortName = attribute.ShortName;
     this.longName = attribute.LongName;
     this.field = field;
     this.attribute = attribute;
 }
예제 #4
0
 public OptionInfo(OptionAttribute attribute, FieldInfo field)
 {
     _required = attribute.Required;
     _helpText = attribute.HelpText;
     _shortName = attribute.ShortName;
     _longName = attribute.LongName;
     _mutuallyExclusiveSet = attribute.MutuallyExclusiveSet;
     _field = field;
     _attribute = attribute;
 }
예제 #5
0
        public OptionInfo(OptionAttribute attribute, PropertyInfo property)
        {
            if (attribute != null)
            {
                Required = attribute.Required;
                HelpText = attribute.HelpText;
                ShortName = attribute.ShortName;
                LongName = attribute.LongName;
                MutuallyExclusiveSet = attribute.MutuallyExclusiveSet;
                _attribute = attribute;
            }
            else
                throw new ArgumentNullException("attribute", "The attribute is mandatory");

            if (property != null)
                _property = property;
            else
                throw new ArgumentNullException("property", "The property is mandatory");
        }