LightInject icon indicating copy to clipboard operation
LightInject copied to clipboard

Combine assembly scanning with named service

Open Prev-I opened this issue 2 years ago • 0 comments

I would like to mark all service class with an annotation (or a specific property) containing the name to be used in Registration when loading from assembly.

[AutoWireName("GET_ALL_USERS")]
public class GetAllUsersQueryHandler : IRequestHandler

Then in startup.cs when registering by assembly, how can I Add the custom logic for service name?

container.RegisterAssembly(typeof(IRequestHandler).Assembly, 
() => new PerContainerLifetime(), 
(serviceType, implementingType) => serviceType.NameSpace == "SomeNamespace", (serviceType, implementingType) => "Provide custom service name here");

Prev-I avatar Dec 28 '22 11:12 Prev-I