/// <summary>
        /// Adds the specified argument to the dictionary
        /// </summary>
        /// <param name="argument">Key/Value pair argument.</param>
        private void AddArgument(string argument)
        {
            if (argument == null)
            {
                throw new ArgumentNullException("argument");
            }

            string key;
            string value;

            if (argument.StartsWith(KeyCharacter.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                string[] splitArg = argument.Substring(1).Split(ValueCharacter);

                //Key is extracted from first element
                key = splitArg[0];

                //Reconstruct the value. We could also do this using substrings.
                if (splitArg.Length > 1)
                {
                    value = string.Join("=", splitArg, 1, splitArg.Length - 1);
                }
                else
                {
                    value = string.Empty;
                }
            }
            else
            {
                throw new ArgumentException("Unsupported value line argument format.", argument);
            }

            Add(key, value);
        }
Example #2
0
        /// <summary>
        /// Adds the specified argument to the dictionary
        /// </summary>
        /// <param name="argument">Key/Value pair argument.</param>
        private void AddArgument(string argument)
        {
            if (argument == null)
            {
                throw new ArgumentNullException("argument");
            }

            string key;
            string value;

            if (argument.StartsWith(KeyCharacter.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                //EDIT: changed split to only split on in two parts based on the key character.
                // File Paths and urls are no longer chopped.
                string[] splitArg = argument.Substring(1).Split(new [] { ValueCharacter }, 2);

                //Key is extracted from first element
                key = splitArg[0];

                //Reconstruct the value. We could also do this using substrings.
                if (splitArg.Length > 1)
                {
                    value = string.Join("=", splitArg, 1, splitArg.Length - 1);
                }
                else
                {
                    value = string.Empty;
                }
            }
            else
            {
                throw new ArgumentException("Unsupported  value line argument format.", argument);
            }

            Add(key, value);
        }