System.Xml.Xsl.XsltOld.Compiler.AddScript C# (CSharp) Method

AddScript() private method

private AddScript ( string source, ScriptingLanguage lang, string ns, string fileName, int lineNumber ) : void
source string
lang ScriptingLanguage
ns string
fileName string
lineNumber int
return void
        internal void AddScript(string source, ScriptingLanguage lang, string ns, string fileName, int lineNumber)
        {
            ValidateExtensionNamespace(ns);

            for (ScriptingLanguage langTmp = ScriptingLanguage.JScript; langTmp <= ScriptingLanguage.CSharp; langTmp++)
            {
                Hashtable typeDecls = _typeDeclsByLang[(int)langTmp];
                if (lang == langTmp)
                {
                    throw new PlatformNotSupportedException("Compiling JScript/CSharp scripts is not supported");
                }
                else if (typeDecls.Contains(ns))
                {
                    throw XsltException.Create(SR.Xslt_ScriptMixedLanguages, ns);
                }
            }
        }

Usage Example

        private void AddScript(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            ScriptingLanguage lang = ScriptingLanguage.JScript;
            string            implementsNamespace = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.LocalName == input.Atoms.Language)
                    {
                        string langName = input.Value;
                        if (
                            String.Compare(langName, "jscript", StringComparison.OrdinalIgnoreCase) == 0 ||
                            String.Compare(langName, "javascript", StringComparison.OrdinalIgnoreCase) == 0
                            )
                        {
                            lang = ScriptingLanguage.JScript;
                        }
                        else if (
                            String.Compare(langName, "c#", StringComparison.OrdinalIgnoreCase) == 0 ||
                            String.Compare(langName, "csharp", StringComparison.OrdinalIgnoreCase) == 0
                            )
                        {
                            lang = ScriptingLanguage.CSharp;
                        }
                        else
                        {
                            throw XsltException.Create(Res.Xslt_ScriptInvalidLanguage, langName);
                        }
                    }
                    else if (input.LocalName == input.Atoms.ImplementsPrefix)
                    {
                        if (!PrefixQName.ValidatePrefix(input.Value))
                        {
                            throw XsltException.Create(Res.Xslt_InvalidAttrValue, input.LocalName, input.Value);
                        }
                        implementsNamespace = compiler.ResolveXmlNamespace(input.Value);
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            if (implementsNamespace == null)
            {
                throw XsltException.Create(Res.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
            }
            if (!input.Recurse() || input.NodeType != XPathNodeType.Text)
            {
                throw XsltException.Create(Res.Xslt_ScriptEmpty);
            }
            compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber);
            input.ToParent();
        }
All Usage Examples Of System.Xml.Xsl.XsltOld.Compiler::AddScript