//[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; }
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); }
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; }
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; }
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"); }