System.Xml.Xsl.XsltArgumentList.AddExtensionObject C# (CSharp) Method

AddExtensionObject() public method

public AddExtensionObject ( string namespaceUri, object extension ) : void
namespaceUri string
extension object
return void
        public void AddExtensionObject(string namespaceUri, object extension)
        {
            CheckArgumentNull(namespaceUri, nameof(namespaceUri));
            CheckArgumentNull(extension, nameof(extension));
            _extensions.Add(namespaceUri, extension);
        }

Usage Example

        public Program()
        {
            //Set the UI to the specified culture.
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(_culturename);

            //Create the XslTransform and load the stylesheet.
            //XslTransform xslt = new XslTransform();
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(_stylesheet);

            //Load the XML data file.
            XPathDocument doc = new XPathDocument(_filename);

            //Create an XsltArgumentList.
            XsltArgumentList xslArg = new XsltArgumentList();

            //Add an object to get the resources for the specified language.
            ResourceTranslator resTran = new ResourceTranslator("Resources.Resource");
            xslArg.AddExtensionObject("urn:myResTran", resTran);

            //Add an object to calculate the circumference of the circle.
            Calculate obj = new Calculate();
            xslArg.AddExtensionObject("urn:myObj", obj);

            //Create an XmlTextWriter to output to the console.
            XmlTextWriter writer = new XmlTextWriter(Console.Out);

            //Transform the file.
            xslt.Transform(doc, xslArg, writer, null);

            writer.Close();
        }
All Usage Examples Of System.Xml.Xsl.XsltArgumentList::AddExtensionObject