public HttpClient GetHttpClient(Type contractType) { IContractScope scope = contractScopeProvider.GetScope(contractType); IHttpClientResolver clientResolver = (IHttpClientResolver)serviceProvider.GetRequiredService(scope.HttpClientResolverType); return(clientResolver.GetHttpClient(contractType)); }
public void AddScope(Type contractType, IContractScope scope) { if (scopes.ContainsKey(contractType)) { throw new ArgumentException($"Could not register scope for contract `{contractType.Name}`, because it is already registered."); } scopes.Add(contractType, scope); }
ClientBCFOptions IOptionsBuilder <ClientBCFOptions> .Build() { ClientBCFOptions clientOptions = new ClientBCFOptions(); Build(clientOptions); IContractScope globalScope = globalScopeBuilder.Build(); clientOptions.InvocationSerializerType = invocationSerializerType ?? clientOptions.InvocationSerializerType; clientOptions.HttpClientResolverType = globalScope.HttpClientResolverType ?? clientOptions.HttpClientResolverType; clientOptions.Scopes = childScopeBuilders.Select(X => X.Build()).Union(new[] { globalScope }).ToArray(); return(clientOptions); }
public HttpClient GetHttpClient(Type contractType) { IContractScope scope = contractScopeProvider.GetScope(contractType); return(httpClientFactory.CreateClient((string)scope.HttpClientArgs)); }