/// <summary>
 /// Initializes a new instance of the <see cref="CommandParameterCollection"/> class.
 /// </summary>
 /// <param name="array">The parameter array.</param>
 public CommandParameterCollection(CommandParameter[] array)
 {
     _parameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
     if (array != null)
         foreach (CommandParameter parameter in array) Add(parameter);
 }
 /// <summary>
 /// Adds the given parameter in collection.
 /// </summary>
 /// <param name="parameter">The parameter.</param>
 /// <exception cref="System.ArgumentNullException">parameter</exception>
 /// <exception cref="System.ArgumentException">Invalid parameter name</exception>
 public void Add(CommandParameter parameter)
 {
     if (parameter == null) throw new ArgumentNullException("parameter");
     if (parameter.Name.Length == 0) throw new ArgumentException("Invalid parameter name", "parameter");
     _parameters[parameter.Name] = parameter.Value; // this will overwrite the existing value for given key if any
 }
 /// <summary>
 /// Returns the array containing all command parameters.
 /// </summary>
 /// <returns></returns>
 public CommandParameter[] ToArray()
 {
     CommandParameter[] array = new CommandParameter[Count];
     if (_parameters != null)
     {
         int index = 0;
         foreach (KeyValuePair<string, object> parameter in _parameters)
             array[index++] = new CommandParameter(parameter.Key, parameter.Value);
     }
     return array;
 }