System.Xml.Xsl.Runtime.XmlQueryOutput.WriteNamespaceDeclarationUnchecked C# (CSharp) Method

WriteNamespaceDeclarationUnchecked() public method

Add a new namespace declaration -- xmlns:prefix="ns" -- to the set of in-scope declarations. NOTE: This method should only be called if caller can guarantee that the current state is EnumAttrs and that there will be no namespace conflicts in the current scope (e.g. trying to map the same prefix to different namespaces within the same element start tag). If no such guarantees exist, then WriteNamespaceDeclaration() should be called instead.
public WriteNamespaceDeclarationUnchecked ( string prefix, string ns ) : void
prefix string
ns string
return void
        public void WriteNamespaceDeclarationUnchecked(string prefix, string ns) {
            Debug.Assert(prefix != null && ns != null);
            Debug.Assert(this.xstate == XmlState.EnumAttrs, "WriteNamespaceDeclaration cannot be called in the " + this.xstate + " state.");

            // xmlns:foo="" is illegal
            Debug.Assert(prefix.Length == 0 || ns.Length != 0);

            if (this.depth == 0) {
                // At top-level, so write namespace declaration directly to output
                Writer.WriteNamespaceDeclaration(prefix, ns);
                return;
            }

            if (this.nsmgr == null) {
                // If namespace manager has no namespaces, then xmlns="" is in scope by default
                if (ns.Length == 0 && prefix.Length == 0)
                    return;

                this.nsmgr = new XmlNamespaceManager(this.runtime.NameTable);
                this.nsmgr.PushScope();
            }

            if (this.nsmgr.LookupNamespace(prefix) != ns)
                AddNamespace(prefix, ns);
        }