Ejemplo n.º 1
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.UserId:
                    this.userId = new UserId();
                    this.userId.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.DelegatePermissions:
                    this.permissions.Reset();
                    this.permissions.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.ReceiveCopiesOfMeetingMessages:
                    this.receiveCopiesOfMeetingMessages = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.ViewPrivateItems:
                    this.viewPrivateItems = jsonProperty.ReadAsBool(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)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.HasLocationChanged:
                    this.hasLocationChanged = jsonProperty.ReadAsBool(key);
                    break;

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

                case XmlElementNames.HasStartTimeChanged:
                    this.hasStartTimeChanged = jsonProperty.ReadAsBool(key);
                    break;

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

                case XmlElementNames.HasEndTimeChanged:
                    this.hasEndTimeChanged = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.End:
                    this.end = 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.CanDelete:
                    this.canDelete = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.CanRenameOrMove:
                    this.canRenameOrMove = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.MustDisplayComment:
                    this.mustDisplayComment = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.HasQuota:
                    this.hasQuota = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsManagedFoldersRoot:
                    this.isManagedFoldersRoot = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.ManagedFolderId:
                    this.managedFolderId = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.Comment:
                    string commentValue = jsonProperty.ReadAsString(key);
                    if (commentValue != null)
                    {
                        this.comment = commentValue;
                    }
                    break;

                case XmlElementNames.StorageQuota:
                    this.storageQuota = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.FolderSize:
                    this.folderSize = jsonProperty.ReadAsInt(key);
                    break;

                case XmlElementNames.HomePage:
                    string homePageValue = jsonProperty.ReadAsString(key);
                    if (homePageValue != null)
                    {
                        this.homePage = homePageValue;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 4
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.UserId:
                    this.UserId = new UserId();
                    this.UserId.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.CanCreateItems:
                    this.canCreateItems = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.CanCreateSubFolders:
                    this.canCreateSubFolders = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsFolderOwner:
                    this.isFolderOwner = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsFolderVisible:
                    this.isFolderVisible = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.IsFolderContact:
                    this.isFolderContact = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.EditItems:
                    this.editItems = jsonProperty.ReadEnumValue <PermissionScope>(key);
                    break;

                case XmlElementNames.DeleteItems:
                    this.deleteItems = jsonProperty.ReadEnumValue <PermissionScope>(key);
                    break;

                case XmlElementNames.ReadItems:
                    this.readItems = jsonProperty.ReadEnumValue <FolderPermissionReadAccess>(key);
                    break;

                case XmlElementNames.PermissionLevel:
                case XmlElementNames.CalendarPermissionLevel:
                    this.permissionLevel = jsonProperty.ReadEnumValue <FolderPermissionLevel>(key);
                    break;

                default:
                    break;
                }
            }

            this.AdjustPermissionLevel();
        }
        /// <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.º 6
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;
                }
            }
        }
Ejemplo n.º 7
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)
        {
            JsonObject rootFolder = responseObject.ReadAsJsonObject(XmlElementNames.RootFolder);

            this.results.TotalCount    = rootFolder.ReadAsInt(XmlAttributeNames.TotalItemsInView);
            this.results.MoreAvailable = rootFolder.ReadAsBool(XmlAttributeNames.IncludesLastItemInRange);

            // Ignore IndexedPagingOffset attribute if MoreAvailable is false.
            if (results.MoreAvailable)
            {
                if (rootFolder.ContainsKey(XmlAttributeNames.IndexedPagingOffset))
                {
                    this.results.NextPageOffset = rootFolder.ReadAsInt(XmlAttributeNames.IndexedPagingOffset);
                }
                else
                {
                    this.results.NextPageOffset = null;
                }
            }

            if (rootFolder.ContainsKey(XmlElementNames.Folders))
            {
                List <Folder> folders = new EwsServiceJsonReader(service).ReadServiceObjectsCollectionFromJson <Folder>(
                    rootFolder,
                    XmlElementNames.Folders,
                    this.CreateFolderInstance,
                    true,               /* clearPropertyBag */
                    this.propertySet,   /* requestedPropertySet */
                    true);              /* summaryPropertiesOnly */

                folders.ForEach((folder) => this.results.Folders.Add(folder));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="eventsResponse">The events response.</param>
        /// <param name="service">The service.</param>
        internal void LoadFromJson(JsonObject eventsResponse, ExchangeService service)
        {
            foreach (string key in eventsResponse.Keys)
            {
                switch (key)
                {
                case XmlElementNames.SubscriptionId:
                    this.subscriptionId = eventsResponse.ReadAsString(key);
                    break;

                case XmlElementNames.PreviousWatermark:
                    this.previousWatermark = eventsResponse.ReadAsString(key);
                    break;

                case XmlElementNames.MoreEvents:
                    this.moreEventsAvailable = eventsResponse.ReadAsBool(key);
                    break;

                case JsonNames.Events:
                    this.LoadEventsFromJson(eventsResponse.ReadAsArray(key), service);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 9
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)
        {
            base.LoadFromJson(jsonProperty, service);

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.AttachLongPathName:
                    this.attachLongPathName = jsonProperty.ReadAsString(key);
                    break;

                case XmlElementNames.ProviderType:
                    this.providerType = jsonProperty.ReadAsString(key);
                    break;

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

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

                default:
                    break;
                }
            }
        }
Ejemplo n.º 10
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.º 11
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);
        }
