这是我在依赖项容器中的IoC方法
public class DependencyContainer
{
public static void RegisterServices(IServiceCollection service)
{
#region Services Injection
service.AddScoped<IUserService, UserService>();
#endregion
#region Repositories Injection
service.AddScoped<IUserRepository, UserRepository>();
#endregion
}
}
现在我想把它添加到网页层的Program.cs中. 我如何在.NET8中做到这一点?
在.NET 5中,它是:
public static void RegisterServices(IServiceCollection services)
{
DependencyContainer.RegisterServices(services);
}
但在.NET 8中,我们没有公共方法,我该怎么做呢?