예제 #1
0
 /// <summary>
 /// Sends the request asynchronously.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="request">The request.</param>
 /// <param name="requestType">Type of the request.</param>
 /// <param name="tenant">The tenant.</param>
 /// <param name="scenarioId">The scenario identifier.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The <see cref="Task" />.
 /// </returns>
 public static Task SendAsync(
     this IGraphClient client,
     IBaseRequest request,
     RequestType requestType,
     string tenant,
     Guid scenarioId,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(client.SendAsync <NoContentMessage>(request, requestType, tenant, scenarioId, cancellationToken));
 }
예제 #2
0
        /// <summary>
        /// Sends the request asynchronously.
        /// </summary>
        /// <typeparam name="T"><see cref="Type" /> of the content present in the response.</typeparam>
        /// <param name="client">The client.</param>
        /// <param name="request">The request.</param>
        /// <param name="requestType">Type of the request.</param>
        /// <param name="tenant">The tenant.</param>
        /// <param name="scenarioId">The scenario identifier.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Task" /> returning the generic type.
        /// </returns>
        public static async Task <T> SendAsync <T>(
            this IGraphClient client,
            IBaseRequest request,
            RequestType requestType,
            string tenant,
            Guid scenarioId,
            CancellationToken cancellationToken = default(CancellationToken))
            where T : class
        {
            var graphRequest  = CreateGraphRequest(request, requestType);
            var graphResponse = await client
                                .SendAsync <object, T>(graphRequest, tenant, scenarioId, cancellationToken)
                                .ConfigureAwait(false);

            return(graphResponse.Content);
        }
예제 #3
0
        /// <summary>
        /// Sends the asynchronous.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <param name="client">The client.</param>
        /// <param name="request">The request.</param>
        /// <param name="tenant">The tenant.</param>
        /// <param name="scenarioId">The scenario identifier.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="IGraphResponse{T}" />.
        /// </returns>
        public static Task <IGraphResponse> SendAsync <TRequest>(
            this IGraphClient client,
            IGraphRequest <TRequest> request,
            string tenant,
            Guid scenarioId,
            CancellationToken cancellationToken = default(CancellationToken))
            where TRequest : class
        {
            if (!string.IsNullOrWhiteSpace(tenant))
            {
                request.Properties.Add(GraphProperty.Property(HttpConstants.HeaderNames.Tenant, tenant));
            }

            request.Properties.Add(GraphProperty.RequestProperty(HttpConstants.HeaderNames.ScenarioId, scenarioId));
            request.Properties.Add(GraphProperty.RequestProperty(HttpConstants.HeaderNames.ClientRequestId, Guid.NewGuid()));

            return(client.SendAsync <TRequest>(request, cancellationToken));
        }