/// <summary> /// Writes the current context to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <b>XmlWriter</b> to which you want to write the current context.</param> /// <param name="xmlNamespace">The XML namespace used to qualify prefixed syndication extension elements and attributes.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="xmlNamespace"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="xmlNamespace"/> is an empty string.</exception> public void WriteTo(XmlWriter writer, string xmlNamespace) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); Guard.ArgumentNotNullOrEmptyString(xmlNamespace, "xmlNamespace"); //------------------------------------------------------------ // Write current extension details to the writer //------------------------------------------------------------ if (ItemsPerPage != null) { writer.WriteElementString("itemsPerPage", xmlNamespace, ItemsPerPage.ToString()); } if (TotalResults != null) { writer.WriteElementString("totalResults", xmlNamespace, TotalResults.ToString()); } if (StartIndex != null) { writer.WriteElementString("startIndex", xmlNamespace, StartIndex.ToString()); } }
/// <summary> /// /// </summary> /// <param name="writer"></param> /// <param name="version"></param> protected override void WriteElementExtensions(XmlWriter writer, string version) { if (TotalResults > 0) { writer.WriteElementString("totalResults", OpdsNamespaces.OpenSearch.Value, TotalResults.ToString(CultureInfo.InvariantCulture)); } if (ItemsPerPage > 0) { writer.WriteElementString("itemsPerPage", OpdsNamespaces.OpenSearch.Value, ItemsPerPage.ToString(CultureInfo.InvariantCulture)); } base.WriteElementExtensions(writer, version); }