/// <summary> /// Before calling XmlRawWriter.WriteStartElement(), perform various checks to ensure well-formedness. /// </summary> public override void WriteStartElement(string prefix, string localName, string ns) { Debug.Assert(prefix != null && localName != null && localName.Length != 0 && ns != null, "Invalid argument"); Debug.Assert(ValidateNames.ValidateName(prefix, localName, ns, XPathNodeType.Element, ValidateNames.Flags.All), "Name validation failed"); // Xml state transitions ConstructWithinContent(XPathNodeType.Element); // Call XmlRawWriter.WriteStartElement WriteStartElementUnchecked(prefix, localName, ns); // Ensure that element's namespace declaration is declared WriteNamespaceDeclarationUnchecked(prefix, ns); // Cache attributes in order to detect duplicates if (this.attrCache == null) this.attrCache = new XmlAttributeCache(); this.attrCache.Init(Writer); Writer = this.attrCache; this.attrCache = null; // Push element names onto a stack PushElementNames(prefix, localName, ns); }
/// <summary> /// This method will be called if "xwrt" is a writer which no longer needs to be part of the pipeline and /// wishes to replace itself with a different writer. For example, the auto-detect writer replaces itself /// with the Html or Xml writer once it has determined which output mode to use. /// </summary> private void SetWrappedWriter(XmlRawWriter writer) { // Reuse XmlAttributeCache so that it doesn't have to be recreated every time if (Writer is XmlAttributeCache) this.attrCache = (XmlAttributeCache) Writer; Writer = writer; }