Ejemplo n.º 12
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)
        {
            base.LoadFromJson(jsonProperty, service);

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.IsContactPhoto:
                    this.isContactPhoto = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.Content:
                    if (this.loadToStream != null)
                    {
                        jsonProperty.ReadAsBase64Content(key, this.loadToStream);
                    }
                    else
                    {
                        // If there's a file attachment content handler, use it. Otherwise
                        // load the content into a byte array.
                        // TODO: Should we mark the attachment to indicate that content is stored elsewhere?
                        if (service.FileAttachmentContentHandler != null)
                        {
                            Stream outputStream = service.FileAttachmentContentHandler.GetOutputStream(this.Id);

                            if (outputStream != null)
                            {
                                jsonProperty.ReadAsBase64Content(key, outputStream);
                            }
                            else
                            {
                                this.content = jsonProperty.ReadAsBase64Content(key);
                            }
                        }
                        else
                        {
                            this.content = jsonProperty.ReadAsBase64Content(key);
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 13
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 XmlAttributeNames.IsExplicit:
                    this.isExplicit = jsonProperty.ReadAsBool(key);
                    break;

                case JsonObject.JsonValueString:
                    this.retentionId = new Guid(jsonProperty.ReadAsString(key));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 14
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;
                }
            }
        }
        /// <summary>
        /// Loads from json array.
        /// </summary>
        /// <param name="jsonProperty">The p.</param>
        /// <param name="service">The service.</param>
        internal void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            int totalItemsInView;

            object[] resolutions;

            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlAttributeNames.TotalItemsInView:
                    totalItemsInView = jsonProperty.ReadAsInt(key);
                    break;

                case XmlAttributeNames.IncludesLastItemInRange:
                    this.includesAllResolutions = jsonProperty.ReadAsBool(key);
                    break;

                // This label only exists for Json objects.  The XML doesn't have a "Resolutions"
                // element.
                // This was necessary becaue of the lack of attributes in JSON
                //
                case "Resolutions":
                    resolutions = jsonProperty.ReadAsArray(key);
                    foreach (object resolution in resolutions)
                    {
                        JsonObject resolutionProperty = resolution as JsonObject;
                        if (resolutionProperty != null)
                        {
                            NameResolution nameResolution = new NameResolution(this);
                            nameResolution.LoadFromJson(resolutionProperty, service);
                            this.items.Add(nameResolution);
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 16
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.AssignCategories:
                    this.assignCategories.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.CopyToFolder:
                    this.copyToFolder = new FolderId();
                    this.copyToFolder.LoadFromJson(
                        jsonProperty.ReadAsJsonObject(key),
                        service);
                    break;

                case XmlElementNames.Delete:
                    this.delete = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.ForwardAsAttachmentToRecipients:
                    this.forwardAsAttachmentToRecipients.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.ForwardToRecipients:
                    this.forwardToRecipients.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.MarkImportance:
                    this.markImportance = jsonProperty.ReadEnumValue <Importance>(key);
                    break;

                case XmlElementNames.MarkAsRead:
                    this.markAsRead = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.MoveToFolder:
                    this.moveToFolder = new FolderId();
                    this.moveToFolder.LoadFromJson(
                        jsonProperty.ReadAsJsonObject(key),
                        service);
                    break;

                case XmlElementNames.PermanentDelete:
                    this.permanentDelete = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.RedirectToRecipients:
                    this.redirectToRecipients.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.SendSMSAlertToRecipients:
                    EmailAddressCollection smsRecipientCollection = new EmailAddressCollection(XmlElementNames.Address);
                    smsRecipientCollection.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    this.sendSMSAlertToRecipients = ConvertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection(smsRecipientCollection);
                    break;

                case XmlElementNames.ServerReplyWithMessage:
                    this.serverReplyWithMessage = new ItemId();
                    this.serverReplyWithMessage.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);
                    break;

                case XmlElementNames.StopProcessingRules:
                    this.stopProcessingRules = 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">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.MeetingTime:
                    this.meetingTime = EwsUtilities.ParseAsUnbiasedDatetimescopedToServicetimeZone(jsonProperty.ReadAsString(key), service);
                    break;

                case XmlElementNames.IsWorkTime:
                    this.isWorkTime = jsonProperty.ReadAsBool(key);
                    break;

                case XmlElementNames.SuggestionQuality:
                    this.quality = jsonProperty.ReadEnumValue <SuggestionQuality>(key);
                    break;

                case XmlElementNames.AttendeeConflictDataArray:
                    object[] jsonConflictArray = jsonProperty.ReadAsArray(key);
                    foreach (object conflictObject in jsonConflictArray)
                    {
                        JsonObject jsonConflict = conflictObject as JsonObject;
                        if (jsonConflict != null)
                        {
                            Conflict conflict = null;

                            switch (jsonConflict.ReadTypeString())
                            {
                            case XmlElementNames.UnknownAttendeeConflictData:
                                conflict = new Conflict(ConflictType.UnknownAttendeeConflict);
                                break;

                            case XmlElementNames.TooBigGroupAttendeeConflictData:
                                conflict = new Conflict(ConflictType.GroupTooBigConflict);
                                break;

                            case XmlElementNames.IndividualAttendeeConflictData:
                                conflict = new Conflict(ConflictType.IndividualAttendeeConflict);
                                break;

                            case XmlElementNames.GroupAttendeeConflictData:
                                conflict = new Conflict(ConflictType.GroupConflict);
                                break;

                            default:
                                EwsUtilities.Assert(
                                    false,
                                    "TimeSuggestion.TryReadElementFromJson",
                                    string.Format("The {0} element name does not map to any AttendeeConflict descendant.", jsonConflict.ReadTypeString()));

                                // The following line to please the compiler
                                break;
                            }

                            conflict.LoadFromJson(jsonConflict, service);

                            this.conflicts.Add(conflict);
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 18
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)
        {
            this.Changes.SyncState            = responseObject.ReadAsString(XmlElementNames.SyncState);
            this.Changes.MoreChangesAvailable = !responseObject.ReadAsBool(this.GetIncludesLastInRangeXmlElementName());

            JsonObject changesElement = responseObject.ReadAsJsonObject(XmlElementNames.Changes);

            foreach (object changeElement in changesElement.ReadAsArray(XmlElementNames.Changes))
            {
                JsonObject jsonChange = changeElement as JsonObject;

                TChange change = this.CreateChangeInstance();

                string changeType = jsonChange.ReadAsString(XmlElementNames.ChangeType);

                switch (changeType)
                {
                case XmlElementNames.Create:
                    change.ChangeType = ChangeType.Create;
                    break;

                case XmlElementNames.Update:
                    change.ChangeType = ChangeType.Update;
                    break;

                case XmlElementNames.Delete:
                    change.ChangeType = ChangeType.Delete;
                    break;

                case XmlElementNames.ReadFlagChange:
                    change.ChangeType = ChangeType.ReadFlagChange;
                    break;

                default:
                    break;
                }

                if (change != null)
                {
                    switch (change.ChangeType)
                    {
                    case ChangeType.Delete:
                    case ChangeType.ReadFlagChange:
                        change.Id = change.CreateId();
                        JsonObject jsonChangeId = jsonChange.ReadAsJsonObject(this.GetChangeIdElementName());
                        change.Id.LoadFromJson(jsonChangeId, service);

                        if (change.ChangeType == ChangeType.ReadFlagChange)
                        {
                            ItemChange itemChange = change as ItemChange;

                            EwsUtilities.Assert(
                                itemChange != null,
                                "SyncResponse.ReadElementsFromJson",
                                "ReadFlagChange is only valid on ItemChange");

                            itemChange.IsRead = jsonChange.ReadAsBool(XmlElementNames.IsRead);
                        }

                        break;

                    default:
                        JsonObject jsonServiceObject = jsonChange.ReadAsJsonObject(this.GetChangeElementName());
                        change.ServiceObject = EwsUtilities.CreateEwsObjectFromXmlElementName <TServiceObject>(service, jsonServiceObject.ReadTypeString());

                        change.ServiceObject.LoadFromJson(
                            jsonServiceObject,
                            service,
                            true,                         /* clearPropertyBag */
                            this.propertySet,
                            this.SummaryPropertiesOnly);
                        break;
                    }

                    this.changes.Add(change);
                }
            }
        }
Ejemplo n.º 19
0
        internal override void LoadPropertyValueFromJson(object value, ExchangeService service, PropertyBag propertyBag)
        {
            EffectiveRights effectiveRightsValue = EffectiveRights.None;
            JsonObject      jsonObject           = value as JsonObject;

            if (jsonObject != null)
            {
                foreach (string key in jsonObject.Keys)
                {
                    switch (key)
                    {
                    case XmlElementNames.CreateAssociated:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.CreateAssociated;
                        }
                        break;

                    case XmlElementNames.CreateContents:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.CreateContents;
                        }
                        break;

                    case XmlElementNames.CreateHierarchy:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.CreateHierarchy;
                        }
                        break;

                    case XmlElementNames.Delete:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.Delete;
                        }
                        break;

                    case XmlElementNames.Modify:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.Modify;
                        }
                        break;

                    case XmlElementNames.Read:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.Read;
                        }
                        break;

                    case XmlElementNames.ViewPrivateItems:
                        if (jsonObject.ReadAsBool(key))
                        {
                            effectiveRightsValue |= EffectiveRights.ViewPrivateItems;
                        }
                        break;
                    }
                }
            }

            propertyBag[this] = value;
        }
