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

📄 csharp.wizards.typedcollection.xft

📁 c#源代码
💻 XFT
字号:
<?xml version="1.0"?>
<Template author="Mike Krueger" version="1.0">
	
	<Config
		name        = "${res:Templates.File.TypedCollection.Name}"
		icon        = "C#.File.FullFile"
		category    = "C#"
		defaultname = "TypedCollection${Number}.cs"
		language    = "C#"
	/>
	
	<Description>${res:Templates.File.TypedCollection.Description}</Description>
	
	<Properties>
		<Property
			name        = "ItemType"
			localizedName = "${res:Templates.File.Properties.TypedCollectionWizard.ItemType}"
			type        = "System.String"
			category    = "${res:Templates.File.Properties.ContextCategory}"
			description = "${res:Templates.File.Properties.TypedCollectionWizard.ItemType.Description}"
		/>
		<Property
			name          = "Accessibility"
			localizedName = "${res:Templates.File.Properties.Accessibility}"
			type          = "Types:Accessibility"
			category      = "${res:Templates.File.Properties.OptionCategory}"
			defaultValue  = "public"
			description   = "${res:Templates.File.Properties.Accessibility.Description}"
		/>
		<Property
			name          = "GenerateDocumentation"
			localizedName = "${res:Templates.File.Properties.GenerateDocumentation}"
			type          = "System.Boolean"
			category      = "${res:Templates.File.Properties.OptionCategory}"
			defaultValue  = "True"
			description   = "${res:Templates.File.Properties.GenerateDocumentation}"
		/>
	</Properties>
	
	<Types>
		<Type name = "Accessibility">
			<Enum name = "Public" value = "public"/>
			<Enum name = "Protected" value = "protected"/>
			<Enum name = "Private" value = "private"/>
			<Enum name = "Internal" value = "internal"/>
			<Enum name = "Protected Internal" value = "protected internal"/>
			<Enum name = "Internal Protected" value = "internal protected"/>
		</Type>
	</Types>
	
	<!-- 
	Special new file templates:
		${StandardNamespace}        -> Standardnamespace of the current project or FileNameWithoutExtension
		${FullName}                 -> Full generated path name
		${FileName}                 -> File name with extension
		${FileNameWithoutExtension} -> File name without extension
		${Extension}                -> Extension in the form ".cs"
		${Path}                     -> Full path of the file
	 -->
	<Files>
		<File name="${FullName}" language="C#"><![CDATA[${StandardHeader.C#}

using System;
using System.Collections;

namespace ${StandardNamespace}
{
<%if (GenerateDocumentation) {%>	/// <summary>
	///   A collection that stores <see cref='${Properties.ItemType}'/> objects.
	/// </summary>
<%}%>	[Serializable()]
	${Properties.Accessibility} class ${ClassName} : CollectionBase {
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Initializes a new instance of <see cref='${ClassName}'/>.
		/// </summary>
<%}%>		public ${ClassName}()
		{
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Initializes a new instance of <see cref='${ClassName}'/> based on another <see cref='${ClassName}'/>.
		/// </summary>
		/// <param name='val'>
		///   A <see cref='${ClassName}'/> from which the contents are copied
		/// </param>
<%}%>		public ${ClassName}(${ClassName} val)
		{
			this.AddRange(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Initializes a new instance of <see cref='${ClassName}'/> containing any array of <see cref='${Properties.ItemType}'/> objects.
		/// </summary>
		/// <param name='val'>
		///       A array of <see cref='${Properties.ItemType}'/> objects with which to intialize the collection
		/// </param>
<%}%>		public ${ClassName}(${Properties.ItemType}[] val)
		{
			this.AddRange(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Represents the entry at the specified index of the <see cref='${Properties.ItemType}'/>.
		/// </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 ${Properties.ItemType} this[int index] {
			get {
				return ((${Properties.ItemType})(List[index]));
			}
			set {
				List[index] = value;
			}
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Adds a <see cref='${Properties.ItemType}'/> with the specified value to the 
		///   <see cref='${ClassName}'/>.
		/// </summary>
		/// <param name='val'>The <see cref='${Properties.ItemType}'/> to add.</param>
		/// <returns>The index at which the new element was inserted.</returns>
		/// <seealso cref='${ClassName}.AddRange'/>
<%}%>		public int Add(${Properties.ItemType} val)
		{
			return List.Add(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Copies the elements of an array to the end of the <see cref='${ClassName}'/>.
		/// </summary>
		/// <param name='val'>
		///    An array of type <see cref='${Properties.ItemType}'/> containing the objects to add to the collection.
		/// </param>
		/// <seealso cref='${ClassName}.Add'/>
<%}%>		public void AddRange(${Properties.ItemType}[] val)
		{
			for (int i = 0; i < val.Length; i++) {
				this.Add(val[i]);
			}
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Adds the contents of another <see cref='${ClassName}'/> to the end of the collection.
		/// </summary>
		/// <param name='val'>
		///    A <see cref='${ClassName}'/> containing the objects to add to the collection.
		/// </param>
		/// <seealso cref='${ClassName}.Add'/>
<%}%>		public void AddRange(${ClassName} val)
		{
			for (int i = 0; i < val.Count; i++)
			{
				this.Add(val[i]);
			}
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Gets a value indicating whether the 
		///    <see cref='${ClassName}'/> contains the specified <see cref='${Properties.ItemType}'/>.
		/// </summary>
		/// <param name='val'>The <see cref='${Properties.ItemType}'/> to locate.</param>
		/// <returns>
		/// <see langword='true'/> if the <see cref='${Properties.ItemType}'/> is contained in the collection; 
		///   otherwise, <see langword='false'/>.
		/// </returns>
		/// <seealso cref='${ClassName}.IndexOf'/>
<%}%>		public bool Contains(${Properties.ItemType} val)
		{
			return List.Contains(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Copies the <see cref='${ClassName}'/> 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='${ClassName}'/>.</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='${ClassName}'/> 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(${Properties.ItemType}[] array, int index)
		{
			List.CopyTo(array, index);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///    Returns the index of a <see cref='${Properties.ItemType}'/> in 
		///       the <see cref='${ClassName}'/>.
		/// </summary>
		/// <param name='val'>The <see cref='${Properties.ItemType}'/> to locate.</param>
		/// <returns>
		///   The index of the <see cref='${Properties.ItemType}'/> of <paramref name='val'/> in the 
		///   <see cref='${ClassName}'/>, if found; otherwise, -1.
		/// </returns>
		/// <seealso cref='${ClassName}.Contains'/>
<%}%>		public int IndexOf(${Properties.ItemType} val)
		{
			return List.IndexOf(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Inserts a <see cref='${Properties.ItemType}'/> into the <see cref='${ClassName}'/> 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='${Properties.ItemType}'/> to insert.</param>
		/// <seealso cref='${ClassName}.Add'/>
<%}%>		public void Insert(int index, ${Properties.ItemType} val)
		{
			List.Insert(index, val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///  Returns an enumerator that can iterate through the <see cref='${ClassName}'/>.
		/// </summary>
		/// <seealso cref='IEnumerator'/>
<%}%>		public new ${Properties.ItemType}Enumerator GetEnumerator()
		{
			return new ${Properties.ItemType}Enumerator(this);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Removes a specific <see cref='${Properties.ItemType}'/> from the <see cref='${ClassName}'/>.
		/// </summary>
		/// <param name='val'>The <see cref='${Properties.ItemType}'/> to remove from the <see cref='${ClassName}'/>.</param>
		/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
<%}%>		public void Remove(${Properties.ItemType} val)
		{
			List.Remove(val);
		}
		
<%if (GenerateDocumentation) {%>		/// <summary>
		///   Enumerator that can iterate through a ${ClassName}.
		/// </summary>
		/// <seealso cref='IEnumerator'/>
		/// <seealso cref='${ClassName}'/>
		/// <seealso cref='${Properties.ItemType}'/>
<%}%>		public class ${Properties.ItemType}Enumerator : IEnumerator
		{
			IEnumerator baseEnumerator;
			IEnumerable temp;
			
<%if (GenerateDocumentation) {%>			/// <summary>
			///   Initializes a new instance of <see cref='${Properties.ItemType}Enumerator'/>.
			/// </summary>
<%}%>			public ${Properties.ItemType}Enumerator(${ClassName} mappings)
			{
				this.temp = ((IEnumerable)(mappings));
				this.baseEnumerator = temp.GetEnumerator();
			}
			
<%if (GenerateDocumentation) {%>			/// <summary>
			///   Gets the current <see cref='${Properties.ItemType}'/> in the <seealso cref='${ClassName}'/>.
			/// </summary>
<%}%>			public ${Properties.ItemType} Current {
				get {
					return ((${Properties.ItemType})(baseEnumerator.Current));
				}
			}
			
			object IEnumerator.Current {
				get {
					return baseEnumerator.Current;
				}
			}
			
<%if (GenerateDocumentation) {%>			/// <summary>
			///   Advances the enumerator to the next <see cref='${Properties.ItemType}'/> of the <see cref='${ClassName}'/>.
			/// </summary>
<%}%>			public bool MoveNext()
			{
				return baseEnumerator.MoveNext();
			}
			
<%if (GenerateDocumentation) {%>			/// <summary>
			///   Sets the enumerator to its initial position, which is before the first element in the <see cref='${ClassName}'/>.
			/// </summary>
<%}%>			public void Reset()
			{
				baseEnumerator.Reset();
			}
		}
	}
}]]></File>
	</Files>
	
	<AdditionalOptions/>
</Template>

⌨️ 快捷键说明

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