public override void WriteTo(XmlWriter w) { string prefix = this.Prefix; if (!string.IsNullOrEmpty(this.NamespaceURI)) { prefix = w.LookupPrefix(this.NamespaceURI) ?? this.Prefix; } w.WriteStartElement(prefix, this.LocalName, this.NamespaceURI); if (this.HasAttributes) { XmlAttributePreservingWriter preservingWriter = w as XmlAttributePreservingWriter; if (preservingWriter == null || this.preservationDict == null) { this.WriteAttributesTo(w); } else { this.WritePreservedAttributesTo(preservingWriter); } } if (this.IsEmpty) { w.WriteEndElement(); } else { this.WriteContentTo(w); w.WriteFullEndElement(); } }
internal void WritePreservedAttributes(XmlAttributePreservingWriter writer, XmlAttributeCollection attributes) { string newLineString = (string)null; if (this.attributeNewLineString != null) { newLineString = writer.SetAttributeNewLineString(this.attributeNewLineString); } try { foreach (string key in this.orderedAttributes) { XmlAttribute xmlAttribute = attributes[key]; if (xmlAttribute != null) { if (this.leadingSpaces.ContainsKey(key)) { writer.WriteAttributeWhitespace(this.leadingSpaces[key]); } xmlAttribute.WriteTo((XmlWriter)writer); } } if (!this.leadingSpaces.ContainsKey(string.Empty)) { return; } writer.WriteAttributeTrailingWhitespace(this.leadingSpaces[string.Empty]); } finally { if (newLineString != null) { writer.SetAttributeNewLineString(newLineString); } } }
internal void WritePreservedAttributes(XmlAttributePreservingWriter writer, XmlAttributeCollection attributes) { string newLineString = (string)null; if (this.attributeNewLineString != null) newLineString = writer.SetAttributeNewLineString(this.attributeNewLineString); try { foreach (string key in this.orderedAttributes) { XmlAttribute xmlAttribute = attributes[key]; if (xmlAttribute != null) { if (this.leadingSpaces.ContainsKey(key)) writer.WriteAttributeWhitespace(this.leadingSpaces[key]); xmlAttribute.WriteTo((XmlWriter)writer); } } if (!this.leadingSpaces.ContainsKey(string.Empty)) return; writer.WriteAttributeTrailingWhitespace(this.leadingSpaces[string.Empty]); } finally { if (newLineString != null) writer.SetAttributeNewLineString(newLineString); } }
private bool StateRequiresBuffer(XmlAttributePreservingWriter.AttributeTextWriter.State state) { if (state != XmlAttributePreservingWriter.AttributeTextWriter.State.Buffering) return state == XmlAttributePreservingWriter.AttributeTextWriter.State.ReadingAttribute; else return true; }
private void ChangeState(XmlAttributePreservingWriter.AttributeTextWriter.State newState) { if (this.state == newState) return; XmlAttributePreservingWriter.AttributeTextWriter.State state = this.state; this.state = newState; if (this.StateRequiresBuffer(newState)) { this.CreateBuffer(); } else { if (!this.StateRequiresBuffer(state)) return; this.FlushBuffer(); } }
private void WritePreservedAttributesTo(XmlAttributePreservingWriter preservingWriter) { this.preservationDict.WritePreservedAttributes(preservingWriter, this.Attributes); }