示例#1
0
 /// <summary>
 /// Adds the specified OfficeClientConfiguration to the collection via POST.
 /// </summary>
 /// <param name="officeClientConfiguration">The OfficeClientConfiguration to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created OfficeClientConfiguration.</returns>
 public System.Threading.Tasks.Task <OfficeClientConfiguration> AddAsync(OfficeClientConfiguration officeClientConfiguration, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     officeClientConfiguration.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(officeClientConfiguration.GetType().FullName));
     return(this.SendAsync <OfficeClientConfiguration>(officeClientConfiguration, cancellationToken));
 }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="officeClientConfigurationToInitialize">The <see cref="OfficeClientConfiguration"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(OfficeClientConfiguration officeClientConfigurationToInitialize)
        {
            if (officeClientConfigurationToInitialize != null && officeClientConfigurationToInitialize.AdditionalData != null)
            {
                if (officeClientConfigurationToInitialize.Assignments != null && officeClientConfigurationToInitialize.Assignments.CurrentPage != null)
                {
                    officeClientConfigurationToInitialize.Assignments.AdditionalData = officeClientConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        officeClientConfigurationToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified OfficeClientConfiguration using POST.
        /// </summary>
        /// <param name="officeClientConfigurationToCreate">The OfficeClientConfiguration to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created OfficeClientConfiguration.</returns>
        public async System.Threading.Tasks.Task <OfficeClientConfiguration> CreateAsync(OfficeClientConfiguration officeClientConfigurationToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <OfficeClientConfiguration>(officeClientConfigurationToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Creates the specified OfficeClientConfiguration using POST.
 /// </summary>
 /// <param name="officeClientConfigurationToCreate">The OfficeClientConfiguration to create.</param>
 /// <returns>The created OfficeClientConfiguration.</returns>
 public System.Threading.Tasks.Task <OfficeClientConfiguration> CreateAsync(OfficeClientConfiguration officeClientConfigurationToCreate)
 {
     return(this.CreateAsync(officeClientConfigurationToCreate, CancellationToken.None));
 }
        /// <summary>
        /// Updates the specified OfficeClientConfiguration using PATCH.
        /// </summary>
        /// <param name="officeClientConfigurationToUpdate">The OfficeClientConfiguration 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 OfficeClientConfiguration.</returns>
        public async System.Threading.Tasks.Task <OfficeClientConfiguration> UpdateAsync(OfficeClientConfiguration officeClientConfigurationToUpdate, CancellationToken cancellationToken)
        {
            if (officeClientConfigurationToUpdate.AdditionalData != null)
            {
                if (officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, officeClientConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            if (officeClientConfigurationToUpdate.AdditionalData != null)
            {
                if (officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, officeClientConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <OfficeClientConfiguration>(officeClientConfigurationToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
示例#6
0
 /// <summary>
 /// Adds the specified OfficeClientConfiguration to the collection via POST.
 /// </summary>
 /// <param name="officeClientConfiguration">The OfficeClientConfiguration to add.</param>
 /// <returns>The created OfficeClientConfiguration.</returns>
 public System.Threading.Tasks.Task <OfficeClientConfiguration> AddAsync(OfficeClientConfiguration officeClientConfiguration)
 {
     return(this.AddAsync(officeClientConfiguration, CancellationToken.None));
 }