-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding HostProvider #448
Comments
How you suggest use IHostProvider with DI? We should setup host on service.AddNClient(.....) |
I think it can look like this: serviceCollection.AddRestNClient(implementationFactory: (serviceProvider, builder) =>
{
var hostProvider = serviceProvider.GetRequiredService<MyHostProvider>();
builder.For<IMyClient>(hostProvider).Build();
}); |
Well... Maybe we already have this feature? |
Not quite. We can do for example like this: serviceCollection.AddRestNClient(implementationFactory: (serviceProvider, builder) =>
{
var hostProvider = serviceProvider.GetRequiredService<MyHostProvider>();
var host = hostProvider.Get();
builder
.For<IBasicClientWithMetadata>(host)
.Build()
}); This is similar to what I want, but the host provider will create the host only once, since the client is a singleton. Perhaps if we implement #449 (comment), it will cover most of the needs. However, we should remember that clients can be created not only using DI. |
The
HostProvider
will allow getting hosts in runtime. Most likely, the provider should be passed toFor
method.The text was updated successfully, but these errors were encountered: