ServiceClientGenerator.CommandArguments.AddResponseFileArguments C# (CSharp) Method

AddResponseFileArguments() private method

private AddResponseFileArguments ( string responseFile, ICollection args ) : void
responseFile string
args ICollection
return void
        private void AddResponseFileArguments(string responseFile, ICollection<string> args)
        {
            try
            {
                // Response file format is one argument (plus optional value)
                // per line. Comments can be used by putting # as the first char.
                using (var s = new StreamReader(ResolvePath(responseFile)))
                {
                    var line = s.ReadLine();
                    while (line != null)
                    {
                        if (line.Length != 0 && line[0] != '#')
                        {
                            // trying to be flexible here and allow for lines with or without keyword 
                            // prefix in the response file
                            var keywordEnd = line.IndexOf(' ');
                            var keyword = keywordEnd > 0 ? line.Substring(0, keywordEnd) : line;

                            if (ArgumentPrefixes.Any(prefix => keyword.StartsWith(prefix.ToString(CultureInfo.InvariantCulture))))
                                args.Add(keyword);
                            else
                                args.Add(ArgumentPrefixes[0] + keyword);

                            if (keywordEnd > 0)
                            {
                                keywordEnd++;
                                if (keywordEnd < line.Length)
                                {
                                    var value = line.Substring(keywordEnd).Trim(' ');
                                    if (!string.IsNullOrEmpty(value))
                                        args.Add(value);
                                }
                            }
                        }
                        line = s.ReadLine();
                    }
                }
            }
            catch (Exception e)
            {
                Error = string.Format("Caught exception processing response file {0} - {1}", responseFile, e.Message);
            }
        }