/// <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) { Guard.ArgumentNotNull(writer, "writer"); Guard.ArgumentNotNullOrEmptyString(elementName, "elementName"); 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); } 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="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="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="AtomLogo"/> 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) { Guard.ArgumentNotNull(writer, "writer"); writer.WriteStartElement("logo", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); writer.WriteString(this.Uri != null ? this.Uri.ToString() : String.Empty); 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="AtomId"/> 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("id", 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(); }
/// <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) { Guard.ArgumentNotNull(writer, "writer"); Guard.ArgumentNotNullOrEmptyString(elementName, "elementName"); 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); } SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <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) { Guard.ArgumentNotNull(writer, "writer"); 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); } 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) { Guard.ArgumentNotNull(writer, "writer"); 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); SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="AtomSource"/> 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) { Guard.ArgumentNotNull(writer, "writer"); writer.WriteStartElement("source", AtomUtility.AtomNamespace); AtomUtility.WriteCommonObjectAttributes(this, writer); if (this.Id != null) { this.Id.WriteTo(writer); } if (this.Title != null) { this.Title.WriteTo(writer, "title"); } if (this.UpdatedOn != DateTime.MinValue) { writer.WriteElementString("updated", AtomUtility.AtomNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.UpdatedOn)); } if (this.Generator != null) { this.Generator.WriteTo(writer); } if (this.Icon != null) { this.Icon.WriteTo(writer); } if (this.Logo != null) { this.Logo.WriteTo(writer); } if (this.Rights != null) { this.Rights.WriteTo(writer, "rights"); } if (this.Subtitle != null) { this.Subtitle.WriteTo(writer, "subtitle"); } foreach (AtomPersonConstruct author in this.Authors) { author.WriteTo(writer, "author"); } foreach (AtomCategory category in this.Categories) { category.WriteTo(writer); } foreach (AtomPersonConstruct contributor in this.Contributors) { contributor.WriteTo(writer, "contributor"); } foreach (AtomLink link in this.Links) { link.WriteTo(writer); } SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }