/// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="windowsMalwareInformationToInitialize">The <see cref="WindowsMalwareInformation"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(WindowsMalwareInformation windowsMalwareInformationToInitialize)
        {
            if (windowsMalwareInformationToInitialize != null && windowsMalwareInformationToInitialize.AdditionalData != null)
            {
                if (windowsMalwareInformationToInitialize.DeviceMalwareStates != null && windowsMalwareInformationToInitialize.DeviceMalwareStates.CurrentPage != null)
                {
                    windowsMalwareInformationToInitialize.DeviceMalwareStates.AdditionalData = windowsMalwareInformationToInitialize.AdditionalData;

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

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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Beispiel #5
0
 /// <summary>
 /// Adds the specified WindowsMalwareInformation to the collection via POST.
 /// </summary>
 /// <param name="windowsMalwareInformation">The WindowsMalwareInformation to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created WindowsMalwareInformation.</returns>
 public System.Threading.Tasks.Task <WindowsMalwareInformation> AddAsync(WindowsMalwareInformation windowsMalwareInformation, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <WindowsMalwareInformation>(windowsMalwareInformation, cancellationToken));
 }
Beispiel #6
0
 /// <summary>
 /// Adds the specified WindowsMalwareInformation to the collection via POST.
 /// </summary>
 /// <param name="windowsMalwareInformation">The WindowsMalwareInformation to add.</param>
 /// <returns>The created WindowsMalwareInformation.</returns>
 public System.Threading.Tasks.Task <WindowsMalwareInformation> AddAsync(WindowsMalwareInformation windowsMalwareInformation)
 {
     return(this.AddAsync(windowsMalwareInformation, CancellationToken.None));
 }