예제 #1
0
 /// <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);
 }
예제 #2
0
 /// <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);
 }
예제 #3
0
        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);
        }
예제 #4
0
 public void WriteXml(System.Xml.XmlWriter?writer)
 {
     if (_value != null)
     {
         writer?.WriteCData(_value);
     }
 }
예제 #5
0
 protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey)
 {
     if (writer != null)
     {
         writer.WriteCData(CommandText);
     }
     return(true);
 }
예제 #6
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     if (!String.IsNullOrEmpty(this.Lang))
     {
         writer.WriteAttributeString("lang", this.Lang);
     }
     writer.WriteCData(this.Content);
 }
예제 #7
0
        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();
        }
예제 #8
0
 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();
     }
 }
예제 #9
0
 /// <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");
     }
 }
예제 #10
0
        /// <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);
        }
예제 #12
0
 public void WriteCData(string value)
 {
     _writer.WriteCData(value);
 }
예제 #13
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(_value);
 }
예제 #14
0
 /// <summary>
 /// Interface implementation, which writes the CDATA tag to the xml
 /// </summary>
 void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(this.text);
 }
예제 #15
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(this.Content);
 }
예제 #16
0
 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);
            }
        }
예제 #18
0
 protected override void WriteContentsTo(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(Text);
 }
예제 #19
0
 protected override void WriteXmlData(System.Xml.XmlWriter writer)
 {
     writer.WriteCData((string)GetData());
 }
예제 #20
0
 public void Verbatim(string content)
 {
     _writer.WriteCData(content);
 }