Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebApiAgentResult"/> class.
        /// </summary>
        /// <param name="sendArgs">The corresponding <see cref="HttpSendArgs"/>.</param>
        /// <param name="response">The <see cref="HttpResponseMessage"/>.</param>
        public HttpAgentResult(HttpSendArgs sendArgs, HttpResponseMessage response) : base(response)
        {
            SendArgs = Check.NotNull(sendArgs, nameof(sendArgs));

            if (response.IsSuccessStatusCode && response.Headers.ETag != null && ExecutionContext.HasCurrent)
            {
                ExecutionContext.Current.ETag = response.Headers.ETag.Tag;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check the arguments.
        /// </summary>
        private static HttpSendArgs CheckSendArgs(HttpSendArgs args, bool mapperIsMandatory = false)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            if (mapperIsMandatory && args.Mapper == null)
            {
                throw new ArgumentException("The Mapper property must not be null.", nameof(args));
            }

            return(args);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Performs the actual <see cref="HttpClient.SendAsync(HttpRequestMessage)"/> and verifies the result.
 /// </summary>
 private async Task <HttpAgentResult> SendAsyncInternal <TReq>(HttpSendArgs args, TReq value) => await(Invoker ??= WebApiAgentInvoker.Current).InvokeAsync(this, async() =>
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebApiAgentResult"/> class.
 /// </summary>
 /// <param name="sendArgs">The corresponding <see cref="HttpSendArgs"/>.</param>
 /// <param name="response">The <see cref="HttpResponseMessage"/>.</param>
 public HttpAgentResult(HttpSendArgs sendArgs, HttpResponseMessage response) : base(response) => SendArgs = Check.NotNull(sendArgs, nameof(sendArgs));