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);
        }
示例#3
0
        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);
        }
示例#4
0
        public HttpClient GetHttpClient(Type contractType)
        {
            IContractScope scope = contractScopeProvider.GetScope(contractType);

            return(httpClientFactory.CreateClient((string)scope.HttpClientArgs));
        }