Here are the changes needed in order to add extension objects to the style task. This change consists of three files:
NAnt.Core\Tasks\StyleTask.cs - modified (I've also included a diff file against the original source) NAnt.Core\Types\XsltExtensionObjectCollection.cs - new NAnt.Core\Types\XsltExtensionObject.cs - new I've also fixed what appeared to be an error with handling the "if" and "unless" attributes of the XsltParameter objects. Sorry that I missed the 0.85 RC1 release, but hope this is useful in any case. Tim On Wed, 24 Nov 2004 18:59:43 +0000, Tim Noll <[EMAIL PROTECTED]> wrote: > OK, I'll post the code in the next few days, as soon as I have a > chance to make sure it works against the 0.85 code base. And, yes, > extension objects will have to have a default parameterless > constructor for now. > > Regards, > > Tim > > > > > On Mon, 22 Nov 2004 12:11:27 +0900, Ian MacLean <[EMAIL PROTECTED]> wrote: > > Tim Noll wrote: > > > > > > > > >I'd like to propose adding extension objects to the style task. More > > >information about extension objects can be found here: > > >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconXsltArgumentListForStylesheetParametersExtensionObjects.asp > > > > > >The build file task would look like this: > > ><style style="style.xsl" in="in.xml" out="out.xml"> > > > <extensionobjects> > > > <extensionobject namespaceuri="urn:CustomParser" > > >type="XsltExtensions.CustomParser" assembly="XsltExtensions.dll" /> > > > </extensionobjects> > > ></style> > > > > > >I believe this should be part of core NAnt rather than NAntContrib, as > > >the style task already supports parameters via the internal use of an > > >XsltArgumentList. Extension objects are the other major feature of > > >argument lists, so incorporating them as well is a logical step. > > > > > >The use of extension objects in place of script blocks also addresses > > >a known memory leak. See http://support.microsoft.com/kb/316775/ and > > >http://support.microsoft.com/kb/325689/#6 for details. > > > > > >I've previously written code to to do this for the 0.84 code base and > > >would be glad to update it for use with 0.85. Please let me know what > > >you think. > > > > > > > > > > > Sounds good Tim. I assume that the custom extension classes must have a > > null paramater constructor for your code to be able to instantiate them > > and pass them to XslStylesheet. I wrote somthing similar as part of > > another project. Please post the code and someone one will take a looks > > at it with a view to inclusion. > > > > Ian > > > > >Tim > > > > > > > > >------------------------------------------------------- > > >This SF.Net email is sponsored by: InterSystems CACHE > > >FREE OODBMS DOWNLOAD - A multidimensional database that combines > > >robust object and relational technologies, making it a perfect match > > >for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8 > > >_______________________________________________ > > >nant-developers mailing list > > >[EMAIL PROTECTED] > > >https://lists.sourceforge.net/lists/listinfo/nant-developers > > > > > > > > > > >
// NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Serge ([EMAIL PROTECTED]) // Gerry Shaw ([EMAIL PROTECTED]) // Scott Hernandez ([EMAIL PROTECTED]) // Tim Noll ([EMAIL PROTECTED]) using System; using System.Collections; using System.Collections.Specialized; using System.Globalization; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; using NAnt.Core.Attributes; using NAnt.Core.Types; using NAnt.Core.Util; namespace NAnt.Core.Tasks { /// <summary> /// Processes a document via XSLT. /// </summary> /// <example> /// <para>Create a report in HTML.</para> /// <code> /// <![CDATA[ /// <style style="report.xsl" in="data.xml" out="report.html" /> /// ]]> /// </code> /// </example> /// <example> /// <para>Create a report in HTML, with a param.</para> /// <code> /// <![CDATA[ /// <style style="report.xsl" in="data.xml" out="report.html"> /// <parameters> /// <parameter name="reportType" namespaceuri="" value="Plain" /> /// </parameters> /// </style> /// ]]> /// </code> /// </example> /// <example> /// <para>Create a report in HTML, with a expanded param.</para> /// <code> /// <![CDATA[ /// <style style="report.xsl" in="data.xml" out="report.html"> /// <parameters> /// <parameter name="reportType" namespaceuri="" value="${report.type}" /> /// </parameters> /// </style> /// ]]> /// </code> /// </example> /// <example> /// <para>Create some code based on a directory of templates.</para> /// <code> /// <![CDATA[ /// <style style="CodeGenerator.xsl" extension="java"> /// <infiles> /// <include name="*.xml" /> /// </infiles> /// <parameters> /// <parameter name="reportType" namespaceuri="" value="Plain" if="${report.plain}" /> /// </parameters> /// <style> /// ]]> /// </code> /// </example> /// <example> /// <para>Create a report in HTML, with an extension object.</para> /// <code> /// <![CDATA[ /// <style style="report.xsl" in="data.xml" out="report.html"> /// <extensionobjects> /// <extensionobject namespaceuri="urn:Formatter" typename="XsltExtensionObjects.Formatter" assembly="XsltExtensionObjects.dll" /> /// </extensionobjects> /// </style> /// ]]> /// </code> /// </example> [TaskName("style")] public class StyleTask : Task { #region Private Instance Fields private DirectoryInfo _destDir; private string _extension = "html"; private FileInfo _xsltFile; private FileInfo _srcFile; private FileInfo _outputFile; private FileSet _inFiles = new FileSet(); private XsltParameterCollection _xsltParameters = new XsltParameterCollection(); private XsltExtensionObjectCollection _xsltExtensions = new XsltExtensionObjectCollection(); #endregion Private Instance Fields #region Public Instance Properties /// <summary> /// Directory in which to store the results. The default is the project /// base directory. /// </summary> [TaskAttribute("destdir", Required=false)] public DirectoryInfo DestDir { get { if (_destDir == null) { return new DirectoryInfo(Project.BaseDirectory); } return _destDir; } set { _destDir = value; } } /// <summary> /// Desired file extension to be used for the targets. The default is /// <c>html</c>. /// </summary> [TaskAttribute("extension", Required=false)] public string Extension { get { return _extension; } set { _extension = value; } } /// <summary> /// Name of the stylesheet to use - given either relative to the project's /// basedir or as an absolute path. /// </summary> [TaskAttribute("style", Required=true)] public FileInfo XsltFile { get { return _xsltFile; } set { _xsltFile = value; } } /// <summary> /// Specifies a single XML document to be styled. Should be used with /// the <see cref="OutputFile" /> attribute. /// </summary> [TaskAttribute("in", Required=false)] public FileInfo SrcFile { get { return _srcFile; } set { _srcFile = value; } } /// <summary> /// Specifies the output name for the styled result from the <see cref="SrcFile" /> /// attribute. /// </summary> [TaskAttribute("out", Required=false)] public FileInfo OutputFile { get { return _outputFile; } set { _outputFile = value; } } /// <summary> /// Specifies a group of input files to which to apply the stylesheet. /// </summary> [BuildElement("infiles")] public FileSet InFiles { get { return _inFiles; } set { _inFiles = value; } } /// <summary> /// XSLT parameters to be passed to the XSLT transformation. /// </summary> [BuildElementCollection("parameters", "parameter")] public XsltParameterCollection Parameters { get { return _xsltParameters; } } /// <summary> /// XSLT extension objects to be passed to the XSLT transformation. /// </summary> [BuildElementCollection("extensionobjects", "extensionobject")] public XsltExtensionObjectCollection ExtensionObjects { get { return _xsltExtensions; } } #endregion Public Instance Properties #region Override implementation of Task protected override void InitializeTask(XmlNode taskNode) { // deprecated as of NAnt 0.8.4 // TO-DO : remove this after NAnt 0.8.5 or so // Load parameters foreach (XmlNode node in taskNode) { if (node.LocalName.Equals("param")) { Log(Level.Warning, "The usage of the <param> element is" + " deprecated. Please use the <parameters> collection" + " instead."); // create and fill XsltParameter XsltParameter xsltParameter = new XsltParameter(); xsltParameter.ParameterName = Project.ExpandProperties(node.Attributes["name"].Value, Location); xsltParameter.Value = Project.ExpandProperties(node.Attributes["expression"].Value, Location); // add parameter to collection _xsltParameters.Add(xsltParameter); } } } protected override void ExecuteTask() { // ensure base directory is set, even if fileset was not initialized // from XML if (InFiles.BaseDirectory == null) { InFiles.BaseDirectory = new DirectoryInfo(Project.BaseDirectory); } StringCollection srcFiles = null; if (SrcFile != null) { srcFiles = new StringCollection(); srcFiles.Add(SrcFile.FullName); } else if (InFiles.FileNames.Count > 0) { if (OutputFile != null) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "The \"out\" attribute is not allowed when \"infiles\" is used."), Location); } srcFiles = InFiles.FileNames; } if (srcFiles == null || srcFiles.Count == 0) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "No source files indicated; use \"in\" or \"infiles\"."), Location); } if (!XsltFile.Exists) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Stylesheet file '{0}' does not exist.", XsltFile.FullName), Location); } foreach (string srcFile in srcFiles) { string destFile = null; if (OutputFile != null) { destFile = OutputFile.FullName; } if (StringUtils.IsNullOrEmpty(destFile)) { // TODO: use System.IO.Path (gs) // append extension if necessary string ext = Extension.IndexOf(".") > -1 ? Extension : "." + Extension; int extPos = srcFile.LastIndexOf('.'); if (extPos == -1) { destFile = srcFile + ext; } else { destFile = srcFile.Substring(0, extPos) + ext; } destFile = Path.GetFileName(destFile); } FileInfo srcInfo = new FileInfo(srcFile); FileInfo destInfo = new FileInfo(Path.GetFullPath(Path.Combine( DestDir.FullName, destFile))); if (!srcInfo.Exists) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Unable to find source XML file '{0}'.", srcInfo.FullName), Location); } bool destOutdated = !destInfo.Exists || srcInfo.LastWriteTime > destInfo.LastWriteTime || XsltFile.LastWriteTime > destInfo.LastWriteTime; if (destOutdated) { XmlReader xmlReader = null; XmlReader xslReader = null; TextWriter writer = null; try { // store current directory string originalCurrentDirectory = Directory.GetCurrentDirectory(); // initialize XPath document holding input XML XPathDocument xml = null; try { // change current directory to directory containing // XSLT file, to allow includes to be resolved // correctly Directory.SetCurrentDirectory(srcInfo.DirectoryName); // load the xml that needs to be transformed Log(Level.Verbose, "Loading XML file '{0}'.", srcInfo.FullName); xmlReader = CreateXmlReader(srcInfo.FullName); xml = new XPathDocument(xmlReader); } finally { // restore original current directory Directory.SetCurrentDirectory(originalCurrentDirectory); } // initialize XSLT transform XslTransform xslt = new XslTransform(); try { // change current directory to directory containing // XSLT file, to allow includes to be resolved // correctly Directory.SetCurrentDirectory(XsltFile.DirectoryName); // load the stylesheet Log(Level.Verbose, "Loading stylesheet '{0}'.", XsltFile.FullName); xslReader = CreateXmlReader(XsltFile.FullName); xslt.Load(xslReader); } finally { // restore original current directory Directory.SetCurrentDirectory(originalCurrentDirectory); } // initialize xslt parameters XsltArgumentList xsltArgs = new XsltArgumentList(); // set the xslt parameters foreach (XsltParameter parameter in Parameters) { if (parameter.IfDefined && !parameter.UnlessDefined) { xsltArgs.AddParam(parameter.ParameterName, parameter.NamespaceUri, parameter.Value); } } // create extension objects foreach (XsltExtensionObject extensionObject in ExtensionObjects) { if (extensionObject.IfDefined && !extensionObject.UnlessDefined) { object extensionInstance = extensionObject.CreateInstance(); xsltArgs.AddExtensionObject(extensionObject.NamespaceUri, extensionInstance); } } // create writer for the destination xml writer = CreateWriter(destInfo.FullName); // do the actual transformation Log(Level.Info, "Processing '{0}' to '{1}'.", srcInfo.FullName, destInfo.FullName); xslt.Transform(xml, xsltArgs, writer); } catch (Exception ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Could not perform XSLT transformation of '{0}' using" + " stylesheet '{1}'.", srcInfo.FullName, XsltFile.FullName), Location, ex); } finally { // ensure file handles are closed if (xmlReader != null) { xmlReader.Close(); } if (xslReader != null) { xslReader.Close(); } if (writer != null) { writer.Close(); } } } } } #endregion Override implementation of Task #region Protected Instance Methods protected virtual XmlReader CreateXmlReader(string file) { XmlTextReader xmlReader = new XmlTextReader(new FileStream(file, FileMode.Open, FileAccess.Read)); return xmlReader; } protected virtual TextWriter CreateWriter(string filepath) { string xmlPath = filepath; TextWriter writer = null; string targetDir = Path.GetDirectoryName(Path.GetFullPath(xmlPath)); if (!StringUtils.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } // UTF-8 encoding will be used //xmlWriter = new XmlTextWriter(xmlPath, null); // Create text writer first writer = new StreamWriter(xmlPath); return writer; } #endregion Protected Instance Methods } }
21d20 < // Tim Noll ([EMAIL PROTECTED]) 87,98d85 < /// <example> < /// <para>Create a report in HTML, with an extension object.</para> < /// <code> < /// <![CDATA[ < /// <style style="report.xsl" in="data.xml" out="report.html"> < /// <extensionobjects> < /// <extensionobject namespaceuri="urn:Formatter" typename="XsltExtensionObjects.Formatter" assembly="XsltExtensionObjects.dll" /> < /// </extensionobjects> < /// </style> < /// ]]> < /// </code> < /// </example> 110d96 < private XsltExtensionObjectCollection _xsltExtensions = new XsltExtensionObjectCollection(); 188,195d173 < /// <summary> < /// XSLT extension objects to be passed to the XSLT transformation. < /// </summary> < [BuildElementCollection("extensionobjects", "extensionobject")] < public XsltExtensionObjectCollection ExtensionObjects { < get { return _xsltExtensions; } < } < 339c317 < if (parameter.IfDefined && !parameter.UnlessDefined) { --- > if (IfDefined && !UnlessDefined) { 345,353d322 < // create extension objects < foreach (XsltExtensionObject extensionObject in ExtensionObjects) { < if (extensionObject.IfDefined && !extensionObject.UnlessDefined) { < object extensionInstance = extensionObject.CreateInstance(); < xsltArgs.AddExtensionObject(extensionObject.NamespaceUri, < extensionInstance); < } < } <
// NAnt - A .NET build tool // Copyright (C) 2001-2003 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gert Driesen ([EMAIL PROTECTED]) // Tim Noll ([EMAIL PROTECTED]) using System; using System.Collections; using System.Globalization; using System.IO; using System.Reflection; using NAnt.Core.Attributes; using NAnt.Core.Util; namespace NAnt.Core.Types { /// <summary> /// Represents an XSLT extension object. The object should have a default /// parameterless constructor and the return value should be one of the /// four basic XPath data types of number, string, Boolean or node set. /// </summary> [ElementName("xsltextensionobject")] public class XsltExtensionObject : Element { #region Private Instance Fields private string _namespaceUri = string.Empty; private string _typeName; private FileInfo _assemblyPath; private bool _ifDefined = true; private bool _unlessDefined; #endregion Private Instance Fields #region Public Instance Constructors /// <summary> /// Initializes a new instance of the <see cref="XsltExtensionObject" /> /// class. /// </summary> public XsltExtensionObject() { } #endregion Public Instance Constructors #region Public Instance Properties /// <summary> /// The namespace URI to associate with the extension object. /// </summary> /// <value> /// The namespace URI to associate with the extension object, or /// <see cref="string.Empty" /> if not set. /// </value> [TaskAttribute("namespaceuri")] public string NamespaceUri { get { return _namespaceUri; } set { _namespaceUri = value; } } /// <summary> /// The full type name of the XSLT extension object. /// </summary> [TaskAttribute("typename", Required=true)] [StringValidator(AllowEmpty=false)] public string TypeName { get { return _typeName; } set { _typeName = value; } } /// <summary> /// The assembly which contains the XSLT extension object. /// </summary> [TaskAttribute("assembly", Required=true)] [StringValidator(AllowEmpty=false)] public FileInfo AssemblyPath { get { return _assemblyPath; } set { _assemblyPath = value; } } /// <summary> /// Indicates if the extension object should be added to the XSLT argument /// list. If <see langword="true" /> then the extension object will be /// added; otherwise, skipped. The default is <see langword="true" />. /// </summary> [TaskAttribute("if")] [BooleanValidator()] public bool IfDefined { get { return _ifDefined; } set { _ifDefined = value; } } /// <summary> /// Indicates if the extension object should not be added to the XSLT argument /// list. If <see langword="false" /> then the extension object will be /// added; otherwise, skipped. The default is <see langword="false" />. /// </summary> [TaskAttribute("unless")] [BooleanValidator()] public bool UnlessDefined { get { return _unlessDefined; } set { _unlessDefined = value; } } #endregion Public Instance Properties #region Public Instance Methods public object CreateInstance() { // test whether extension assembly exists if (!AssemblyPath.Exists) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Assembly \"{0}\" does not exist. Can't create extension object.", AssemblyPath.FullName), Location); } // load extension object from assembly object extensionInstance = null; try { Assembly extensionAssembly = Assembly.LoadFrom(AssemblyPath.FullName); extensionInstance = extensionAssembly.CreateInstance(TypeName); } catch (Exception ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Can't create extension object \"{0}\" from \"{1}\".", TypeName, AssemblyPath.FullName), Location, ex); } return extensionInstance; } #endregion } }
// NAnt - A .NET build tool // Copyright (C) 2001-2003 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gert Driesen ([EMAIL PROTECTED]) // Tim Noll ([EMAIL PROTECTED]) using System; using System.Collections; namespace NAnt.Core.Types { /// <summary> /// Contains a collection of <see cref="XsltExtensionObject" /> elements. /// </summary> [Serializable()] public class XsltExtensionObjectCollection : CollectionBase { #region Public Instance Constructors /// <summary> /// Initializes a new instance of the /// <see cref="XsltExtensionObjectCollection"/> class. /// </summary> public XsltExtensionObjectCollection() { } /// <summary> /// Initializes a new instance of the /// <see cref="XsltExtensionObjectCollection"/> class with the /// specified <see cref="XsltExtensionObjectCollection"/> instance. /// </summary> public XsltExtensionObjectCollection(XsltExtensionObjectCollection value) { AddRange(value); } /// <summary> /// Initializes a new instance of the /// <see cref="XsltExtensionObjectCollection"/> class with the /// specified array of <see cref="XsltExtensionObject"/> instances. /// </summary> public XsltExtensionObjectCollection(XsltExtensionObject[] value) { AddRange(value); } #endregion Public Instance Constructors #region Public Instance Properties /// <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> [System.Runtime.CompilerServices.IndexerName("Item")] public XsltExtensionObject this[int index] { get { return (XsltExtensionObject) base.List[index]; } set { base.List[index] = value; } } /// <summary> /// Gets the <see cref="XsltExtensionObject"/> with the specified name. /// </summary> /// <param name="value">The name of the <see cref="XsltExtensionObject"/> /// to get.</param> [System.Runtime.CompilerServices.IndexerName("Item")] public XsltExtensionObject this[string value] { get { if (value != null) { // Try to locate instance using Value foreach (XsltExtensionObject extensionObject in base.List) { if (extensionObject.Name == value) { return extensionObject; } } } return null; } } #endregion Public Instance Properties #region Public Instance Methods /// <summary> /// Adds a <see cref="XsltExtensionObject"/> to the end of the collection. /// </summary> /// <param name="item">The <see cref="XsltExtensionObject"/> to be added /// to the end of the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(XsltExtensionObject item) { return base.List.Add(item); } /// <summary> /// Adds the elements of a <see cref="XsltExtensionObject"/> array to the /// end of the collection. /// </summary> /// <param name="items">The array of <see cref="XsltExtensionObject"/> /// elements to be added to the end of the collection.</param> public void AddRange(XsltExtensionObject[] items) { for (int i = 0; (i < items.Length); i = (i + 1)) { Add(items[i]); } } /// <summary> /// Adds the elements of a <see cref="XsltExtensionObjectCollection"/> /// to the end of the collection. /// </summary> /// <param name="items">The <see cref="XsltExtensionObjectCollection"/> /// to be added to the end of the collection.</param> public void AddRange(XsltExtensionObjectCollection items) { for (int i = 0; (i < items.Count); i = (i + 1)) { Add(items[i]); } } /// <summary> /// Determines whether a <see cref="XsltExtensionObject"/> is in the /// collection. /// </summary> /// <param name="item">The <see cref="XsltExtensionObject"/> to locate /// in the collection.</param> /// <returns> /// <see langword="true" /> if <paramref name="item"/> is found in the /// collection; otherwise, <see langword="false" />. /// </returns> public bool Contains(XsltExtensionObject item) { return base.List.Contains(item); } /// <summary> /// Determines whether a <see cref="XsltExtensionObject"/> with the /// specified value is in the collection. /// </summary> /// <param name="value">The argument value to locate in the /// collection.</param> /// <returns> /// <see langword="true" /> if a <see cref="XsltExtensionObject" /> /// with value <paramref name="value"/> is found in the collection; /// otherwise, <see langword="false" />. /// </returns> public bool Contains(string value) { return this[value] != null; } /// <summary> /// Copies the entire collection to a compatible one-dimensional array, /// starting at the specified index of the target array. /// </summary> /// <param name="array">The one-dimensional array that is the /// destination of the elements copied from the collection. The array /// must have zero-based indexing.</param> /// <param name="index">The zero-based index in <paramref name="array"/> /// at which copying begins.</param> public void CopyTo(XsltExtensionObject[] array, int index) { base.List.CopyTo(array, index); } /// <summary> /// Retrieves the index of a specified <see cref="XsltExtensionObject"/> /// object in the collection. /// </summary> /// <param name="item">The <see cref="XsltExtensionObject"/> object for /// which the index is returned.</param> /// <returns> /// The index of the specified <see cref="XsltExtensionObject"/>. If the /// <see cref="XsltExtensionObject"/> is not currently a member of the /// collection, it returns -1. /// </returns> public int IndexOf(XsltExtensionObject item) { return base.List.IndexOf(item); } /// <summary> /// Inserts a <see cref="XsltExtensionObject"/> into the collection at /// the specified index. /// </summary> /// <param name="index">The zero-based index at which /// <paramref name="item"/> should be inserted.</param> /// <param name="item">The <see cref="XsltExtensionObject"/> to /// insert.</param> public void Insert(int index, XsltExtensionObject item) { base.List.Insert(index, item); } /// <summary> /// Returns an enumerator that can iterate through the collection. /// </summary> /// <returns> /// A <see cref="XsltExtensionObjectEnumerator"/> for the entire /// collection. /// </returns> public new XsltExtensionObjectEnumerator GetEnumerator() { return new XsltExtensionObjectEnumerator(this); } /// <summary> /// Removes a member from the collection. /// </summary> /// <param name="item">The <see cref="XsltExtensionObject"/> to remove /// from the collection.</param> public void Remove(XsltExtensionObject item) { base.List.Remove(item); } #endregion Public Instance Methods } /// <summary> /// Enumerates the <see cref="XsltExtensionObject"/> elements of a /// <see cref="XsltExtensionObjectCollection"/>. /// </summary> public class XsltExtensionObjectEnumerator : IEnumerator { #region Internal Instance Constructors /// <summary> /// Initializes a new instance of the /// <see cref="XsltExtensionObjectEnumerator"/> class /// with the specified <see cref="XsltExtensionObjectCollection"/>. /// </summary> /// <param name="arguments">The collection that should be /// enumerated.</param> internal XsltExtensionObjectEnumerator(XsltExtensionObjectCollection arguments) { IEnumerable temp = (IEnumerable) (arguments); _baseEnumerator = temp.GetEnumerator(); } #endregion Internal Instance Constructors #region Implementation of IEnumerator /// <summary> /// Gets the current element in the collection. /// </summary> /// <returns> /// The current element in the collection. /// </returns> public XsltExtensionObject Current { get { return (XsltExtensionObject) _baseEnumerator.Current; } } object IEnumerator.Current { get { return _baseEnumerator.Current; } } /// <summary> /// Advances the enumerator to the next element of the collection. /// </summary> /// <returns> /// <see langword="true" /> if the enumerator was successfully advanced /// to the next element; <see langword="false" /> if the enumerator has /// passed the end of the collection. /// </returns> public bool MoveNext() { return _baseEnumerator.MoveNext(); } bool IEnumerator.MoveNext() { return _baseEnumerator.MoveNext(); } /// <summary> /// Sets the enumerator to its initial position, which is before the /// first element in the collection. /// </summary> public void Reset() { _baseEnumerator.Reset(); } void IEnumerator.Reset() { _baseEnumerator.Reset(); } #endregion Implementation of IEnumerator #region Private Instance Fields private IEnumerator _baseEnumerator; #endregion Private Instance Fields } }