How to use multiple values for ValueArgument?

Mar 20, 2015 at 3:30 PM
When I tried using the "MultipleValues" option, it tells me that I need to implement ICollections<TValue> but I have no idea how to accomplish this.

Any good example here how this could look like?
Coordinator
Mar 20, 2015 at 9:41 PM
Edited Mar 20, 2015 at 9:41 PM
Something like this:
[TestFixture]
public class ValueArgumentTests
{
    public CommandLineParser.CommandLineParser CommandLineParser;
    ParsingTarget target; 

    class ParsingTarget
    {
        [ValueArgument(typeof(int), 'i', AllowMultiple = true)]
        public List<int> Numbers = new List<int>(); 
    }

    [TestFixtureSetUp]
    public void Init()
    {
        CommandLineParser = new CommandLineParser.CommandLineParser();
        target = new ParsingTarget();
        CommandLineParser.ExtractArgumentAttributes(target);
    }

    [Test]
    public void MultipleValuesTest()
    {
        string[] args = new[] { "-i", "1", "-i", "2", "-i", "3" };
        CommandLineParser.ParseCommandLine(args);
    }

    public enum MyEnum
    {
        One,
        Two
    }

    [Test]
    public void EnumTest()
    {
        ValueArgument<MyEnum> enumArg = new ValueArgument<MyEnum>('e');
        CommandLineParser.Arguments.Add(enumArg);
        string[] args = new[] { "-e", "One" };
        CommandLineParser.ParseCommandLine(args);
    }
}