Register open generics in ASP.NET Core
See original GitHub issueGiven the following:
public class Foo : IFoo {
...
}
public class FooValidator : AbstractValidator<IFoo> {
...
}
It would be nice to be able to resolve IValidator<Foo>
from the ASP.NET Core DI Container.
I know the built-in DI container does not support open generics out of the box, so one would have to scan the assembly and explicitly register the validator for all concrete implementations of IFoo
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Registering Open Generics in ASPNET Core Dependency ...
NET Core startup, there is a simple way to do so. ... Registering Open Generics in ASPNET Core Dependency Injection.
Read more >ASP.NET Core dependency injection: Registering open ...
A really interesting trick you can do with the ASP.NET core dependency injection is that you can register an open generic type.
Read more >How to register dependency injection with generic types? ...
I have an asp.net core web app with multiple parameters in appSettings.json file. I didnt' want to have services having IOptions<MyObject> in ...
Read more >Constrained Open Generics Support Merged in .NET Core ...
The built-in container is a conforming container - that is, it provides some default behaviors that ASP.NET Core requires, and if you want...
Read more >How to Register Open Generic in .NET Core Dependency ...
In this topic we would cover. How to create a Open Generic; Right way to register Dependency Injection. If you have a generic...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, can definitely look at doing that for a future version
The simplest thing is probably just to register these types with the container directly manually rather than relying on FV’s built in AssemblyScanner