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);
}