/// <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; } }
/// <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); }
/// <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() =>
/// <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));