コード例 #1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="onPremisesPublishingProfileToInitialize">The <see cref="OnPremisesPublishingProfile"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(OnPremisesPublishingProfile onPremisesPublishingProfileToInitialize)
        {
            if (onPremisesPublishingProfileToInitialize != null && onPremisesPublishingProfileToInitialize.AdditionalData != null)
            {
                if (onPremisesPublishingProfileToInitialize.Agents != null && onPremisesPublishingProfileToInitialize.Agents.CurrentPage != null)
                {
                    onPremisesPublishingProfileToInitialize.Agents.AdditionalData = onPremisesPublishingProfileToInitialize.AdditionalData;

                    object nextPageLink;
                    onPremisesPublishingProfileToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        onPremisesPublishingProfileToInitialize.Agents.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (onPremisesPublishingProfileToInitialize.AgentGroups != null && onPremisesPublishingProfileToInitialize.AgentGroups.CurrentPage != null)
                {
                    onPremisesPublishingProfileToInitialize.AgentGroups.AdditionalData = onPremisesPublishingProfileToInitialize.AdditionalData;

                    object nextPageLink;
                    onPremisesPublishingProfileToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        onPremisesPublishingProfileToInitialize.AgentGroups.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (onPremisesPublishingProfileToInitialize.PublishedResources != null && onPremisesPublishingProfileToInitialize.PublishedResources.CurrentPage != null)
                {
                    onPremisesPublishingProfileToInitialize.PublishedResources.AdditionalData = onPremisesPublishingProfileToInitialize.AdditionalData;

                    object nextPageLink;
                    onPremisesPublishingProfileToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        onPremisesPublishingProfileToInitialize.PublishedResources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds the specified OnPremisesPublishingProfile to the collection via POST.
 /// </summary>
 /// <param name="onPremisesPublishingProfile">The OnPremisesPublishingProfile to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created OnPremisesPublishingProfile.</returns>
 public System.Threading.Tasks.Task <OnPremisesPublishingProfile> AddAsync(OnPremisesPublishingProfile onPremisesPublishingProfile, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <OnPremisesPublishingProfile>(onPremisesPublishingProfile, cancellationToken));
 }
コード例 #3
0
 /// <summary>
 /// Adds the specified OnPremisesPublishingProfile to the collection via POST.
 /// </summary>
 /// <param name="onPremisesPublishingProfile">The OnPremisesPublishingProfile to add.</param>
 /// <returns>The created OnPremisesPublishingProfile.</returns>
 public System.Threading.Tasks.Task <OnPremisesPublishingProfile> AddAsync(OnPremisesPublishingProfile onPremisesPublishingProfile)
 {
     return(this.AddAsync(onPremisesPublishingProfile, CancellationToken.None));
 }
コード例 #4
0
        /// <summary>
        /// Creates the specified OnPremisesPublishingProfile using POST.
        /// </summary>
        /// <param name="onPremisesPublishingProfileToCreate">The OnPremisesPublishingProfile to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created OnPremisesPublishingProfile.</returns>
        public async System.Threading.Tasks.Task <OnPremisesPublishingProfile> CreateAsync(OnPremisesPublishingProfile onPremisesPublishingProfileToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <OnPremisesPublishingProfile>(onPremisesPublishingProfileToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #5
0
        /// <summary>
        /// Updates the specified OnPremisesPublishingProfile using PATCH.
        /// </summary>
        /// <param name="onPremisesPublishingProfileToUpdate">The OnPremisesPublishingProfile to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated OnPremisesPublishingProfile.</returns>
        public async System.Threading.Tasks.Task <OnPremisesPublishingProfile> UpdateAsync(OnPremisesPublishingProfile onPremisesPublishingProfileToUpdate, CancellationToken cancellationToken)
        {
            if (onPremisesPublishingProfileToUpdate.AdditionalData != null)
            {
                if (onPremisesPublishingProfileToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    onPremisesPublishingProfileToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, onPremisesPublishingProfileToUpdate.GetType().Name)
                    });
                }
            }
            if (onPremisesPublishingProfileToUpdate.AdditionalData != null)
            {
                if (onPremisesPublishingProfileToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    onPremisesPublishingProfileToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, onPremisesPublishingProfileToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <OnPremisesPublishingProfile>(onPremisesPublishingProfileToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }