using Autofac; using MongoRepository; namespace CommonInfrastructure { public class AutofacModule : Module { protected override void Load(ContainerBuilder builder) { builder.RegisterGeneric(typeof(MongoBaseRepository<>)) .As(typeof(IMongoBaseRepository<>)) .InstancePerLifetimeScope(); builder.RegisterType() .As() .InstancePerLifetimeScope(); } public static void RegisterServices(ContainerBuilder builder, Type serviceAssemblyType) { builder.RegisterAssemblyTypes(serviceAssemblyType.Assembly) .Where(t => t.Name.EndsWith("Service")) .AsImplementedInterfaces() .InstancePerLifetimeScope(); } } }