/// <summary> /// Initializes a new instance of the <see cref="DelegatingHttpApiCall{T}"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException">If <paramref name="httpApiCall"/> is <see langword="null"/>.</exception> public DelegatingHttpApiCall(IHttpApiCall <T> httpApiCall) { if (httpApiCall == null) { throw new ArgumentNullException("httpApiCall"); } _httpApiCall = httpApiCall; _httpApiCall.BeforeAsyncWebRequest += HandleBeforeAsyncWebRequest; _httpApiCall.AfterAsyncWebResponse += HandleAfterAsyncWebResponse; }
/// <summary> /// Initializes a new instance of the <see cref="TransformHttpApiCall{TSource, TResult}"/> class with the /// behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <param name="selector">The function which selects the result for this API call from the result provided by /// the underlying <paramref name="httpApiCall"/>.</param> /// <exception cref="ArgumentNullException"> /// <para>If <paramref name="httpApiCall"/> is <see langword="null"/>.</para> /// <para>-or-</para> /// <para>If <paramref name="selector"/> is <see langword="null"/>.</para> /// </exception> public TransformHttpApiCall(IHttpApiCall <TSource> httpApiCall, Func <HttpResponseMessage, TSource, CancellationToken, TResult> selector) { if (httpApiCall == null) { throw new ArgumentNullException("httpApiCall"); } if (selector == null) { throw new ArgumentNullException("selector"); } _httpApiCall = httpApiCall; _selector = selector; _httpApiCall.BeforeAsyncWebRequest += HandleBeforeAsyncWebRequest; _httpApiCall.AfterAsyncWebResponse += HandleAfterAsyncWebResponse; }
/// <summary> /// Initializes a new instance of the <see cref="DelegatingHttpApiCall{T}"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <param name="selector">A function used to select the final result from the result of the source API call.</param> /// <exception cref="ArgumentNullException"> /// <para>If <paramref name="httpApiCall"/> is <see langword="null"/>.</para> /// <para>-or-</para> /// <para>If <paramref name="selector"/> is <see langword="null"/>.</para> /// </exception> public DelegatingHttpApiCall(IHttpApiCall <TSource> httpApiCall, Func <TSource, TResult> selector) { if (httpApiCall == null) { throw new ArgumentNullException("httpApiCall"); } if (selector == null) { throw new ArgumentNullException("selector"); } _httpApiCall = httpApiCall; _selector = selector; _httpApiCall.BeforeAsyncWebRequest += HandleBeforeAsyncWebRequest; _httpApiCall.AfterAsyncWebResponse += HandleAfterAsyncWebResponse; }
/// <summary> /// Initializes a new instance of the <see cref="GetExtensionApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public GetExtensionApiCall(IHttpApiCall <ExtensionResponse> httpApiCall) : base(httpApiCall) { }
/// <summary> /// Initializes a new instance of the <see cref="ListTenantsApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public ListTenantsApiCall(IHttpApiCall <ReadOnlyCollectionPage <Tenant> > httpApiCall) : base(httpApiCall) { }
/// <summary> /// Initializes a new instance of the <see cref="ListApiVersionsApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public ListApiVersionsApiCall(IHttpApiCall <ReadOnlyCollectionPage <ApiVersion> > httpApiCall) : base(httpApiCall) { }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticateApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public AuthenticateApiCall(IHttpApiCall <AccessResponse> httpApiCall) : base(httpApiCall) { }
/// <summary> /// Initializes a new instance of the <see cref="ListExtensionsApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public ListExtensionsApiCall(IHttpApiCall <ReadOnlyCollectionPage <Extension> > httpApiCall) : base(httpApiCall) { }
/// <summary> /// Initializes a new instance of the <see cref="GetApiVersionApiCall"/> class /// with the behavior provided by another <see cref="IHttpApiCall{T}"/> instance. /// </summary> /// <param name="httpApiCall">The <see cref="IHttpApiCall{T}"/> providing the behavior for the API call.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="httpApiCall"/> is <see langword="null"/>. /// </exception> public GetApiVersionApiCall(IHttpApiCall <ApiVersionResponse> httpApiCall) : base(httpApiCall) { }
/// <summary> /// Projects the result of an HTTP API call into a new form. /// </summary> /// <typeparam name="TSource">The type of object returned by the HTTP API call.</typeparam> /// <typeparam name="TResult">The type of object returned by <paramref name="selector"/>.</typeparam> /// <param name="source">The input HTTP API call to transform.</param> /// <param name="selector">A transform function to apply to the result of <paramref name="source"/>.</param> /// <returns>An <see cref="IHttpApiCall{T}"/> whose result is the result of invoking the transform function on /// the result of <paramref name="source"/>.</returns> public static IHttpApiCall <TResult> Select <TSource, TResult>(this IHttpApiCall <TSource> source, Func <TSource, TResult> selector) { return(new DelegatingHttpApiCall <TSource, TResult>(source, selector)); }
/// <summary> /// Returns the input typed as <see cref="IHttpApiCall{T}"/>. /// </summary> /// <remarks> /// <para>The <see cref="AsHttpApiCall{T}"/> method has no effect other than to change the compile-time type of /// <paramref name="apiCall"/> from a type that implements <see cref="IHttpApiCall{T}"/> to /// <see cref="IHttpApiCall{T}"/> itself.</para> /// </remarks> /// <typeparam name="T">The type returned by the HTTP API call.</typeparam> /// <param name="apiCall">The API call to type as <see cref="IHttpApiCall{T}"/>.</param> /// <returns>The input API call typed as <see cref="IHttpApiCall{T}"/>.</returns> public static IHttpApiCall <T> AsHttpApiCall <T>(this IHttpApiCall <T> apiCall) { return(apiCall); }