Skip to content
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

Creating custom providers using DI #433

Open
smolchanovsky opened this issue Apr 16, 2022 · 2 comments
Open

Creating custom providers using DI #433

smolchanovsky opened this issue Apr 16, 2022 · 2 comments

Comments

@smolchanovsky
Copy link
Member

smolchanovsky commented Apr 16, 2022

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());
@Kingmidas74
Copy link
Member

@smolchanovsky
Copy link
Member Author

smolchanovsky commented Sep 3, 2022

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();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants