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

Cannot register System.Type in IContainerBuilder #107

Closed
Razenpok opened this issue Feb 2, 2021 · 2 comments
Closed

Cannot register System.Type in IContainerBuilder #107

Razenpok opened this issue Feb 2, 2021 · 2 comments

Comments

@Razenpok
Copy link

Razenpok commented Feb 2, 2021

I want to register all the types I need that derive from a certain interface, and there's no way to do this:

var baseType = typeof(IUseCase);
var assembly = baseType.Assembly;
var useCaseTypes = assembly.GetTypes()
    .Where(t => baseType.IsAssignableFrom(t));
foreach (var useCaseType in useCaseTypes)
{
    builder.Register(useCaseType, Lifetime.Transient);
}
@hadashiA
Copy link
Owner

hadashiA commented Feb 2, 2021

Agree. This is useful.
I will expose Register(Type, ...).
Thanks for the feedback.

@hadashiA
Copy link
Owner

hadashiA commented Feb 4, 2021

Releaed in v1.5.1

@hadashiA hadashiA closed this as completed Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants