コード例 #1
0
ファイル: Api.cs プロジェクト: mikaelrjohansson/Web-Anchor
        /// <summary>
        /// Creates an api of type T. T must be an interface that looks like a web anchor api.
        /// With this method you can supply your own httpClient. You will be responsible to dispose this HttpClient yourself.
        /// </summary>
        /// <typeparam name="T">An interface for your Api.</typeparam>
        /// <param name="httpClient">A HttpClient that you can modify the way you like. You must also handle disposing of this HttpClient yourself.</param>
        /// <param name="configure">Offers you a convenient option to configure a default ApiSettings</param>
        /// <returns></returns>
        public static T For <T>(HttpClient httpClient, Action <DefaultApiSettings> configure) where T : class
        {
            var settings = new DefaultApiSettings();

            configure?.Invoke(settings);
            return(For <T>(httpClient, settings));
        }
コード例 #2
0
ファイル: Api.cs プロジェクト: mikaelrjohansson/Web-Anchor
        /// <summary>
        /// Creates an api of type T. T must be an interface that looks like a web anchor api.
        /// This method will create a httpClient on the fly. If T extends IDisposable, that HttpClient will
        /// be disposed when your api is disposed.
        /// </summary>
        /// <typeparam name="T">An interface for your Api.</typeparam>
        /// <param name="baseUri">A base URI that will be used for ALL httprequests created by this web anchor api. This URI will never be modified by any web anchor magic.</param>
        /// <param name="configure">Offers you a convenient option to configure a default ApiSettings</param>
        /// <returns></returns>
        public static T For <T>(string baseUri, Action <DefaultApiSettings> configure) where T : class
        {
            var settings = new DefaultApiSettings();

            configure?.Invoke(settings);
            return(For <T>(baseUri, settings));
        }