Exemplo n.º 1
0
        /// <summary>
        /// Saves the current <see cref="BlogMLTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is an empty string.</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            Guard.ArgumentNotNull(writer, "writer");
            Guard.ArgumentNotNullOrEmptyString(elementName, "elementName");
            writer.WriteStartElement(elementName, BlogMLUtility.BlogMLNamespace);

            if (this.ContentType != BlogMLContentType.None)
            {
                writer.WriteAttributeString("type", BlogMLTextConstruct.ConstructTypeAsString(this.ContentType));
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                if (this.EscapeContent)
                {
                    writer.WriteCData(this.Content);
                }
                else
                {
                    writer.WriteString(this.Content);
                }
            }
            SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="BlogMLTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is an empty string.</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(writer, "writer");
            Guard.ArgumentNotNullOrEmptyString(elementName, "elementName");

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement(elementName, BlogMLUtility.BlogMLNamespace);

            if (this.ContentType != BlogMLContentType.None)
            {
                writer.WriteAttributeString("type", BlogMLTextConstruct.ConstructTypeAsString(this.ContentType));
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                if (this.EscapeContent)
                {
                    writer.WriteCData(this.Content);
                }
                else
                {
                    writer.WriteString(this.Content);
                }
            }

            //------------------------------------------------------------
            //	Write the syndication extensions of the current instance
            //------------------------------------------------------------
            SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer);

            writer.WriteEndElement();
        }