예제 #1
0
 private void ThrowIfArgumentsRemain(ArgIterator argIt)
 {
     if (argIt.MoveNext() == true)
     {
         throw new Exception("Unexpected arguments");
     }
 }
예제 #2
0
        public void Parse(T t, string[] args)
        {
            try
            {
                var argIt = new ArgIterator(args);

                new OptionalArgumentsParser <T>(t, _optionalArgumentAttrs, argIt).Parse();
                new RequiredArgumentsParser <T>(t, _requiredArgumentAttrs, argIt).Parse();
                new RemainingArgumentsParser <T>(t, _remainingArgumentAttr, argIt).Parse();

                ThrowIfArgumentsRemain(argIt);
            }
            catch (Exception e)
            {
                throw new NArgException(Usage.GetUsageString(_progName, _optionalArgumentAttrs, _requiredArgumentAttrs, _remainingArgumentAttr), e);
            }
        }
 public RequiredArgumentsParser(T t, IEnumerable <MemberAttribute> required, ArgIterator argIt)
 {
     _t        = t;
     _required = required;
     _argIt    = argIt;
 }
 public RemainingArgumentsParser(T t, MemberAttribute remaining, ArgIterator argIt)
 {
     _t         = t;
     _remaining = remaining;
     _argIt     = argIt;
 }
예제 #5
0
 public OptionalArgumentsParser(T t, IEnumerable <MemberAttribute> options, ArgIterator argIt)
 {
     _t       = t;
     _options = options;
     _argIt   = argIt;
 }