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

📄 pagelocationcollection.cs

📁 基于.Net环境下c#实现的国人自己的Blog平台,基于.Text的核心技术,但做了汉化以及改写了一部分的核心代码,值得研究学习
💻 CS
📖 第 1 页 / 共 4 页
字号:
#region Disclaimer/Info

///////////////////////////////////////////////////////////////////////////////////////////////////
// .Text WebLog
// 
// .Text is an open source weblog system started by Scott Watermasysk. 
// Blog: http://ScottWater.com/blog 
// RSS: http://scottwater.com/blog/rss.aspx
// Email: Dottext@ScottWater.com
//
// For updated news and information please visit http://scottwater.com/dottext and subscribe to 
// the Rss feed @ http://scottwater.com/dottext/rss.aspx
//
// On its release (on or about August 1, 2003) this application is licensed under the BSD. However, I reserve the 
// right to change or modify this at any time. The most recent and up to date license can always be fount at:
// http://ScottWater.com/License.txt
// 
// Please direct all code related questions to:
// GotDotNet Workspace: http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=e99fccb3-1a8c-42b5-90ee-348f6b77c407
// Yahoo Group http://groups.yahoo.com/group/DotText/
// 
///////////////////////////////////////////////////////////////////////////////////////////////////

#endregion

using System;
using System.Collections;

namespace Dottext.Web.Admin
{

	#region PageLocationCollection

	/// <summary>
	/// Implements a strongly typed collection of <see cref="PageLocation"/> elements.
	/// </summary>
	/// <remarks>
	/// <b>PageLocationCollection</b> provides an <see cref="ArrayList"/> 
	/// that is strongly typed for <see cref="PageLocation"/> elements.
	/// </remarks>
	[Serializable]
	public class PageLocationCollection : IPageLocationList, IList, ICloneable
	{
		#region Private Fields

		private const int _defaultCapacity = 16;

		private PageLocation[] _array = null;
		private int _count = 0;

		[NonSerialized] private int _version = 0;

		#endregion

		#region Private Constructors

		private enum Tag
		{
			Default
		}

		private PageLocationCollection(Tag tag)
		{
		}

		#endregion

		#region Public Constructors

