This project is read-only.
Each value not captured by an option can be included in a collection of strings derived from System.Collections.Generic.IList<string>.
Obviously, this attribute has no name(s) and is derived directly from System.Attribute.
It's currently the only exception, but it's not excluded that in the future it will have similars.

C#:
namespace CommandLine
{
    public sealed class ValueListAttribute : System.Attribute
    {
        public ValueListAttribute(Type concreteType);

        public int MaximumElements { get; set; }
    }
}
  1. Must be assigned to a field of type IList<string>.
  2. The constructor must accept a type derived from IList<string> as List<string>.
  3. If the MaximumElements property is set to a number greater than 0 (default), the parser will fail if the limit is exceeded.
Here is an example.

C#:
class Options
{
    // ...
    [ValueList(typeof(List<string>), MaximumElements = 3)]
    public IList<string> Items = null;
    // ...	
}
The following will be accepted.

Console:
GuideApp

GuideApp valueONE

GuideApp value-II value_three

GuideApp file0009.xml file0010.bin file0011.dat

The following will be refused.

Console:
GuideApp file0009.xml file0010.bin file0011.dat file0012.htm

Last edited Nov 13, 2009 at 4:36 PM by gsscoder, version 2

Comments

No comments yet.