/// <summary> /// Saves the current <see cref="ApmlConcept"/> 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("Concept", ApmlUtility.ApmlNamespace); writer.WriteAttributeString("key", this.Key); writer.WriteAttributeString("value", this.Value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo)); if (!String.IsNullOrEmpty(this.From)) { writer.WriteAttributeString("from", this.From); } if (this.UpdatedOn != DateTime.MinValue) { writer.WriteAttributeString("updated", SyndicationDateTimeUtility.ToRfc3339DateTime(this.UpdatedOn)); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="ApmlHead"/> 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("Head", ApmlUtility.ApmlNamespace); if (!String.IsNullOrEmpty(this.Title)) { writer.WriteElementString("Title", ApmlUtility.ApmlNamespace, this.Title); } if (!String.IsNullOrEmpty(this.Generator)) { writer.WriteElementString("Generator", ApmlUtility.ApmlNamespace, this.Generator); } if (!String.IsNullOrEmpty(this.EmailAddress)) { writer.WriteElementString("UserEmail", ApmlUtility.ApmlNamespace, this.EmailAddress); } if (this.CreatedOn != DateTime.MinValue) { writer.WriteElementString("DateCreated", ApmlUtility.ApmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.CreatedOn)); } SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <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 (this.Period != SiteSummaryUpdatePeriod.None) { writer.WriteElementString("updatePeriod", xmlNamespace, SiteSummaryUpdateSyndicationExtension.PeriodAsString(this.Period)); } if (this.Frequency != Int32.MinValue) { writer.WriteElementString("updateFrequency", xmlNamespace, this.Frequency.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (this.Base != DateTime.MinValue) { writer.WriteElementString("updateBase", xmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.Base)); } }
/// <summary> /// Saves the current <see cref="FeedSynchronizationHistory"/> 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"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("history", extension.XmlNamespace); writer.WriteAttributeString("sequence", this.Sequence.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); if (this.When != DateTime.MinValue) { writer.WriteAttributeString("when", SyndicationDateTimeUtility.ToRfc3339DateTime(this.When)); } if (!String.IsNullOrEmpty(this.By)) { writer.WriteAttributeString("when", this.By); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="IBlogMLCommonObject"/> attributes to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="source">A object that implements the <see cref="IBlogMLCommonObject"/> interface to extract BlogML common object information from.</param> /// <param name="writer">The <see cref="XmlWriter"/> to which the <paramref name="source"/> information will be written.</param> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public static void WriteCommonObjectAttributes(IBlogMLCommonObject source, XmlWriter writer) { Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(writer, "writer"); if (!String.IsNullOrEmpty(source.Id)) { writer.WriteAttributeString("id", source.Id); } if (source.CreatedOn != DateTime.MinValue) { writer.WriteAttributeString("date-created", SyndicationDateTimeUtility.ToRfc3339DateTime(source.CreatedOn)); } if (source.LastModifiedOn != DateTime.MinValue) { writer.WriteAttributeString("date-modified", SyndicationDateTimeUtility.ToRfc3339DateTime(source.LastModifiedOn)); } if (source.ApprovalStatus != BlogMLApprovalStatus.None) { writer.WriteAttributeString("approved", BlogMLUtility.ApprovalStatusAsString(source.ApprovalStatus)); } }
public void SingleResource_Verify_CanCreate() { var request = new SDataSingleResourceRequest(_service) { ResourceKind = "employees" }; var payload = new SDataPayload(); payload.Values["Title"] = "create 1"; payload.Values["NationalIdNumber"] = "44444"; payload.Values["LoginId"] = "create 4"; payload.Values["ContactId"] = "9999"; payload.Values["BirthDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(new DateTime(1970, 8, 2)); payload.Values["HireDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now); payload.Values["ModifiedDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now); payload.Values["MaritalStatus"] = "Single"; payload.Values["SalariedFlag"] = XmlConvert.ToString(true); payload.Values["CurrentFlag"] = XmlConvert.ToString(true); payload.Values["Gender"] = "Male"; payload.Values["RowGuid"] = Guid.NewGuid().ToString(); var entry = new AtomEntry { UpdatedOn = DateTime.Now, PublishedOn = DateTime.Now }; entry.SetSDataPayload(payload); request.Entry = entry; _mock.Setup(s => s.CreateEntry(request, request.Entry)).Returns(TestData.Entry); entry = request.Create(); Expect(entry, Is.Not.Null); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationSharingInformation"/> 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"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); writer.WriteStartElement("sharing", extension.XmlNamespace); if (!String.IsNullOrEmpty(this.Since)) { writer.WriteAttributeString("since", this.Since); } if (!String.IsNullOrEmpty(this.Until)) { writer.WriteAttributeString("until", this.Until); } if (this.ExpiresOn != DateTime.MinValue) { writer.WriteAttributeString("expires", SyndicationDateTimeUtility.ToRfc3339DateTime(this.ExpiresOn)); } foreach (FeedSynchronizationRelatedInformation relation in this.Relations) { relation.WriteTo(writer); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="ApmlSource"/> 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", ApmlUtility.ApmlNamespace); writer.WriteAttributeString("key", this.Key); writer.WriteAttributeString("name", this.Name); writer.WriteAttributeString("value", this.Value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo)); writer.WriteAttributeString("type", this.MimeType); if (!String.IsNullOrEmpty(this.From)) { writer.WriteAttributeString("from", this.From); } if (this.UpdatedOn != DateTime.MinValue) { writer.WriteAttributeString("updated", SyndicationDateTimeUtility.ToRfc3339DateTime(this.UpdatedOn)); } foreach (ApmlAuthor author in this.Authors) { author.WriteTo(writer); } SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <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) { Guard.ArgumentNotNull(writer, "writer"); Guard.ArgumentNotNullOrEmptyString(xmlNamespace, "xmlNamespace"); if (this.EditedOn != DateTime.MinValue) { writer.WriteElementString("edited", xmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.EditedOn)); } }
/// <summary> /// Returns the string representation of the supplied scalar value using the specified <see cref="XmlRpcScalarValueType"/>. /// </summary> /// <param name="type">The data type used to determine string representation.</param> /// <param name="scalar">The scalar value to convert.</param> /// <returns>The string representation of the current instance's <see cref="Value"/>, based on its <see cref="ValueType"/>.</returns> private static string ValueAsString(XmlRpcScalarValueType type, object scalar) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string value = String.Empty; //------------------------------------------------------------ // Return string representation based on data type //------------------------------------------------------------ if (scalar == null) { return(String.Empty); } switch (type) { case XmlRpcScalarValueType.Base64: byte[] data = scalar as byte[]; if (data != null) { value = Convert.ToBase64String(data, Base64FormattingOptions.None); } else { value = Convert.ToString(scalar, CultureInfo.InvariantCulture); } break; case XmlRpcScalarValueType.Boolean: value = Convert.ToBoolean(scalar, CultureInfo.InvariantCulture) ? "1" : "0"; break; case XmlRpcScalarValueType.DateTime: value = SyndicationDateTimeUtility.ToRfc3339DateTime(Convert.ToDateTime(scalar, DateTimeFormatInfo.InvariantInfo)); break; case XmlRpcScalarValueType.Double: value = Convert.ToDouble(scalar, NumberFormatInfo.InvariantInfo).ToString(NumberFormatInfo.InvariantInfo); break; case XmlRpcScalarValueType.Integer: value = Convert.ToInt32(scalar, NumberFormatInfo.InvariantInfo).ToString(NumberFormatInfo.InvariantInfo); break; case XmlRpcScalarValueType.String: value = Convert.ToString(scalar, CultureInfo.InvariantCulture).Trim(); break; } return(value); }
/// <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 (this.EditedOn != DateTime.MinValue) { writer.WriteElementString("edited", xmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.EditedOn)); } }
/// <summary> /// Saves the current <see cref="FeedSynchronizationHistory"/> 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"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); writer.WriteStartElement("history", extension.XmlNamespace); writer.WriteAttributeString("sequence", this.Sequence.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); if (this.When != DateTime.MinValue) { writer.WriteAttributeString("when", SyndicationDateTimeUtility.ToRfc3339DateTime(this.When)); } if (!String.IsNullOrEmpty(this.By)) { writer.WriteAttributeString("when", this.By); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="ApmlHead"/> 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("Head", ApmlUtility.ApmlNamespace); if (!String.IsNullOrEmpty(this.Title)) { writer.WriteElementString("Title", ApmlUtility.ApmlNamespace, this.Title); } if (!String.IsNullOrEmpty(this.Generator)) { writer.WriteElementString("Generator", ApmlUtility.ApmlNamespace, this.Generator); } if (!String.IsNullOrEmpty(this.EmailAddress)) { writer.WriteElementString("UserEmail", ApmlUtility.ApmlNamespace, this.EmailAddress); } if (this.CreatedOn != DateTime.MinValue) { writer.WriteElementString("DateCreated", ApmlUtility.ApmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.CreatedOn)); } //------------------------------------------------------------ // Write the syndication extensions of the current instance //------------------------------------------------------------ SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationSharingInformation"/> 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"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("sharing", extension.XmlNamespace); if (!String.IsNullOrEmpty(this.Since)) { writer.WriteAttributeString("since", this.Since); } if (!String.IsNullOrEmpty(this.Until)) { writer.WriteAttributeString("until", this.Until); } if (this.ExpiresOn != DateTime.MinValue) { writer.WriteAttributeString("expires", SyndicationDateTimeUtility.ToRfc3339DateTime(this.ExpiresOn)); } foreach (FeedSynchronizationRelatedInformation relation in this.Relations) { relation.WriteTo(writer); } writer.WriteEndElement(); }
/// <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 (!String.IsNullOrEmpty(this.Contributor)) { writer.WriteElementString("contributor", xmlNamespace, this.Contributor); } if (!String.IsNullOrEmpty(this.Coverage)) { writer.WriteElementString("coverage", xmlNamespace, this.Coverage); } if (!String.IsNullOrEmpty(this.Creator)) { writer.WriteElementString("creator", xmlNamespace, this.Creator); } if (this.Date != DateTime.MinValue) { writer.WriteElementString("date", xmlNamespace, SyndicationDateTimeUtility.ToRfc3339DateTime(this.Date)); } if (!String.IsNullOrEmpty(this.Description)) { writer.WriteElementString("description", xmlNamespace, this.Description); } if (!String.IsNullOrEmpty(this.Format)) { writer.WriteElementString("format", xmlNamespace, this.Format); } if (!String.IsNullOrEmpty(this.Identifier)) { writer.WriteElementString("identifier", xmlNamespace, this.Identifier); } if (this.Language != null) { writer.WriteElementString("language", xmlNamespace, this.Language.Name); } if (!String.IsNullOrEmpty(this.Publisher)) { writer.WriteElementString("publisher", xmlNamespace, this.Publisher); } if (!String.IsNullOrEmpty(this.Relation)) { writer.WriteElementString("relation", xmlNamespace, this.Relation); } if (!String.IsNullOrEmpty(this.Rights)) { writer.WriteElementString("rights", xmlNamespace, this.Rights); } if (!String.IsNullOrEmpty(this.Source)) { writer.WriteElementString("source", xmlNamespace, this.Source); } if (!String.IsNullOrEmpty(this.Subject)) { writer.WriteElementString("subject", xmlNamespace, this.Subject); } if (!String.IsNullOrEmpty(this.Title)) { writer.WriteElementString("title", xmlNamespace, this.Title); } if (this.TypeVocabulary != DublinCoreTypeVocabularies.None) { writer.WriteElementString("type", xmlNamespace, DublinCoreElementSetSyndicationExtension.TypeVocabularyAsString(this.TypeVocabulary)); } }
/// <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(); }