using Autofac; using ChessGameService; using CommonService; using MongoRepository; namespace ChessGameHost.Middleware { public class AutofacModule : Module { protected override void Load(ContainerBuilder builder) { builder.RegisterGeneric(typeof(MongoBaseRepository<>)).As(typeof(IMongoBaseRepository<>)).InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(MongoBaseService<>)).As(typeof(IMongoBaseService<>)).InstancePerLifetimeScope(); // var assembly = typeof(Program).Assembly; builder.RegisterType() .As() .InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(ApiLogService).Assembly) .Where(t => t.Name.EndsWith("Service")) .AsImplementedInterfaces() .InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(ChessGameService.ChessGameService).Assembly) .Where(t => t.Name.EndsWith("Service")) .AsImplementedInterfaces() .InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(UserService.User.UserService).Assembly) .Where(t => t.Name.EndsWith("Service")) .AsImplementedInterfaces() .InstancePerLifetimeScope(); } } }