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