⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contactcollection.cs

📁 该源代码用 C# 写成
💻 CS
字号:
using System;
using System.Collections;
using Org.InteliIM.Users;

namespace Org.InteliIM.Users
{
	/// <summary>
	///   A collection that stores <see cref='Contact'/> objects.
	/// </summary>
	[Serializable()]
	public class ContactCollection : CollectionBase
	{
		/// <summary>
		///   Initializes a new instance of <see cref='ContactCollection'/>.
		/// </summary>
		public ContactCollection()
		{
		}

		/// <summary>
		///   Initializes a new instance of <see cref='ContactCollection'/> based on another <see cref='ContactCollection'/>.
		/// </summary>
		/// <param name='val'>
		///   A <see cref='ContactCollection'/> from which the contents are copied
		/// </param>
		public ContactCollection(ContactCollection val)
		{
			this.AddRange(val);
		}

		/// <summary>
		///   Initializes a new instance of <see cref='ContactCollection'/> containing any array of <see cref='Contact'/> objects.
		/// </summary>
		/// <param name='val'>
		///       A array of <see cref='Contact'/> objects with which to intialize the collection
		/// </param>
		public ContactCollection(Contact[] val)
		{
			this.AddRange(val);
		}

		/// <summary>
		///   Represents the entry at the specified index of the <see cref='Contact'/>.
		/// </summary>
		/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
		/// <value>The entry at the specified index of the collection.</value>
		/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
		public Contact this[int index]
		{
			get { return ((Contact) (List[index])); }
			set { List[index] = value; }
		}

		/// <summary>
		///   Adds a <see cref='Contact'/> with the specified value to the 
		///   <see cref='ContactCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='Contact'/> to add.</param>
		/// <returns>The index at which the new element was inserted.</returns>
		/// <seealso cref='ContactCollection.AddRange'/>
		public int Add(Contact val)
		{
			return List.Add(val);
		}

		/// <summary>
		///   Copies the elements of an array to the end of the <see cref='ContactCollection'/>.
		/// </summary>
		/// <param name='val'>
		///    An array of type <see cref='Contact'/> containing the objects to add to the collection.
		/// </param>
		/// <seealso cref='ContactCollection.Add'/>
		public void AddRange(Contact[] val)
		{
			for (int i = 0; i < val.Length; i++)
			{
				this.Add(val[i]);
			}
		}

		/// <summary>
		///   Adds the contents of another <see cref='ContactCollection'/> to the end of the collection.
		/// </summary>
		/// <param name='val'>
		///    A <see cref='ContactCollection'/> containing the objects to add to the collection.
		/// </param>
		/// <seealso cref='ContactCollection.Add'/>
		public void AddRange(ContactCollection val)
		{
			for (int i = 0; i < val.Count; i++)
			{
				this.Add(val[i]);
			}
		}

		/// <summary>
		///   Gets a value indicating whether the 
		///    <see cref='ContactCollection'/> contains the specified <see cref='Contact'/>.
		/// </summary>
		/// <param name='val'>The <see cref='Contact'/> to locate.</param>
		/// <returns>
		/// <see langword='true'/> if the <see cref='Contact'/> is contained in the collection; 
		///   otherwise, <see langword='false'/>.
		/// </returns>
		/// <seealso cref='ContactCollection.IndexOf'/>
		public bool Contains(Contact val)
		{
			return List.Contains(val);
		}

		/// <summary>
		///   Copies the <see cref='ContactCollection'/> values to a one-dimensional <see cref='Array'/> instance at the 
		///    specified index.
		/// </summary>
		/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='ContactCollection'/>.</param>
		/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
		/// <exception cref='ArgumentException'>
		///   <para><paramref name='array'/> is multidimensional.</para>
		///   <para>-or-</para>
		///   <para>The number of elements in the <see cref='ContactCollection'/> is greater than
		///         the available space between <paramref name='arrayIndex'/> and the end of
		///         <paramref name='array'/>.</para>
		/// </exception>
		/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
		/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
		/// <seealso cref='Array'/>
		public void CopyTo(Contact[] array, int index)
		{
			List.CopyTo(array, index);
		}

		/// <summary>
		///    Returns the index of a <see cref='Contact'/> in 
		///       the <see cref='ContactCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='Contact'/> to locate.</param>
		/// <returns>
		///   The index of the <see cref='Contact'/> of <paramref name='val'/> in the 
		///   <see cref='ContactCollection'/>, if found; otherwise, -1.
		/// </returns>
		/// <seealso cref='ContactCollection.Contains'/>
		public int IndexOf(Contact val)
		{
			return List.IndexOf(val);
		}

		/// <summary>
		///   Inserts a <see cref='Contact'/> into the <see cref='ContactCollection'/> at the specified index.
		/// </summary>
		/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
		/// <param name='val'>The <see cref='Contact'/> to insert.</param>
		/// <seealso cref='ContactCollection.Add'/>
		public void Insert(int index, Contact val)
		{
			List.Insert(index, val);
		}

		/// <summary>
		///  Returns an enumerator that can iterate through the <see cref='ContactCollection'/>.
		/// </summary>
		/// <seealso cref='IEnumerator'/>
		new public ContactEnumerator GetEnumerator()
		{
			return new ContactEnumerator(this);
		}

		/// <summary>
		///   Removes a specific <see cref='Contact'/> from the <see cref='ContactCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='Contact'/> to remove from the <see cref='ContactCollection'/>.</param>
		/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
		public void Remove(Contact val)
		{
			List.Remove(val);
		}

		/// <summary>
		///   Enumerator that can iterate through a ContactCollection.
		/// </summary>
		/// <seealso cref='IEnumerator'/>
		/// <seealso cref='ContactCollection'/>
		/// <seealso cref='Contact'/>
		public class ContactEnumerator : IEnumerator
		{
			private IEnumerator baseEnumerator;
			private IEnumerable temp;

			/// <summary>
			///   Initializes a new instance of <see cref='ContactEnumerator'/>.
			/// </summary>
			public ContactEnumerator(ContactCollection mappings)
			{
				this.temp = ((IEnumerable) (mappings));
				this.baseEnumerator = temp.GetEnumerator();
			}

			/// <summary>
			///   Gets the current <see cref='Contact'/> in the <seealso cref='ContactCollection'/>.
			/// </summary>
			public Contact Current
			{
				get { return ((Contact) (baseEnumerator.Current)); }
			}

			object IEnumerator.Current
			{
				get { return baseEnumerator.Current; }
			}

			/// <summary>
			///   Advances the enumerator to the next <see cref='Contact'/> of the <see cref='ContactCollection'/>.
			/// </summary>
			public bool MoveNext()
			{
				return baseEnumerator.MoveNext();
			}

			/// <summary>
			///   Sets the enumerator to its initial position, which is before the first element in the <see cref='ContactCollection'/>.
			/// </summary>
			public void Reset()
			{
				baseEnumerator.Reset();
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -