Ejemplo n.º 1
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonResponse">The json response.</param>
        /// <param name="service">The service.</param>
        internal virtual void LoadFromJson(JsonObject jsonResponse, ExchangeService service)
        {
            this.id = jsonResponse.ReadAsString(XmlElementNames.SubscriptionId);

            if (this.UsesWatermark)
            {
                this.watermark = jsonResponse.ReadAsString(XmlElementNames.Watermark);
            }
        }
        /// <summary>
        /// Load from json.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        /// <returns>Retention policy tag object.</returns>
        internal static RetentionPolicyTag LoadFromJson(JsonObject jsonObject)
        {
            RetentionPolicyTag retentionPolicyTag = new RetentionPolicyTag();

            if (jsonObject.ContainsKey(XmlElementNames.DisplayName))
            {
                retentionPolicyTag.DisplayName = jsonObject.ReadAsString(XmlElementNames.DisplayName);
            }

            if (jsonObject.ContainsKey(XmlElementNames.RetentionId))
            {
                retentionPolicyTag.RetentionId = new Guid(jsonObject.ReadAsString(XmlElementNames.RetentionId));
            }

            if (jsonObject.ContainsKey(XmlElementNames.RetentionPeriod))
            {
                retentionPolicyTag.RetentionPeriod = jsonObject.ReadAsInt(XmlElementNames.RetentionPeriod);
            }

            if (jsonObject.ContainsKey(XmlElementNames.Type))
            {
                retentionPolicyTag.Type = jsonObject.ReadEnumValue <ElcFolderType>(XmlElementNames.Type);
            }

            if (jsonObject.ContainsKey(XmlElementNames.RetentionAction))
            {
                retentionPolicyTag.RetentionAction = jsonObject.ReadEnumValue <RetentionActionType>(XmlElementNames.RetentionAction);
            }

            if (jsonObject.ContainsKey(XmlElementNames.Description))
            {
                retentionPolicyTag.Description = jsonObject.ReadAsString(XmlElementNames.Description);
            }

            if (jsonObject.ContainsKey(XmlElementNames.IsVisible))
            {
                retentionPolicyTag.IsVisible = jsonObject.ReadAsBool(XmlElementNames.IsVisible);
            }

            if (jsonObject.ContainsKey(XmlElementNames.OptedInto))
            {
                retentionPolicyTag.OptedInto = jsonObject.ReadAsBool(XmlElementNames.OptedInto);
            }

            if (jsonObject.ContainsKey(XmlElementNames.IsArchive))
            {
                retentionPolicyTag.IsArchive = jsonObject.ReadAsBool(XmlElementNames.IsArchive);
            }

            return(retentionPolicyTag);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.Title:
                    this.title = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.FirstName:
                    this.givenName = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.MiddleName:
                    this.middleName = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.LastName:
                    this.surname = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Suffix:
                    this.suffix = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Initials:
                    this.initials = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.FullName:
                    this.fullName = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.NickName:
                    this.nickname = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.YomiFirstName:
                    this.yomiGivenName = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.YomiLastName:
                    this.yomiSurname = jsonProperty.ReadAsString(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads response elements from Json.
        /// </summary>
        /// <param name="responseObject">The response object.</param>
        /// <param name="service">The service.</param>
        internal override void ReadElementsFromJson(JsonObject responseObject, ExchangeService service)
        {
            base.ReadElementsFromJson(responseObject, service);

            if (responseObject.ContainsKey(XmlElementNames.Token))
            {
                JsonObject jsonObject = responseObject.ReadAsJsonObject(XmlElementNames.Token);

                this.Id         = jsonObject.ReadAsString(XmlElementNames.Id);
                this.TokenType  = (ClientAccessTokenType)Enum.Parse(typeof(ClientAccessTokenType), jsonObject.ReadAsString(XmlElementNames.TokenType));
                this.TokenValue = jsonObject.ReadAsString(XmlElementNames.TokenValue);
                this.TTL        = jsonObject.ReadAsInt(XmlElementNames.TTL);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads the attachment id from json.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        private void LoadAttachmentIdFromJson(JsonObject jsonObject)
        {
            this.id = jsonObject.ReadAsString(XmlAttributeNames.Id);

            if (this.Owner != null &&
                jsonObject.ContainsKey(XmlAttributeNames.RootItemChangeKey))
            {
                string rootItemChangeKey = jsonObject.ReadAsString(XmlAttributeNames.RootItemChangeKey);

                if (!string.IsNullOrEmpty(rootItemChangeKey))
                {
                    this.Owner.RootItemId.ChangeKey = rootItemChangeKey;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.PhoneCallState:
                    this.state = jsonProperty.ReadEnumValue <PhoneCallState>(key);
                    break;

                case XmlElementNames.ConnectionFailureCause:
                    this.connectionFailureCause = jsonProperty.ReadEnumValue <ConnectionFailureCause>(key);
                    break;

                case XmlElementNames.SIPResponseText:
                    this.sipResponseText = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.SIPResponseCode:
                    this.sipResponseCode = jsonProperty.ReadAsInt(key);
                    break;

                default:
                    break;
                }
            }
        }
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            base.LoadFromJson(jsonProperty, service);

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlAttributeNames.Id:
                    this.id = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Transition:

                    foreach (object uncastJsonTransition in jsonProperty.ReadAsArray(key))
                    {
                        JsonObject         jsonTransition = uncastJsonTransition as JsonObject;
                        TimeZoneTransition transition     = TimeZoneTransition.Create(this.timeZoneDefinition, jsonTransition.ReadTypeString());

                        transition.LoadFromJson(jsonTransition, service);

                        this.transitions.Add(transition);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.IsUndecidedApprovalRequest:
                    this.isUndecidedApprovalRequest = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.ApprovalDecision:
                    this.approvalDecision = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.ApprovalDecisionMaker:
                    this.approvalDecisionMaker = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.ApprovalDecisionTime:
                    this.approvalDecisionTime = service.ConvertUniversalDateTimeStringToLocalDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                default:
                    break;
                }
            }
        }
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.Bias:
                    this.delta = TimeSpan.FromMinutes(jsonProperty.ReadAsInt(key));
                    break;

                case XmlElementNames.Time:
                    this.timeOfDay = TimeSpan.Parse(jsonProperty.ReadAsString(key));
                    break;

                case XmlElementNames.DayOrder:
                    this.dayOrder = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.DayOfWeek:
                    this.dayOfTheWeek = jsonProperty.ReadEnumValue <DayOfTheWeek>(key);
                    break;

                case XmlElementNames.Month:
                    this.month = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.Year:
                    this.year = jsonProperty.ReadAsInt(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.UserOptions:
                    Object[] votingOptionObjects = jsonProperty.ReadAsArray(XmlElementNames.UserOptions);
                    if (votingOptionObjects != null)
                    {
                        foreach (object votingOptionObject in votingOptionObjects)
                        {
                            JsonObject       jsonObject = votingOptionObject as JsonObject;
                            VotingOptionData option     = new VotingOptionData();

                            option.LoadFromJson(jsonObject, service);
                            this.userOptions.Add(option);
                        }
                    }
                    break;

                case XmlElementNames.VotingResponse:
                    this.votingResponse = jsonProperty.ReadAsString(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.DayOfWeek:
                    EwsUtilities.ParseEnumValueList <DayOfTheWeek>(
                        this.daysOfWeek,
                        jsonProperty.ReadAsString(key),
                        ' ');
                    break;

                case XmlElementNames.StartTimeInMinutes:
                    this.startTime = TimeSpan.FromMinutes(jsonProperty.ReadAsInt(key));
                    break;

                case XmlElementNames.EndTimeInMinutes:
                    this.endTime = TimeSpan.FromMinutes(jsonProperty.ReadAsInt(key));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.ItemId:
                    this.itemId = new ItemId();
                    this.itemId.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.Start:
                    this.start = service.ConvertUniversalDateTimeStringToLocalDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                case XmlElementNames.End:
                    this.end = service.ConvertUniversalDateTimeStringToLocalDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                case XmlElementNames.OriginalStart:
                    this.originalStart = service.ConvertUniversalDateTimeStringToLocalDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                default:
                    break;
                }
            }
        }
        /// <summary>
        /// Load from json
        /// </summary>
        /// <param name="jsonObject">The json object</param>
        /// <returns>Mailbox hold object</returns>
        internal static MailboxHoldResult LoadFromJson(JsonObject jsonObject)
        {
            List <MailboxHoldStatus> statuses   = new List <MailboxHoldStatus>();
            MailboxHoldResult        holdResult = new MailboxHoldResult();

            if (jsonObject.ContainsKey(XmlElementNames.HoldId))
            {
                holdResult.HoldId = jsonObject.ReadAsString(XmlElementNames.HoldId);
            }

            if (jsonObject.ContainsKey(XmlElementNames.Query))
            {
                holdResult.Query = jsonObject.ReadAsString(XmlElementNames.Query);
            }

            if (jsonObject.ContainsKey(XmlElementNames.Statuses))
            {
                foreach (object statusObject in jsonObject.ReadAsArray(XmlElementNames.Statuses))
                {
                    MailboxHoldStatus status     = new MailboxHoldStatus();
                    JsonObject        jsonStatus = statusObject as JsonObject;

                    if (jsonStatus.ContainsKey(XmlElementNames.Mailbox))
                    {
                        status.Mailbox = jsonStatus.ReadAsString(XmlElementNames.Mailbox);
                    }

                    if (jsonStatus.ContainsKey(XmlElementNames.Status))
                    {
                        status.Status = (HoldStatus)Enum.Parse(typeof(HoldStatus), jsonStatus.ReadAsString(XmlElementNames.Status));
                    }

                    if (jsonStatus.ContainsKey(XmlElementNames.AdditionalInfo))
                    {
                        status.AdditionalInfo = jsonStatus.ReadAsString(XmlElementNames.AdditionalInfo);
                    }

                    statuses.Add(status);
                }
            }

            holdResult.Statuses = statuses.Count == 0 ? null : statuses.ToArray();

            return(holdResult);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Load from json
        /// </summary>
        /// <param name="jsonObject">The json object</param>
        /// <returns>Discovery search configuration object</returns>
        internal static DiscoverySearchConfiguration LoadFromJson(JsonObject jsonObject)
        {
            List <SearchableMailbox>     mailboxes     = new List <SearchableMailbox>();
            DiscoverySearchConfiguration configuration = new DiscoverySearchConfiguration();

            if (jsonObject.ContainsKey(XmlElementNames.SearchId))
            {
                configuration.SearchId = jsonObject.ReadAsString(XmlElementNames.SearchId);
            }

            if (jsonObject.ContainsKey(XmlElementNames.InPlaceHoldIdentity))
            {
                configuration.InPlaceHoldIdentity = jsonObject.ReadAsString(XmlElementNames.InPlaceHoldIdentity);
            }

            if (jsonObject.ContainsKey(XmlElementNames.ManagedByOrganization))
            {
                configuration.ManagedByOrganization = jsonObject.ReadAsString(XmlElementNames.ManagedByOrganization);
            }

            if (jsonObject.ContainsKey(XmlElementNames.SearchQuery))
            {
                configuration.SearchQuery = jsonObject.ReadAsString(XmlElementNames.SearchQuery);
            }

            if (jsonObject.ContainsKey(XmlElementNames.SearchableMailboxes))
            {
                foreach (object searchableMailboxObject in jsonObject.ReadAsArray(XmlElementNames.SearchableMailboxes))
                {
                    JsonObject jsonSearchableMailbox = searchableMailboxObject as JsonObject;

                    mailboxes.Add(SearchableMailbox.LoadFromJson(jsonSearchableMailbox));
                }
            }

            if (jsonObject.ContainsKey(XmlElementNames.Language))
            {
                configuration.Language = jsonObject.ReadAsString(XmlElementNames.Language);
            }

            configuration.SearchableMailboxes = mailboxes.Count == 0 ? null : mailboxes.ToArray();

            return(configuration);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlAttributeNames.Id:
                    this.uniqueId = jsonProperty.ReadAsString(key);
                    break;

                case XmlAttributeNames.ChangeKey:
                    this.changeKey = jsonProperty.ReadAsString(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.ID:
                    this.storeId = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Subject:
                    this.subject = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Location:
                    this.location = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.IsMeeting:
                    this.isMeeting = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsRecurring:
                    this.isRecurring = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsException:
                    this.isException = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsReminderSet:
                    this.isReminderSet = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsPrivate:
                    this.isPrivate = jsonProperty.ReadAsBool(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.AttachmentId:
                    this.LoadAttachmentIdFromJson(jsonProperty.ReadAsJsonObject(key));
                    break;

                case XmlElementNames.Name:
                    this.name = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.ContentType:
                    this.contentType = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.ContentId:
                    this.contentId = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.ContentLocation:
                    this.contentLocation = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Size:
                    this.size = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.LastModifiedTime:
                    this.lastModifiedTime = service.ConvertUniversalDateTimeStringToLocalDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                case XmlElementNames.IsInline:
                    this.isInline = jsonProperty.ReadAsBool(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service"></param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlAttributeNames.HeaderName:
                    this.name = jsonProperty.ReadAsString(key);
                    break;

                case JsonObject.JsonValueString:
                    this.value = jsonProperty.ReadAsString(key);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Parses the specified json object.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        /// <returns></returns>
        internal static ExchangeServerInfo Parse(JsonObject jsonObject)
        {
            ExchangeServerInfo info = new ExchangeServerInfo();

            info.MajorVersion     = jsonObject.ReadAsInt("MajorVersion");
            info.MinorVersion     = jsonObject.ReadAsInt("MinorVersion");
            info.MajorBuildNumber = jsonObject.ReadAsInt("MajorBuildNumber");
            info.MinorBuildNumber = jsonObject.ReadAsInt("MinorBuildNumber");
            info.VersionString    = jsonObject.ReadAsString("Version");
            return(info);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Load from json
        /// </summary>
        /// <param name="jsonObject">The json object</param>
        /// <returns>Searchable mailbox object</returns>
        internal static SearchableMailbox LoadFromJson(JsonObject jsonObject)
        {
            SearchableMailbox searchableMailbox = new SearchableMailbox();

            if (jsonObject.ContainsKey(XmlElementNames.Guid))
            {
                searchableMailbox.Guid = new Guid(jsonObject.ReadAsString(XmlElementNames.Guid));
            }

            if (jsonObject.ContainsKey(XmlElementNames.DisplayName))
            {
                searchableMailbox.DisplayName = jsonObject.ReadAsString(XmlElementNames.DisplayName);
            }

            if (jsonObject.ContainsKey(XmlElementNames.PrimarySmtpAddress))
            {
                searchableMailbox.SmtpAddress = jsonObject.ReadAsString(XmlElementNames.PrimarySmtpAddress);
            }

            if (jsonObject.ContainsKey(XmlElementNames.IsExternalMailbox))
            {
                searchableMailbox.IsExternalMailbox = jsonObject.ReadAsBool(XmlElementNames.IsExternalMailbox);
            }

            if (jsonObject.ContainsKey(XmlElementNames.ExternalEmailAddress))
            {
                searchableMailbox.ExternalEmailAddress = jsonObject.ReadAsString(XmlElementNames.ExternalEmailAddress);
            }

            if (jsonObject.ContainsKey(XmlElementNames.IsMembershipGroup))
            {
                searchableMailbox.IsMembershipGroup = jsonObject.ReadAsBool(XmlElementNames.IsMembershipGroup);
            }

            if (jsonObject.ContainsKey(XmlElementNames.ReferenceId))
            {
                searchableMailbox.ReferenceId = jsonObject.ReadAsString(XmlElementNames.ReferenceId);
            }

            return(searchableMailbox);
        }
        /// <summary>
        /// Tries to load from XML.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        /// <returns>True if property was loaded.</returns>
        internal static PropertyDefinitionBase TryLoadFromJson(JsonObject jsonObject)
        {
            switch (jsonObject.ReadTypeString())
            {
            case JsonNames.PathToUnindexedFieldType:
                return(ServiceObjectSchema.FindPropertyDefinition(jsonObject.ReadAsString(XmlAttributeNames.FieldURI)));

            case JsonNames.PathToIndexedFieldType:
                return(new IndexedPropertyDefinition(
                           jsonObject.ReadAsString(XmlAttributeNames.FieldURI),
                           jsonObject.ReadAsString(XmlAttributeNames.FieldIndex)));

            case JsonNames.PathToExtendedFieldType:
                ExtendedPropertyDefinition propertyDefinition = new ExtendedPropertyDefinition();
                propertyDefinition.LoadFromJson(jsonObject);
                return(propertyDefinition);

            default:
                return(null);
            }
        }
        /// <summary>
        /// Gets the dictionary object.
        /// </summary>
        /// <param name="jsonObject">The json object.</param>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        private object GetDictionaryObject(JsonObject jsonObject, ExchangeService service)
        {
            if (jsonObject == null)
            {
                return(null);
            }

            UserConfigurationDictionaryObjectType type = GetObjectType(jsonObject.ReadAsString(XmlElementNames.Type));

            List <string> values = this.GetObjectValue(jsonObject.ReadAsArray(XmlElementNames.Value));

            return(this.ConstructObject(type, values, service));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="responseObject">The response object.</param>
        /// <param name="service">The service.</param>
        internal void LoadFromJson(JsonObject responseObject, ExchangeService service)
        {
            foreach (string key in responseObject.Keys)
            {
                switch (key)
                {
                case XmlElementNames.UserConfigurationName:
                    JsonObject jsonUserConfigName = responseObject.ReadAsJsonObject(key);
                    string     responseName       = jsonUserConfigName.ReadAsString(XmlAttributeNames.Name);

                    EwsUtilities.Assert(
                        string.Compare(this.name, responseName, StringComparison.Ordinal) == 0,
                        "UserConfiguration.LoadFromJson",
                        "UserConfigurationName does not match: Expected: " + this.name + " Name in response: " + responseName);

                    break;

                case XmlElementNames.ItemId:
                    this.itemId = new ItemId();
                    this.itemId.LoadFromJson(responseObject.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.Dictionary:
                    ((IJsonCollectionDeserializer)this.dictionary).CreateFromJsonCollection(responseObject.ReadAsArray(key), service);
                    break;

                case XmlElementNames.XmlData:
                    this.xmlData = Convert.FromBase64String(responseObject.ReadAsString(key));
                    break;

                case XmlElementNames.BinaryData:
                    this.binaryData = Convert.FromBase64String(responseObject.ReadAsString(key));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            base.LoadFromJson(jsonProperty, service);

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlAttributeNames.Id:
                    this.id = jsonProperty.ReadAsString(key);
                    break;

                case XmlAttributeNames.Name:
                    this.name = jsonProperty.ReadAsString(key);
                    break;

                case XmlAttributeNames.Bias:
                    this.bias = EwsUtilities.XSDurationToTimeSpan(jsonProperty.ReadAsString(key));
                    break;
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            this.InternetMessageId = jsonProperty.ReadAsString(XmlElementNames.ConversationIndex);

            if (jsonProperty.ContainsKey(XmlElementNames.ParentInternetMessageId))
            {
                this.ParentInternetMessageId = jsonProperty.ReadAsString(XmlElementNames.ParentInternetMessageId);
            }

            if (jsonProperty.ContainsKey(XmlElementNames.Items))
            {
                EwsServiceJsonReader jsonReader = new EwsServiceJsonReader(service);

                this.Items = jsonReader.ReadServiceObjectsCollectionFromJson <Item>(
                    jsonProperty,
                    XmlElementNames.Items,
                    this.GetObjectInstance,
                    false,              /* clearPropertyBag */
                    this.propertySet,   /* requestedPropertySet */
                    false);             /* summaryPropertiesOnly */
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="responseObject">The response object.</param>
        /// <param name="service">The service.</param>
        internal void LoadFromJson(JsonObject responseObject, ExchangeService service)
        {
            this.result    = (ServiceResult)Enum.Parse(typeof(ServiceResult), responseObject.ReadAsString(XmlAttributeNames.ResponseClass));
            this.errorCode = (ServiceError)Enum.Parse(typeof(ServiceError), responseObject.ReadAsString(XmlElementNames.ResponseCode));

            // TODO: Deal with a JSON version of "LoadExtraDetailsFromXml"
            if (this.result == ServiceResult.Warning || this.result == ServiceResult.Error)
            {
                this.errorMessage = responseObject.ReadAsString(XmlElementNames.MessageText);
            }

            if (this.result == ServiceResult.Success || this.result == ServiceResult.Warning)
            {
                if (!this.BatchProcessingStopped)
                {
                    this.ReadElementsFromJson(responseObject, service);
                }
            }

            this.MapErrorCodeToErrorMessage();

            this.Loaded();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            this.date    = DateTime.Parse(jsonProperty.ReadAsString(XmlElementNames.Date));
            this.quality = jsonProperty.ReadEnumValue <SuggestionQuality>(XmlElementNames.DayQuality);

            foreach (object jsonSuggestion in jsonProperty.ReadAsArray(XmlElementNames.SuggestionArray))
            {
                TimeSuggestion timeSuggestion = new TimeSuggestion();

                timeSuggestion.LoadFromJson(jsonSuggestion as JsonObject, service);

                this.timeSuggestions.Add(timeSuggestion);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            this.ConversationId = new ConversationId();
            this.ConversationId.LoadFromJson(jsonProperty.ReadAsJsonObject(XmlElementNames.ConversationId), service);

            if (jsonProperty.ContainsKey(XmlElementNames.SyncState))
            {
                this.SyncState = jsonProperty.ReadAsString(XmlElementNames.SyncState);
            }

            this.ConversationNodes = new ConversationNodeCollection(this.propertySet);
            ((IJsonCollectionDeserializer)this.ConversationNodes).CreateFromJsonCollection(
                jsonProperty.ReadAsArray(XmlElementNames.ConversationNodes),
                service);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Loads from json.
 /// </summary>
 /// <param name="jsonProperty">The json property.</param>
 /// <param name="service">The service.</param>
 internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
 {
     this.Key             = jsonProperty.ReadEnumValue <PhysicalAddressKey>(XmlAttributeNames.Key);
     this.Street          = jsonProperty.ReadAsString(XmlElementNames.Street);
     this.City            = jsonProperty.ReadAsString(XmlElementNames.City);
     this.State           = jsonProperty.ReadAsString(XmlElementNames.State);
     this.Street          = jsonProperty.ReadAsString(XmlElementNames.Street);
     this.CountryOrRegion = jsonProperty.ReadAsString(XmlElementNames.CountryOrRegion);
     this.PostalCode      = jsonProperty.ReadAsString(XmlElementNames.PostalCode);
 }
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            base.LoadFromJson(jsonProperty, service);

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.EndDate:
                    this.endDate = service.ConvertStartDateToUnspecifiedDateTime(jsonProperty.ReadAsString(key)).Value;
                    break;

                default:
                    break;
                }
            }
        }