Пример #1
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);
        }