コード例 #1
0
ファイル: Recurrence.cs プロジェクト: vsajip/ews-managed-api
        /// <summary>
        /// Compares two objects by converting them to JSON and comparing their string values
        /// </summary>
        /// <param name="otherRecurrence">object to compare to</param>
        /// <returns>true if the objects serialize to the same string</returns>
        public bool IsSame(Recurrence otherRecurrence)
        {
            if (otherRecurrence == null)
            {
                return(false);
            }

            string jsonString;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                ((JsonObject)this.InternalToJson(null)).SerializeToJson(memoryStream);
                memoryStream.Position = 0;
                using (StreamReader reader = new StreamReader(memoryStream))
                {
                    jsonString = reader.ReadToEnd();
                }
            }

            string otherJsonString;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                ((JsonObject)otherRecurrence.InternalToJson(null)).SerializeToJson(memoryStream);
                memoryStream.Position = 0;
                using (StreamReader reader = new StreamReader(memoryStream))
                {
                    otherJsonString = reader.ReadToEnd();
                }
            }

            return(String.Equals(jsonString, otherJsonString, StringComparison.Ordinal));
        }
コード例 #2
0
        /// <summary>
        /// Writes the json value.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        /// <param name="propertyBag">The property bag.</param>
        /// <param name="service">The service.</param>
        /// <param name="isUpdateOperation">if set to <c>true</c> [is update operation].</param>
        internal override void WriteJsonValue(JsonObject jsonObject, PropertyBag propertyBag, ExchangeService service, bool isUpdateOperation)
        {
            Recurrence value = propertyBag[this] as Recurrence;

            if (value != null)
            {
                jsonObject.Add(this.XmlElementName, value.InternalToJson(service));
            }
        }