NClient
NClient copied to clipboard
Creating custom providers using DI
I want to create custom providers using DI. From the client's API side, it should look like this:
services.AddRestNClient<IBasicClientWithMetadata>(host: "http://localhost:5000",
implementationFactory: builder => builder
.WithHandling<MyHandler>()
.Build());
I'm sorry, but this feature already implemented, isn't? https://github.com/nclient/NClient/blob/main/tests/NClient.Extensions/NClient.Extensions.DependencyInjection.Tests/AddRestNClientExtensionsTest.cs#L73
No, there is no such feature yet. Please note how the handler is created:
.WithHandling<MyHandler>()
Now we can only create a handler like this:
services.AddRestNClient<IBasicClientWithMetadata>(host: "http://localhost:5000", implementationFactory: (serviceProvider, builder) =>
{
var myHandler = serviceProvider.GetRequiredService<MyHandler>();
return builder
.WithHandling(myHandler)
.Build();
});