OpenStory.Common.ParameterList.ToArgumentList C# (CSharp) Method

ToArgumentList() public method

Constructs a string array parameter list.
This is useful when you need to use the list with the .NET methods to execute a process.
public ToArgumentList ( ) : string[]
return string[]
        public string[] ToArgumentList()
        {
            var count = this.parameters.Count;
            var args = new string[count];
            int index = 0;

            var entries = this.parameters.OrderBy(item => item.Key, StringComparer.OrdinalIgnoreCase);
            foreach (var entry in entries)
            {
                var name = entry.Key;
                var value = entry.Value;
                if (string.IsNullOrEmpty(value))
                {
                    const string NoValueEntry = @"--{0}";
                    args[index] = string.Format(InvariantCulture, NoValueEntry, name);
                }
                else
                {
                    const string ValueEntry = @"--{0}=""{1}""";
                    args[index] = string.Format(InvariantCulture, ValueEntry, name, value);
                }

                index++;
            }

            return args;
        }