How to batch register interfaces without BasedOn method in Castle Windsor?

Clash Royale CLAN TAG#URR8PPP
How to batch register interfaces without BasedOn method in Castle Windsor?
I’ve got a project under .NET Core. I want to register all repository interfaces to classes that implemented these interface without extending all interfaces from a base interface using Castle Windsor
I don’t want to use the code below:
container.Register(
FromAssemblyContaining<StudentRepository>()
.BasedOn<IBase>()
.WithService.Select((type, types) =>
type.BaseType != null && type.Name.EndsWith(type.BaseType.Name)
? new type.BaseType
: Enumerable.Empty<Type>()));
I want Castle Windsor to automatically detect all interfaces from the assembly.
1 Answer
1
Using this code:
container.Kernel.Register(
Classes.FromAssembly(typeof(StudentRepository).Assembly)
.Where(Component.IsInNamespace(typeof(StudentRepository).Namespace, includeSubnamespaces: true))
.WithServiceAllInterfaces()
.LifestyleScoped());
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.