container.AddRegistration(Lifestyle.Singleton);
container.AddRegistration(typeof(HomeController), () => new HomeController(new Logger()));
container.AddRegistration( typeof(IService), () => IsTestEnvironment() ? new TestService() : new RealService(), Lifestyle.Singleton);This code registers the IService type conditionally based on the result of the IsTestEnvironment() method. If the method returns true, the TestService implementation will be used. Otherwise, the RealService implementation will be used. The registration uses a Singleton lifestyle, meaning that the same instance will be returned every time the IService is requested. Package library: SimpleInjector In conclusion, SimpleInjector is a flexible and lightweight solution for managing dependencies in .NET applications. The AddRegistration method is a key feature of the library, allowing you to easily register types and manage their lifecycles.