using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; namespace EasyDevCore.Database { /// /// /// [Serializable] public sealed class EasyDbParameterCollection : IEnumerable { private Dictionary m_List; /// /// Initializes a new instance of the class. /// public EasyDbParameterCollection() { m_List = new Dictionary(); } /// /// Adds the specified p. /// /// The parameter. /// /// The p. public EasyDbParameter Add(EasyDbParameter parameter) { m_List.Add(parameter.ParameterName, parameter); return parameter; } /// /// Removes the specified parameter name. /// /// Name of the parameter. /// public bool Remove(string parameterName) { return m_List.Remove(parameterName); } /// /// Gets the count. /// /// The count. public int Count { get { return m_List.Count; } } /// /// Determines whether [contains] [the specified name]. /// /// The name. /// /// true if [contains] [the specified name]; otherwise, false. /// public bool Contains(string name) { return m_List.ContainsKey(name); } /// /// Gets the with the specified name. /// /// /// The . /// /// The name. /// public EasyDbParameter this[string name] { get { return Contains(name) ? m_List[name] : null; } } /// /// Gets the at the specified index. /// /// /// The . /// /// The index. /// public EasyDbParameter this[int index] { get { return m_List.Values.ElementAtOrDefault(index); } } #region IEnumerable Members /// /// Returns an enumerator that iterates through the collection. /// /// /// A that can be used to iterate through the collection. /// IEnumerator IEnumerable.GetEnumerator() { return m_List.Values.GetEnumerator(); } #endregion #region IEnumerable Members /// /// Returns an enumerator that iterates through a collection. /// /// /// An object that can be used to iterate through the collection. /// System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { IEnumerable enumerable = this; return enumerable.GetEnumerator(); } #endregion } }