protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
IConfiguration configuration = builder.Build();
containerRegistry.RegisterInstance(new AppSettings(configuration));
var optionsBuilder= new DbContextOptionsBuilder<RXMesContext>().UseSqlServer(AppSettings.DbConnectionString);
containerRegistry.RegisterInstance(optionsBuilder.Options);
containerRegistry.Register<RXMesContext>();
containerRegistry.Register<IBaseRepository<Sys_Permission>, BaseRepository<Sys_Permission>>();
var serviceDll = Environment.CurrentDirectory + @"\RXMes.Repository.dll";
var serviceAssembly = Assembly.LoadFrom(serviceDll);
var repostoryList = (from t in serviceAssembly.GetTypes()
where typeof(IBaseRepository<>).IsAssignableFrom(t) &&
!t.IsAbstract
select t).ToList();
repostoryList.ForEach(t => containerRegistry.GetContainer().RegisterType(typeof(IBaseRepository<>),t,"",new TransientLifetimeManager(),new InjectionConstructor()));
}
|