void WriteElementsToXml(EwsServiceXmlWriter writer) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.Bias, (int)this.delta.TotalMinutes); writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.Time, EwsUtilities.TimeSpanToXSTime(this.timeOfDay)); writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.DayOrder, this.dayOrder); writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.Month, (int)this.month); // Only write DayOfWeek if this is a recurring time change if (this.Year == 0) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.DayOfWeek, this.dayOfTheWeek); } // Only emit year if it's non zero, otherwise AS returns "Request is invalid" if (this.Year != 0) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.Year, this.Year); } }
/// <summary> /// Serializes the property to a Json value. /// </summary> /// <param name="service"></param> /// <returns> /// A Json value (either a JsonObject, an array of Json values, or a Json primitive) /// </returns> internal override object InternalToJson(ExchangeService service) { JsonObject jsonProperty = new JsonObject(); jsonProperty.Add( XmlElementNames.Bias, (int)this.delta.TotalMinutes); jsonProperty.Add( XmlElementNames.Time, EwsUtilities.TimeSpanToXSTime(this.timeOfDay)); jsonProperty.Add( XmlElementNames.DayOrder, this.dayOrder); jsonProperty.Add( XmlElementNames.Month, (int)this.month); // Only write DayOfWeek if this is a recurring time change if (this.Year == 0) { jsonProperty.Add( XmlElementNames.DayOfWeek, this.dayOfTheWeek); } // Only emit year if it's non zero, otherwise AS returns "Request is invalid" if (this.Year != 0) { jsonProperty.Add( XmlElementNames.Year, this.Year); } return(jsonProperty); }