示例#1
0
        public static IServiceCollection AddMercuryClient(this IServiceCollection services, Action <MercuryClientSettings> configure)
        {
            var settings = new MercuryClientSettings();

            configure(settings);
            services.AddSingleton(settings);
            services.AddSingleton <IMercuryClientFactory, MercuryClientFactory>();
            services.AddHttpClient <IMercuryClient, MercuryClient>(config =>
            {
                config.BaseAddress = new Uri(settings.BaseAddress);
            });

            return(services);
        }
示例#2
0
 public MercuryClient(HttpClient httpClient, MercuryClientSettings settings)
 {
     this.httpClient = httpClient;
     this.settings   = settings;
 }
示例#3
0
 public MercuryClientFactory(IHttpClientFactory httpClientFactory, MercuryClientSettings settings)
 {
     this.httpClientFactory = httpClientFactory;
     this.settings          = settings;
 }