/// <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 jsonAttachment = base.InternalToJson(service) as JsonObject; if (service.RequestedServerVersion > ExchangeVersion.Exchange2007_SP1) { jsonAttachment.Add(XmlElementNames.IsContactPhoto, this.isContactPhoto); } if (!string.IsNullOrEmpty(this.FileName)) { using (FileStream fileStream = new FileStream(this.FileName, FileMode.Open, FileAccess.Read)) { jsonAttachment.AddBase64(XmlElementNames.Content, fileStream); } } else if (this.ContentStream != null) { jsonAttachment.AddBase64(XmlElementNames.Content, this.ContentStream); } else if (this.Content != null) { jsonAttachment.AddBase64(XmlElementNames.Content, this.Content); } else { EwsUtilities.Assert( false, "FileAttachment.WriteElementsToXml", "The attachment's content is not set."); } return(jsonAttachment); }
/// <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(XmlAttributeNames.ChangeKey, this.CharacterSet); if (this.Content != null && this.Content.Length > 0) { jsonProperty.AddBase64(JsonObject.JsonValueString, this.Content); } return(jsonProperty); }