ServiceClientGenerator.CommandArguments.Process C# (CSharp) Method

Process() private method

private Process ( IEnumerable cmdlineArgs ) : void
cmdlineArgs IEnumerable
return void
        private void Process(IEnumerable<string> cmdlineArgs)
        {
            // walk the supplied command line looking for any response file(s), indicated using
            // @filename, and fuse into one logical set of arguments we can parse
            var argsToParse = new List<string>();
            foreach (var a in cmdlineArgs)
            {
                if (a.StartsWith("@", StringComparison.OrdinalIgnoreCase))
                    AddResponseFileArguments(a.Substring(1), argsToParse);
                else
                    argsToParse.Add(a);
            }

            if (string.IsNullOrEmpty(Error))
            {
                for (var argIndex = 0; argIndex < argsToParse.Count; argIndex++)
                {
                    if (!IsSwitch(argsToParse[argIndex])) continue;

                    var argDeclaration = FindArgDeclaration(argsToParse[argIndex]);
                    if (argDeclaration != null)
                    {
                        if (argDeclaration.HasValue)
                            argIndex++;
                        if (argIndex < argsToParse.Count)
                            argDeclaration.Parse(this, argsToParse[argIndex]);
                        else
                            Error = "Expected value for argument: " + argDeclaration.OptionName;
                    }
                    else
                        Error = "Unrecognised argument: " + argsToParse[argIndex];

                    if (!string.IsNullOrEmpty(Error))
                        break;
                }
            }
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Takes the command line arguments, fuses them with any response file that may also have
        /// been specified, and parses them.
        /// </summary>
        /// <param name="cmdlineArgs">The set of arguments supplied to the program</param>
        /// <returns></returns>
        public static CommandArguments Parse(string[] cmdlineArgs)
        {
            var arguments = new CommandArguments();

            arguments.Process(cmdlineArgs);
            return(arguments);
        }
All Usage Examples Of ServiceClientGenerator.CommandArguments::Process