Ejemplo n.º 20
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);

            JsonObject rootFolder         = responseObject.ReadAsJsonObject(XmlElementNames.RootFolder);
            int        totalItemsInView   = rootFolder.ReadAsInt(XmlAttributeNames.TotalItemsInView);
            bool       moreItemsAvailable = !rootFolder.ReadAsBool(XmlAttributeNames.IncludesLastItemInRange);

            // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false.
            int?nextPageOffset = null;

            if (moreItemsAvailable)
            {
                if (rootFolder.ContainsKey(XmlAttributeNames.IndexedPagingOffset))
                {
                    nextPageOffset = rootFolder.ReadAsInt(XmlAttributeNames.IndexedPagingOffset);
                }
            }

            if (!this.isGrouped)
            {
                this.results                = new FindItemsResults <TItem>();
                this.results.TotalCount     = totalItemsInView;
                this.results.NextPageOffset = nextPageOffset;
                this.results.MoreAvailable  = moreItemsAvailable;
                this.InternalReadItemsFromJson(
                    rootFolder,
                    this.propertySet,
                    service,
                    this.results.Items);
            }
            else
            {
                this.groupedFindResults                = new GroupedFindItemsResults <TItem>();
                this.groupedFindResults.TotalCount     = totalItemsInView;
                this.groupedFindResults.NextPageOffset = nextPageOffset;
                this.groupedFindResults.MoreAvailable  = moreItemsAvailable;

                if (rootFolder.ContainsKey(XmlElementNames.Groups))
                {
                    object[] jsGroups = rootFolder.ReadAsArray(XmlElementNames.Groups);

                    foreach (JsonObject jsGroup in jsGroups.OfType <JsonObject>())
                    {
                        if (jsGroup.ContainsKey(XmlElementNames.GroupedItems))
                        {
                            JsonObject jsGroupedItems = jsGroup.ReadAsJsonObject(XmlElementNames.GroupedItems);

                            string groupIndex = jsGroupedItems.ReadAsString(XmlElementNames.GroupIndex);

                            List <TItem> itemList = new List <TItem>();
                            this.InternalReadItemsFromJson(
                                jsGroupedItems,
                                this.propertySet,
                                service,
                                itemList);

                            this.groupedFindResults.ItemGroups.Add(new ItemGroup <TItem>(groupIndex, itemList));
                        }
                    }
                }
            }

            Object[] highlightTermObjects = responseObject.ReadAsArray(XmlElementNames.HighlightTerms);
            if (highlightTermObjects != null)
            {
                foreach (object highlightTermObject in highlightTermObjects)
                {
                    JsonObject    jsonHighlightTerm = highlightTermObject as JsonObject;
                    HighlightTerm term = new HighlightTerm();

                    term.LoadFromJson(jsonHighlightTerm, service);
                    this.results.HighlightTerms.Add(term);
                }
            }
        }