ProcessArgument() public method

public ProcessArgument ( string arg, string nextArg ) : OptionProcessingResult
arg string
nextArg string
return OptionProcessingResult
Beispiel #1
0
        public string[] ProcessArgs(string[] args)
        {
            this.list.Sort();
            args = this.NormalizeArgs(args);
            try
            {
                int num1 = args.Length;
                for (int num2 = 0; num2 < num1; num2++)
                {
                    string text1;
                    string text2 = args[num2];
                    if ((num2 + 1) < num1)
                    {
                        text1 = args[num2 + 1];
                    }
                    else
                    {
                        text1 = null;
                    }
                    bool flag1 = false;
                    if ((text2.Length <= 1) || (!text2.StartsWith("-", StringComparison.Ordinal) && !text2.StartsWith("/", StringComparison.Ordinal)))
                    {
                        goto Label_00DA;
                    }
                    IEnumerator enumerator1 = this.list.GetEnumerator();
Label_0078:
                    try
                    {
                        if (enumerator1.MoveNext())
                        {
                            OptionDetails          details1 = (OptionDetails)enumerator1.Current;
                            OptionProcessingResult result1  = details1.ProcessArgument(text2, text1);
                            if (result1 == OptionProcessingResult.NotThisOption)
                            {
                                goto Label_0078;
                            }
                            flag1 = true;
                            if (result1 == OptionProcessingResult.OptionConsumedParameter)
                            {
                                num2++;
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable1 = enumerator1 as IDisposable;
                        if (disposable1 != null)
                        {
                            disposable1.Dispose();
                        }
                    }
Label_00DA:
                    if (!flag1)
                    {
                        this.ProcessNonOption(text2);
                    }
                }
                IEnumerator enumerator2 = this.list.GetEnumerator();
Label_0102:
                try
                {
                    if (enumerator2.MoveNext())
                    {
                        OptionDetails details2 = (OptionDetails)enumerator2.Current;
                        details2.TransferValues();
                        goto Label_0102;
                    }
                }
                finally
                {
                    IDisposable disposable2 = enumerator2 as IDisposable;
                    if (disposable2 != null)
                    {
                        disposable2.Dispose();
                    }
                }
                IEnumerator enumerator3 = this.argumentsTail.GetEnumerator();
Label_0151:
                try
                {
                    if (enumerator3.MoveNext())
                    {
                        string text3 = (string)enumerator3.Current;
                        this.ProcessNonOption(text3);
                        goto Label_0151;
                    }
                }
                finally
                {
                    IDisposable disposable3 = enumerator3 as IDisposable;
                    if (disposable3 != null)
                    {
                        disposable3.Dispose();
                    }
                }
                return((string[])this.arguments.ToArray(typeof(string)));
            }
            catch (Exception exception1)
            {
                Console.WriteLine(exception1.ToString());
                Environment.Exit(1);
            }
            return(null);
        }