/// <summary> /// Saves the current <see cref="AtomCategory"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("category", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); writer.WriteAttributeString("term", this.Term); if (this.Scheme != null) { writer.WriteAttributeString("scheme", this.Scheme.ToString()); } if (!String.IsNullOrEmpty(this.Label)) { writer.WriteAttributeString("label", this.Label); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomGenerator"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("generator", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); if (this.Uri != null) { writer.WriteAttributeString("uri", this.Uri.ToString()); } if (!String.IsNullOrEmpty(this.Version)) { writer.WriteAttributeString("version", this.Version); } writer.WriteString(this.Content); //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomPersonConstruct"/> 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 person 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, AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); writer.WriteElementString("name", AtomUtility.AtomNamespace, this.Name); if (this.Uri != null) { writer.WriteElementString("uri", AtomUtility.AtomNamespace, this.Uri.ToString()); } if (!String.IsNullOrEmpty(this.EmailAddress)) { writer.WriteElementString("email", AtomUtility.AtomNamespace, this.EmailAddress); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomContent"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("content", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); if (!String.IsNullOrEmpty(this.ContentType)) { writer.WriteAttributeString("type", this.ContentType); } if (this.Source != null) { writer.WriteAttributeString("src", this.Source.ToString()); } if (String.Compare(this.ContentType, "xhtml", StringComparison.OrdinalIgnoreCase) == 0 && String.IsNullOrEmpty(writer.LookupPrefix(AtomUtility.XhtmlNamespace))) { writer.WriteAttributeString("xmlns", "xhtml", null, AtomUtility.XhtmlNamespace); } if (!String.IsNullOrEmpty(this.Content)) { if (String.Compare(this.ContentType, "xhtml", StringComparison.OrdinalIgnoreCase) == 0) { writer.WriteStartElement("div", AtomUtility.XhtmlNamespace); writer.WriteString(this.Content); writer.WriteEndElement(); } else { writer.WriteString(this.Content); } } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomLink"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("link", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); writer.WriteAttributeString("href", this.Uri != null ? this.Uri.ToString() : String.Empty); if (!String.IsNullOrEmpty(this.Relation)) { writer.WriteAttributeString("rel", this.Relation); } if (!String.IsNullOrEmpty(this.ContentType)) { writer.WriteAttributeString("type", this.ContentType); } if (this.ContentLanguage != null) { writer.WriteAttributeString("hreflang", this.ContentLanguage.Name); } if (!String.IsNullOrEmpty(this.Title)) { writer.WriteAttributeString("title", this.Title); } if (this.Length != Int64.MinValue) { writer.WriteAttributeString("length", this.Length.ToString(NumberFormatInfo.InvariantInfo)); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomTextConstruct"/> 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, AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); if (this.TextType == AtomTextConstructType.Xhtml && String.IsNullOrEmpty(writer.LookupPrefix(AtomUtility.XhtmlNamespace))) { writer.WriteAttributeString("xmlns", "xhtml", null, AtomUtility.XhtmlNamespace); } if (this.TextType != AtomTextConstructType.None) { writer.WriteAttributeString("type", AtomTextConstruct.ConstructTypeAsString(this.TextType)); } if (this.TextType == AtomTextConstructType.Xhtml) { writer.WriteStartElement("div", AtomUtility.XhtmlNamespace); writer.WriteString(this.Content); writer.WriteEndElement(); } else { writer.WriteString(this.Content); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomIcon"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("icon", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); writer.WriteString(this.Uri != null ? this.Uri.ToString() : String.Empty); //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }