home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Software / Freeware / Programare / Sharp / SharpDevelop_1.0.3.1761_Setup.exe / CSharp.Wizards.TypedCollection.xft < prev    next >
Extensible Markup Language  |  2004-11-07  |  11KB  |  297 lines

  1. <?xml version="1.0"?>
  2. <Template author="Mike Krueger" version="1.0">
  3.     
  4.     <Config
  5.         name        = "${res:Templates.File.TypedCollection.Name}"
  6.         icon        = "C#.File.FullFile"
  7.         category    = "C#"
  8.         defaultname = "TypedCollection${Number}.cs"
  9.         language    = "C#"
  10.     />
  11.     
  12.     <Description>${res:Templates.File.TypedCollection.Description}</Description>
  13.     
  14.     <Properties>
  15.         <Property
  16.             name        = "ItemType"
  17.             localizedName = "${res:Templates.File.Properties.TypedCollectionWizard.ItemType}"
  18.             type        = "System.String"
  19.             category    = "${res:Templates.File.Properties.ContextCategory}"
  20.             description = "${res:Templates.File.Properties.TypedCollectionWizard.ItemType.Description}"
  21.         />
  22.         <Property
  23.             name          = "Accessibility"
  24.             localizedName = "${res:Templates.File.Properties.Accessibility}"
  25.             type          = "Types:Accessibility"
  26.             category      = "${res:Templates.File.Properties.OptionCategory}"
  27.             defaultValue  = "public"
  28.             description   = "${res:Templates.File.Properties.Accessibility.Description}"
  29.         />
  30.         <Property
  31.             name          = "GenerateDocumentation"
  32.             localizedName = "${res:Templates.File.Properties.GenerateDocumentation}"
  33.             type          = "System.Boolean"
  34.             category      = "${res:Templates.File.Properties.OptionCategory}"
  35.             defaultValue  = "True"
  36.             description   = "${res:Templates.File.Properties.GenerateDocumentation}"
  37.         />
  38.     </Properties>
  39.     
  40.     <Types>
  41.         <Type name = "Accessibility">
  42.             <Enum name = "Public" value = "public"/>
  43.             <Enum name = "Protected" value = "protected"/>
  44.             <Enum name = "Private" value = "private"/>
  45.             <Enum name = "Internal" value = "internal"/>
  46.             <Enum name = "Protected Internal" value = "protected internal"/>
  47.             <Enum name = "Internal Protected" value = "internal protected"/>
  48.         </Type>
  49.     </Types>
  50.     
  51.     <!-- 
  52.     Special new file templates:
  53.         ${StandardNamespace}        -> Standardnamespace of the current project or FileNameWithoutExtension
  54.         ${FullName}                 -> Full generated path name
  55.         ${FileName}                 -> File name with extension
  56.         ${FileNameWithoutExtension} -> File name without extension
  57.         ${Extension}                -> Extension in the form ".cs"
  58.         ${Path}                     -> Full path of the file
  59.      -->
  60.     <Files>
  61.         <File name="${FullName}" language="C#"><![CDATA[${StandardHeader.C#}
  62.  
  63. using System;
  64. using System.Collections;
  65.  
  66. namespace ${StandardNamespace}
  67. {
  68. <%if (GenerateDocumentation) {%>    /// <summary>
  69.     ///   A collection that stores <see cref='${Properties.ItemType}'/> objects.
  70.     /// </summary>
  71. <%}%>    [Serializable()]
  72.     ${Properties.Accessibility} class ${ClassName} : CollectionBase {
  73.         
  74. <%if (GenerateDocumentation) {%>        /// <summary>
  75.         ///   Initializes a new instance of <see cref='${ClassName}'/>.
  76.         /// </summary>
  77. <%}%>        public ${ClassName}()
  78.         {
  79.         }
  80.         
  81. <%if (GenerateDocumentation) {%>        /// <summary>
  82.         ///   Initializes a new instance of <see cref='${ClassName}'/> based on another <see cref='${ClassName}'/>.
  83.         /// </summary>
  84.         /// <param name='val'>
  85.         ///   A <see cref='${ClassName}'/> from which the contents are copied
  86.         /// </param>
  87. <%}%>        public ${ClassName}(${ClassName} val)
  88.         {
  89.             this.AddRange(val);
  90.         }
  91.         
  92. <%if (GenerateDocumentation) {%>        /// <summary>
  93.         ///   Initializes a new instance of <see cref='${ClassName}'/> containing any array of <see cref='${Properties.ItemType}'/> objects.
  94.         /// </summary>
  95.         /// <param name='val'>
  96.         ///       A array of <see cref='${Properties.ItemType}'/> objects with which to intialize the collection
  97.         /// </param>
  98. <%}%>        public ${ClassName}(${Properties.ItemType}[] val)
  99.         {
  100.             this.AddRange(val);
  101.         }
  102.         
  103. <%if (GenerateDocumentation) {%>        /// <summary>
  104.         ///   Represents the entry at the specified index of the <see cref='${Properties.ItemType}'/>.
  105.         /// </summary>
  106.         /// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
  107.         /// <value>The entry at the specified index of the collection.</value>
  108.         /// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
  109. <%}%>        public ${Properties.ItemType} this[int index] {
  110.             get {
  111.                 return ((${Properties.ItemType})(List[index]));
  112.             }
  113.             set {
  114.                 List[index] = value;
  115.             }
  116.         }
  117.         
  118. <%if (GenerateDocumentation) {%>        /// <summary>
  119.         ///   Adds a <see cref='${Properties.ItemType}'/> with the specified value to the 
  120.         ///   <see cref='${ClassName}'/>.
  121.         /// </summary>
  122.         /// <param name='val'>The <see cref='${Properties.ItemType}'/> to add.</param>
  123.         /// <returns>The index at which the new element was inserted.</returns>
  124.         /// <seealso cref='${ClassName}.AddRange'/>
  125. <%}%>        public int Add(${Properties.ItemType} val)
  126.         {
  127.             return List.Add(val);
  128.         }
  129.         
  130. <%if (GenerateDocumentation) {%>        /// <summary>
  131.         ///   Copies the elements of an array to the end of the <see cref='${ClassName}'/>.
  132.         /// </summary>
  133.         /// <param name='val'>
  134.         ///    An array of type <see cref='${Properties.ItemType}'/> containing the objects to add to the collection.
  135.         /// </param>
  136.         /// <seealso cref='${ClassName}.Add'/>
  137. <%}%>        public void AddRange(${Properties.ItemType}[] val)
  138.         {
  139.             for (int i = 0; i < val.Length; i++) {
  140.                 this.Add(val[i]);
  141.             }
  142.         }
  143.         
  144. <%if (GenerateDocumentation) {%>        /// <summary>
  145.         ///   Adds the contents of another <see cref='${ClassName}'/> to the end of the collection.
  146.         /// </summary>
  147.         /// <param name='val'>
  148.         ///    A <see cref='${ClassName}'/> containing the objects to add to the collection.
  149.         /// </param>
  150.         /// <seealso cref='${ClassName}.Add'/>
  151. <%}%>        public void AddRange(${ClassName} val)
  152.         {
  153.             for (int i = 0; i < val.Count; i++)
  154.             {
  155.                 this.Add(val[i]);
  156.             }
  157.         }
  158.         
  159. <%if (GenerateDocumentation) {%>        /// <summary>
  160.         ///   Gets a value indicating whether the 
  161.         ///    <see cref='${ClassName}'/> contains the specified <see cref='${Properties.ItemType}'/>.
  162.         /// </summary>
  163.         /// <param name='val'>The <see cref='${Properties.ItemType}'/> to locate.</param>
  164.         /// <returns>
  165.         /// <see langword='true'/> if the <see cref='${Properties.ItemType}'/> is contained in the collection; 
  166.         ///   otherwise, <see langword='false'/>.
  167.         /// </returns>
  168.         /// <seealso cref='${ClassName}.IndexOf'/>
  169. <%}%>        public bool Contains(${Properties.ItemType} val)
  170.         {
  171.             return List.Contains(val);
  172.         }
  173.         
  174. <%if (GenerateDocumentation) {%>        /// <summary>
  175.         ///   Copies the <see cref='${ClassName}'/> values to a one-dimensional <see cref='Array'/> instance at the 
  176.         ///    specified index.
  177.         /// </summary>
  178.         /// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='${ClassName}'/>.</param>
  179.         /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
  180.         /// <exception cref='ArgumentException'>
  181.         ///   <para><paramref name='array'/> is multidimensional.</para>
  182.         ///   <para>-or-</para>
  183.         ///   <para>The number of elements in the <see cref='${ClassName}'/> is greater than
  184.         ///         the available space between <paramref name='arrayIndex'/> and the end of
  185.         ///         <paramref name='array'/>.</para>
  186.         /// </exception>
  187.         /// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
  188.         /// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
  189.         /// <seealso cref='Array'/>
  190. <%}%>        public void CopyTo(${Properties.ItemType}[] array, int index)
  191.         {
  192.             List.CopyTo(array, index);
  193.         }
  194.         
  195. <%if (GenerateDocumentation) {%>        /// <summary>
  196.         ///    Returns the index of a <see cref='${Properties.ItemType}'/> in 
  197.         ///       the <see cref='${ClassName}'/>.
  198.         /// </summary>
  199.         /// <param name='val'>The <see cref='${Properties.ItemType}'/> to locate.</param>
  200.         /// <returns>
  201.         ///   The index of the <see cref='${Properties.ItemType}'/> of <paramref name='val'/> in the 
  202.         ///   <see cref='${ClassName}'/>, if found; otherwise, -1.
  203.         /// </returns>
  204.         /// <seealso cref='${ClassName}.Contains'/>
  205. <%}%>        public int IndexOf(${Properties.ItemType} val)
  206.         {
  207.             return List.IndexOf(val);
  208.         }
  209.         
  210. <%if (GenerateDocumentation) {%>        /// <summary>
  211.         ///   Inserts a <see cref='${Properties.ItemType}'/> into the <see cref='${ClassName}'/> at the specified index.
  212.         /// </summary>
  213.         /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
  214.         /// <param name='val'>The <see cref='${Properties.ItemType}'/> to insert.</param>
  215.         /// <seealso cref='${ClassName}.Add'/>
  216. <%}%>        public void Insert(int index, ${Properties.ItemType} val)
  217.         {
  218.             List.Insert(index, val);
  219.         }
  220.         
  221. <%if (GenerateDocumentation) {%>        /// <summary>
  222.         ///  Returns an enumerator that can iterate through the <see cref='${ClassName}'/>.
  223.         /// </summary>
  224.         /// <seealso cref='IEnumerator'/>
  225. <%}%>        public new ${Properties.ItemType}Enumerator GetEnumerator()
  226.         {
  227.             return new ${Properties.ItemType}Enumerator(this);
  228.         }
  229.         
  230. <%if (GenerateDocumentation) {%>        /// <summary>
  231.         ///   Removes a specific <see cref='${Properties.ItemType}'/> from the <see cref='${ClassName}'/>.
  232.         /// </summary>
  233.         /// <param name='val'>The <see cref='${Properties.ItemType}'/> to remove from the <see cref='${ClassName}'/>.</param>
  234.         /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
  235. <%}%>        public void Remove(${Properties.ItemType} val)
  236.         {
  237.             List.Remove(val);
  238.         }
  239.         
  240. <%if (GenerateDocumentation) {%>        /// <summary>
  241.         ///   Enumerator that can iterate through a ${ClassName}.
  242.         /// </summary>
  243.         /// <seealso cref='IEnumerator'/>
  244.         /// <seealso cref='${ClassName}'/>
  245.         /// <seealso cref='${Properties.ItemType}'/>
  246. <%}%>        public class ${Properties.ItemType}Enumerator : IEnumerator
  247.         {
  248.             IEnumerator baseEnumerator;
  249.             IEnumerable temp;
  250.             
  251. <%if (GenerateDocumentation) {%>            /// <summary>
  252.             ///   Initializes a new instance of <see cref='${Properties.ItemType}Enumerator'/>.
  253.             /// </summary>
  254. <%}%>            public ${Properties.ItemType}Enumerator(${ClassName} mappings)
  255.             {
  256.                 this.temp = ((IEnumerable)(mappings));
  257.                 this.baseEnumerator = temp.GetEnumerator();
  258.             }
  259.             
  260. <%if (GenerateDocumentation) {%>            /// <summary>
  261.             ///   Gets the current <see cref='${Properties.ItemType}'/> in the <seealso cref='${ClassName}'/>.
  262.             /// </summary>
  263. <%}%>            public ${Properties.ItemType} Current {
  264.                 get {
  265.                     return ((${Properties.ItemType})(baseEnumerator.Current));
  266.                 }
  267.             }
  268.             
  269.             object IEnumerator.Current {
  270.                 get {
  271.                     return baseEnumerator.Current;
  272.                 }
  273.             }
  274.             
  275. <%if (GenerateDocumentation) {%>            /// <summary>
  276.             ///   Advances the enumerator to the next <see cref='${Properties.ItemType}'/> of the <see cref='${ClassName}'/>.
  277.             /// </summary>
  278. <%}%>            public bool MoveNext()
  279.             {
  280.                 return baseEnumerator.MoveNext();
  281.             }
  282.             
  283. <%if (GenerateDocumentation) {%>            /// <summary>
  284.             ///   Sets the enumerator to its initial position, which is before the first element in the <see cref='${ClassName}'/>.
  285.             /// </summary>
  286. <%}%>            public void Reset()
  287.             {
  288.                 baseEnumerator.Reset();
  289.             }
  290.         }
  291.     }
  292. }]]></File>
  293.     </Files>
  294.     
  295.     <AdditionalOptions/>
  296. </Template>
  297.