I have a multiple instance of IReportData so I register it on PreInitialize of my module
IocManager.IocContainer.Register(
Component.For<IReportData, Expense>().ImplementedBy<Expense>(),
Component.For<IReportData, Invoice>().ImplementedBy<Invoice>()
);
In this way I need to register every new IReportData, how can I do it automatically via IocManager.IocContainer?
9 Answer(s)
-
0
Hi @andmattia
You can do it similar to https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Dependency/BasicConventionalRegistrar.cs#L15
There are other samples in ABP's source code.
-
0
hi @ismcagdas
I try to flow your suggestion but my interface are not registered. Last week I update to lastest ABP 4.2 and this week I try it again.
-
0
Show code.
-
0
@andmattia
Any news ?
-
0
Hi @ismcagdas
I can't test this week beacuse I don't have time to do it. I plan to do next week and I give you an update ASAP.
-
0
@andmattia
Thank you for your feedback. We can continue according to your response.
-
0
@ismcagdas
I try to implement the example that has suggested but it doesn't work, but I check on Windsor docs at Select() and I see the correct implementation.
So the problem is related to the name because to registrer class with different name than the interface I use this code
public class ReportConventionalRegistrar : IConventionalDependencyRegistrar { public void RegisterAssembly(IConventionalRegistrationContext context) { context.IocManager.IocContainer.Register( Classes.FromAssembly(context.Assembly) .BasedOn<IReportData>() .If(type => !type.GetTypeInfo().IsGenericTypeDefinition) .WithService.Self() .WithService.Base() ); } }
-
0
Did you add your registerer to IocManager? see : https://github.com/aspnetboilerplate/aspnetboilerplate/blob/f4b34279b743319d922a02a2246a1af9b7255886/src/Abp/AbpKernelModule.cs#L45
-
0
@demirmusa
Yes I do it on my base module and works fine.