コード例 #1
0
ファイル: FluentClient.cs プロジェクト: faygan/FluentRest
        /// <summary>
        /// Sends a GET request using specified fluent <paramref name="builder"/> as an asynchronous operation.
        /// </summary>
        /// <param name="builder">The fluent builder factory.</param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null" />.</exception>
        public async Task <FluentResponse> GetAsync(Action <QueryBuilder> builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var fluentRequest = _defaultRequest.Clone();

            fluentRequest.Method = HttpMethod.Get;

            var fluentBuilder = new QueryBuilder(fluentRequest);

            builder(fluentBuilder);

            var response = await SendAsync(fluentRequest).ConfigureAwait(false);

            return(response);
        }