-
Register for class
interface ITestService { } [ServiceImplementation(ServiceLifetime.Scoped, typeof(ITestService))] class TestService : ITestService { } [ServiceImplementation(ServiceLifetime.Scoped)] class TestServiceTwo { } it only register one.
-
Register for interface
[ServiceInterfaceAttribute(ServiceLifetime.Scoped)] interface ITestService { } class TestServiceOne : ITestService { } class TestServiceTwo : ITestService { }
it will register the implementation classes of all inherited interfaces.
-
how to use in serviceCollection
services.AddAutoRegister(typeof(Startup).GetTypeInfo().Assembly);