		/// <overloads>
		/// Initializes a new instance of the <see cref="PageLocationCollection"/> class.
		/// </overloads>
		/// <summary>
		/// Initializes a new instance of the <see cref="PageLocationCollection"/> class
		/// that is empty and has the default initial capacity.
		/// </summary>
		/// <remarks>Please refer to <see cref="ArrayList()"/> for details.</remarks>    
		public PageLocationCollection()
		{
			this._array = new PageLocation[_defaultCapacity];
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="PageLocationCollection"/> class
		/// that is empty and has the specified initial capacity.
		/// </summary>
		/// <param name="capacity">The number of elements that the new 
		/// <see cref="PageLocationCollection"/> is initially capable of storing.</param>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <paramref name="capacity"/> is less than zero.</exception>    
		/// <remarks>Please refer to <see cref="ArrayList(Int32)"/> for details.</remarks>    
		public PageLocationCollection(int capacity)
		{
			if (capacity < 0)
				throw new ArgumentOutOfRangeException("capacity", capacity, "Argument cannot be negative.");

			this._array = new PageLocation[capacity];
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="PageLocationCollection"/> class
		/// that contains elements copied from the specified collection and
		/// that has the same initial capacity as the number of elements copied.
		/// </summary>
		/// <param name="collection">The <see cref="PageLocationCollection"/> 
		/// whose elements are copied to the new collection.</param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="collection"/> is a null reference.</exception>        
		/// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks>    
		public PageLocationCollection(PageLocationCollection collection)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");

			this._array = new PageLocation[collection.Count];
			AddRange(collection);
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="PageLocationCollection"/> class
		/// that contains elements copied from the specified <see cref="PageLocation"/>
		/// array and that has the same initial capacity as the number of elements copied.
		/// </summary>
		/// <param name="array">An <see cref="Array"/> of <see cref="PageLocation"/> 
		/// elements that are copied to the new collection.</param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="array"/> is a null reference.</exception>        
		/// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks>    
		public PageLocationCollection(PageLocation[] array)
		{
			if (array == null)
				throw new ArgumentNullException("array");

			this._array = new PageLocation[array.Length];
			AddRange(array);
		}

		#endregion

		#region Public Properties

		#region Capacity

		/// <summary>
		/// Gets or sets the capacity of the <see cref="PageLocationCollection"/>.
		/// </summary>
		/// <value>The number of elements that the 
		/// <see cref="PageLocationCollection"/> can contain.</value>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <b>Capacity</b> is set to a value that is less than <see cref="Count"/>.</exception>
		/// <remarks>Please refer to <see cref="ArrayList.Capacity"/> for details.</remarks>
		public virtual int Capacity
		{
			get { return this._array.Length; }
			set
			{
				if (value == this._array.Length)
					return;

				if (value < this._count)
					throw new ArgumentOutOfRangeException("Capacity", value, "Value cannot be less than Count.");

				if (value == 0)
				{
					this._array = new PageLocation[_defaultCapacity];
					return;
				}

				PageLocation[] newArray = new PageLocation[value];
				Array.Copy(this._array, newArray, this._count);
				this._array = newArray;
			}
		}

		#endregion

		#region Count

		/// <summary>
		/// Gets the number of elements contained in the <see cref="PageLocationCollection"/>.
		/// </summary>
		/// <value>
		/// The number of elements contained in the <see cref="PageLocationCollection"/>.
		/// </value>
		/// <remarks>Please refer to <see cref="ArrayList.Count"/> for details.</remarks>
		public virtual int Count
		{
			get { return this._count; }
		}

		#endregion

		#region IsFixedSize

		/// <summary>
		/// Gets a value indicating whether the <see cref="PageLocationCollection"/> has a fixed size.
		/// </summary>
		/// <value><c>true</c> if the <see cref="PageLocationCollection"/> has a fixed size;
		/// otherwise, <c>false</c>. The default is <c>false</c>.</value>
		/// <remarks>Please refer to <see cref="ArrayList.IsFixedSize"/> for details.</remarks>
		public virtual bool IsFixedSize
		{
			get { return false; }
		}

		#endregion

		#region IsReadOnly

		/// <summary>
		/// Gets a value indicating whether the <see cref="PageLocationCollection"/> is read-only.
		/// </summary>
		/// <value><c>true</c> if the <see cref="PageLocationCollection"/> is read-only;
		/// otherwise, <c>false</c>. The default is <c>false</c>.</value>
		/// <remarks>Please refer to <see cref="ArrayList.IsReadOnly"/> for details.</remarks>
		public virtual bool IsReadOnly
		{
			get { return false; }
		}

		#endregion

		#region IsSynchronized

		/// <summary>
		/// Gets a value indicating whether access to the <see cref="PageLocationCollection"/> 
		/// is synchronized (thread-safe).
		/// </summary>
		/// <value><c>true</c> if access to the <see cref="PageLocationCollection"/> is 
		/// synchronized (thread-safe); otherwise, <c>false</c>. The default is <c>false</c>.</value>
		/// <remarks>Please refer to <see cref="ArrayList.IsSynchronized"/> for details.</remarks>
		public virtual bool IsSynchronized
		{
			get { return false; }
		}

		#endregion

		#region Item

		/// <summary>
		/// Gets or sets the <see cref="PageLocation"/> element at the specified index.
		/// </summary>
		/// <param name="index">The zero-based index of the 
		/// <see cref="PageLocation"/> element to get or set.</param>
		/// <value>
		/// The <see cref="PageLocation"/> element at the specified <paramref name="index"/>.
		/// </value>    
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="index"/> is less than zero.</para>
		/// <para>-or-</para>
		/// <para><paramref name="index"/> is equal to or greater than <see cref="Count"/>.</para>
		/// </exception>
		/// <exception cref="NotSupportedException">
		/// The property is set and the <see cref="PageLocationCollection"/> is read-only.</exception>
		/// <remarks>Please refer to <see cref="ArrayList.this"/> for details.</remarks>
		public virtual PageLocation this[int index]
		{
			get
			{
				ValidateIndex(index);
				return this._array[index];
			}
			set
			{
				ValidateIndex(index);
				++this._version;
				this._array[index] = value;
			}
		}

		/// <summary>
		/// Gets or sets the element at the specified index.
		/// </summary>
		/// <param name="index">The zero-based index of the element to get or set.</param>
		/// <value>
		/// The element at the specified <paramref name="index"/>. When the property
		/// is set, this value must be compatible with <see cref="PageLocation"/>.
		/// </value>    
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="index"/> is less than zero.</para>
		/// <para>-or-</para>
		/// <para><paramref name="index"/> is equal to or greater than <see cref="Count"/>.</para>
		/// </exception>
		/// <exception cref="InvalidCastException">The property is set to a value
		/// that is not compatible with <see cref="PageLocation"/>.</exception>
		/// <exception cref="NotSupportedException">
		/// The property is set and the <see cref="PageLocationCollection"/> is read-only.</exception>
		/// <remarks>Please refer to <see cref="ArrayList.this"/> for details.</remarks>
		object IList.this[int index]
		{
			get { return this[index]; }
			set { this[index] = (PageLocation) value; }
		}

		#endregion

		#region SyncRoot

		/// <summary>
		/// Gets an object that can be used to synchronize 
		/// access to the <see cref="PageLocationCollection"/>.
		/// </summary>
		/// <value>An object that can be used to synchronize 
		/// access to the <see cref="PageLocationCollection"/>.
		/// </value>
		/// <remarks>Please refer to <see cref="ArrayList.SyncRoot"/> for details.</remarks>
		public virtual object SyncRoot
		{
			get { return this; }
		}

		#endregion

		#endregion

		#region Public Methods

		#region Add    

		/// <summary>
		/// Adds a <see cref="PageLocation"/> to the end of the <see cref="PageLocationCollection"/>.
		/// </summary>
		/// <param name="value">The <see cref="PageLocation"/> object 
		/// to be added to the end of the <see cref="PageLocationCollection"/>.
		/// This argument can be a null reference.
		/// </param>    
		/// <returns>The <see cref="PageLocationCollection"/> index at which the 
		/// <paramref name="value"/> has been added.</returns>
		/// <exception cref="NotSupportedException">
		/// <para>The <see cref="PageLocationCollection"/> is read-only.</para>
		/// <para>-or-</para>
		/// <para>The <b>PageLocationCollection</b> has a fixed size.</para></exception>    
		/// <remarks>Please refer to <see cref="ArrayList.Add"/> for details.</remarks>
		public virtual int Add(PageLocation value)
		{
			if (this._count == this._array.Length)
				EnsureCapacity(this._count + 1);

			++this._version;
			this._array[this._count] = value;
			return this._count++;
		}

		/// <summary>
		/// Adds an <see cref="Object"/> to the end of the <see cref="PageLocationCollection"/>.
		/// </summary>
		/// <param name="value">
		/// The object to be added to the end of the <see cref="PageLocationCollection"/>.
		/// This argument must be compatible with <see cref="PageLocation"/>.
		/// This argument can be a null reference.
		/// </param>    
		/// <returns>The <see cref="PageLocationCollection"/> index at which the 
		/// <paramref name="value"/> has been added.</returns>

⌨️ 快捷键说明

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