예제 #1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="windowsInformationProtectionToInitialize">The <see cref="WindowsInformationProtection"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(WindowsInformationProtection windowsInformationProtectionToInitialize)
        {
            if (windowsInformationProtectionToInitialize != null && windowsInformationProtectionToInitialize.AdditionalData != null)
            {
                if (windowsInformationProtectionToInitialize.ProtectedAppLockerFiles != null && windowsInformationProtectionToInitialize.ProtectedAppLockerFiles.CurrentPage != null)
                {
                    windowsInformationProtectionToInitialize.ProtectedAppLockerFiles.AdditionalData = windowsInformationProtectionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windowsInformationProtectionToInitialize.ProtectedAppLockerFiles.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (windowsInformationProtectionToInitialize.ExemptAppLockerFiles != null && windowsInformationProtectionToInitialize.ExemptAppLockerFiles.CurrentPage != null)
                {
                    windowsInformationProtectionToInitialize.ExemptAppLockerFiles.AdditionalData = windowsInformationProtectionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windowsInformationProtectionToInitialize.ExemptAppLockerFiles.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (windowsInformationProtectionToInitialize.Assignments != null && windowsInformationProtectionToInitialize.Assignments.CurrentPage != null)
                {
                    windowsInformationProtectionToInitialize.Assignments.AdditionalData = windowsInformationProtectionToInitialize.AdditionalData;

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

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

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

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