Exemplo n.º 1
0
 private bool AddSource(OptionSet.ArgumentEnumerator ae, string argument)
 {
     foreach (ArgumentSource argumentSource in this.sources)
     {
         IEnumerable <string> replacement;
         if (argumentSource.GetArguments(argument, out replacement))
         {
             ae.Add(replacement);
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        public List <string> Parse(IEnumerable <string> arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }
            OptionContext optionContext = this.CreateOptionContext();

            optionContext.OptionIndex = -1;
            bool          flag = true;
            List <string> list = new List <string>();
            Option        def  = this.Contains("<>") ? this["<>"] : (Option)null;

            OptionSet.ArgumentEnumerator ae = new OptionSet.ArgumentEnumerator(arguments);
            foreach (string str in ae)
            {
                ++optionContext.OptionIndex;
                if (str == "--")
                {
                    flag = false;
                }
                else if (!flag)
                {
                    OptionSet.Unprocessed((ICollection <string>)list, def, optionContext, str);
                }
                else if (!this.AddSource(ae, str) && !this.Parse(str, optionContext))
                {
                    OptionSet.Unprocessed((ICollection <string>)list, def, optionContext, str);
                }
            }
            if (optionContext.Option != null)
            {
                optionContext.Option.Invoke(optionContext);
            }
            return(list);
        }