/// <summary> /// 将注释文本填写到一个XML书写器中 /// </summary> /// <remarks> /// 若 OwnerDocument.WriteOptions.CommentOutput设置为false则不输出注释 /// 若设置了OwnerDocument.WriteOptions.CommentOutputXSL则对象输出为 /// [xsl:comment]对象文本[/xsl:comment] /// </remarks> /// <param name="myWriter">XML书写器</param> /// <returns>操作是否成功</returns> public override bool Write(System.Xml.XmlWriter myWriter) { if (myOwnerDocument.WriteOptions.CommentOutput) { if (strText != null && strText.Length > 0) { string vText = strText + " "; if (vText.IndexOf("--") >= 0) { vText = "因保存需要,将所有的\"- -\"转换为 \"@@\"符号\r\n" + vText.Replace("--", "@@"); } if (myOwnerDocument.WriteOptions.CommentOutputXSL) { myWriter.WriteStartElement(StringConstXSLT.Comment); myWriter.WriteCData(vText); myWriter.WriteEndElement(); } else { myWriter.WriteComment(vText); } } } return(true); }
/// <summary> /// 向XML书写器输出对象数据 /// </summary> /// <remarks>若设置了OwnerDocument.WriteOptions.ScriptWriteCData /// 则脚本代码放置在 CDATA 块中</remarks> /// <param name="myWriter">XML书写器</param> /// <returns>操作是否成功</returns> protected override bool InnerWrite(System.Xml.XmlWriter myWriter) { if (HTMLTextReader.isBlankString(strText)) { myWriter.WriteString(" "); } else { if (myOwnerDocument.WriteOptions.ScriptWriteCData) { string vText = strText.Replace("<![CDATA[", ""); vText = vText.Replace("]]", ""); myWriter.WriteString("//"); myWriter.WriteCData(vText + "//"); } else { string vText = strText + " "; if (vText.IndexOf("--") >= 0) { vText = "因保存需要,将所有的\"--\"转换为 \"@@\"符号\r\n" + vText.Replace("--", "@@"); } myWriter.WriteComment(vText); } //myWriter.WriteString( strText ); } return(true); }
protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey) { bool returnValue; if (cDataProperties.Count == 0) { returnValue = base.SerializeElement(writer, serializeCollectionKey); } else { foreach (ConfigurationProperty configurationProperty in Properties) { string name = configurationProperty.Name; string propertyValue = configurationProperty.Converter.ConvertToString( base[name]); if (cDataProperties.ContainsKey(name)) { writer.WriteCData(propertyValue); } else { writer.WriteAttributeString("name", propertyValue); } } returnValue = true; } return(returnValue); }
public void WriteXml(System.Xml.XmlWriter?writer) { if (_value != null) { writer?.WriteCData(_value); } }
protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey) { if (writer != null) { writer.WriteCData(CommandText); } return(true); }
public void WriteXml(System.Xml.XmlWriter writer) { if (!String.IsNullOrEmpty(this.Lang)) { writer.WriteAttributeString("lang", this.Lang); } writer.WriteCData(this.Content); }
public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteElementString("SnippetTemplatePath", SnippetTemplatePath); writer.WriteElementString("SlotName", SlotName); writer.WriteStartElement("Data"); writer.WriteCData(Data); writer.WriteElementString("ContentID", ContentID); writer.WriteEndElement(); }
public void WriteXml(System.Xml.XmlWriter writer) { foreach (string key in this.Keys) { writer.WriteStartElement("item"); writer.WriteAttributeString("key", key); writer.WriteCData(this[key]); writer.WriteEndElement(); } }
/// <summary> /// Write xml /// </summary> /// <param name="writer">Writer</param> public void WriteXml(System.Xml.XmlWriter writer) { if (string.IsNullOrWhiteSpace(value)) { writer.WriteString(string.Empty); } else { writer.WriteCData("\n" + value + "\n"); } }
/// <summary> /// 写入XML /// </summary> /// <param name="s"></param> /// <param name="writer"></param> void WriteXml(string s, System.Xml.XmlWriter writer) { if (string.IsNullOrEmpty(s) == false) { int index = s.IndexOf("]]>"); if (index >= 0) { WriteXml(s.Substring(0, index + 2), writer); WriteXml(s.Substring(index + 2), writer); } else { writer.WriteCData(s); } } }
protected override bool SerializeElement( System.Xml.XmlWriter writer, bool serializeCollectionKey) { if (writer == null) { return(true); } bool returnValue; if (string.IsNullOrEmpty( _cDataConfigurationPropertyName)) { returnValue = base.SerializeElement( writer, serializeCollectionKey); } else { foreach (ConfigurationProperty configurationProperty in Properties) { string name = configurationProperty.Name; TypeConverter converter = configurationProperty.Converter; string propertyValue = converter.ConvertToString( base[name]); if (name == _cDataConfigurationPropertyName) { writer.WriteCData(propertyValue); } else { writer.WriteAttributeString("name", propertyValue); } } returnValue = true; } return(returnValue); }
public void WriteCData(string value) { _writer.WriteCData(value); }
public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteCData(_value); }
/// <summary> /// Interface implementation, which writes the CDATA tag to the xml /// </summary> void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { writer.WriteCData(this.text); }
public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteCData(this.Content); }
protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context) { writer.WriteCData((string)GetData(false)); }
public static void XmlReaderClone(System.Xml.XmlReader reader, System.Xml.XmlWriter writer) { if (reader == null) { throw new ArgumentNullException("System.Xml.XmlReader"); } if (writer == null) { throw new ArgumentNullException("System.Xml.XmlWriter"); } switch (reader.NodeType) { case System.Xml.XmlNodeType.Element: writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); writer.WriteAttributes(reader, true); if (reader.IsEmptyElement) { writer.WriteEndElement(); } break; case System.Xml.XmlNodeType.Text: writer.WriteString(reader.Value); break; case System.Xml.XmlNodeType.Whitespace: case System.Xml.XmlNodeType.SignificantWhitespace: writer.WriteWhitespace(reader.Value); break; case System.Xml.XmlNodeType.CDATA: writer.WriteCData(reader.Value); break; case System.Xml.XmlNodeType.EntityReference: writer.WriteEntityRef(reader.Name); break; case System.Xml.XmlNodeType.XmlDeclaration: case System.Xml.XmlNodeType.ProcessingInstruction: writer.WriteProcessingInstruction(reader.Name, reader.Value); break; case System.Xml.XmlNodeType.DocumentType: writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value); break; case System.Xml.XmlNodeType.Comment: writer.WriteComment(reader.Value); break; case System.Xml.XmlNodeType.EndElement: writer.WriteFullEndElement(); break; } if (reader.Read()) { XmlReaderClone(reader, writer); } }
protected override void WriteContentsTo(System.Xml.XmlWriter writer) { writer.WriteCData(Text); }
protected override void WriteXmlData(System.Xml.XmlWriter writer) { writer.WriteCData((string)GetData()); }
public void Verbatim(string content) { _writer.WriteCData(content); }