LightInject
LightInject copied to clipboard
Combine assembly scanning with named service
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");