public static void AddClient(this IServiceCollection services, Uri baseUri, IAuthenticationProviderBuilder authenticationProviderBuilder) { var factory = authenticationProviderBuilder.GetFactory(); services.Configure <ClientOptions>(v => v.BaseUri = baseUri); services.AddTransient <IClient>(v => new Client(factory(v), v.GetService <IOptions <ClientOptions> >())); }
public static void AddDigitServiceClient(this IServiceCollection services, Uri baseUri, IAuthenticationProviderBuilder authenticationProviderBuilder) { services.AddDigitServiceClient(new DigitServiceOptions() { DigitServiceBaseUri = baseUri }, authenticationProviderBuilder); }
public static void AddDigitServiceClient(this IServiceCollection services, DigitServiceOptions options, IAuthenticationProviderBuilder authenticationProviderBuilder) { var factory = authenticationProviderBuilder.GetFactory(); services.Configure <DigitServiceOptions>(v => { v.DigitServiceBaseUri = options.DigitServiceBaseUri; v.LogAuthor = options.LogAuthor; }); services.AddTransient <IDigitServiceClient>(v => new DigitServiceClient(factory(v), v.GetService <IOptions <DigitServiceOptions> >())); }
public static void AddDigitPushServiceClient(this IServiceCollection services, Uri baseUri, IAuthenticationProviderBuilder authenticationProviderBuilder) { var factory = authenticationProviderBuilder.GetFactory(); services.AddHttpClient(nameof(DigitPushServiceClient), client => { client.BaseAddress = baseUri; }); services.AddTransient <IDigitPushServiceClient>(v => { var client = v.GetRequiredService <IHttpClientFactory>().CreateClient(nameof(DigitPushServiceClient)); return(new DigitPushServiceClient(factory(v), client)); }); }