67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
|
|||
|
|
|
||
|
|
using Autofac;
|
||
|
|
using CommonService;
|
||
|
|
using FishGameService.GameService;
|
||
|
|
using FishGameService.Services;
|
||
|
|
using MongoRepository;
|
||
|
|
|
||
|
|
namespace FishGameHost.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();
|
||
|
|
|
||
|
|
builder.RegisterType<RedisService.RedisService>()
|
||
|
|
.As<RedisService.IRedisService>()
|
||
|
|
.InstancePerLifetimeScope();
|
||
|
|
|
||
|
|
builder.RegisterType<ReconnectTracker>()
|
||
|
|
.As<IReconnectTracker>()
|
||
|
|
.SingleInstance();
|
||
|
|
|
||
|
|
builder.RegisterType<BulletTracker>()
|
||
|
|
.As<IBulletTracker>()
|
||
|
|
.SingleInstance();
|
||
|
|
|
||
|
|
builder.RegisterType<FishKillTracker>()
|
||
|
|
.As<IFishKillTracker>()
|
||
|
|
.SingleInstance();
|
||
|
|
|
||
|
|
builder.RegisterType<FishSpawnConfigStore>()
|
||
|
|
.AsSelf()
|
||
|
|
.SingleInstance();
|
||
|
|
|
||
|
|
builder.RegisterAssemblyTypes(typeof(ApiLogService).Assembly)
|
||
|
|
.Where(t => t.Name.EndsWith("Service"))
|
||
|
|
.AsImplementedInterfaces()
|
||
|
|
.InstancePerLifetimeScope();
|
||
|
|
|
||
|
|
builder.RegisterType<FishSpawnService>()
|
||
|
|
.AsSelf()
|
||
|
|
.As<IHostedService>()
|
||
|
|
.SingleInstance();
|
||
|
|
|
||
|
|
builder.RegisterAssemblyTypes(typeof(FishingGameService).Assembly)
|
||
|
|
.Where(t => t.Name.EndsWith("Service") && t != typeof(FishSpawnService)
|
||
|
|
&& t != typeof(RobotKillAnnounceService))
|
||
|
|
.AsImplementedInterfaces()
|
||
|
|
.InstancePerLifetimeScope();
|
||
|
|
|
||
|
|
builder.RegisterAssemblyTypes(typeof(FishingGameService).Assembly)
|
||
|
|
.Where(t => t.Name.EndsWith("Subscriber"))
|
||
|
|
.AsSelf()
|
||
|
|
.InstancePerLifetimeScope();
|
||
|
|
builder.RegisterAssemblyTypes(typeof(UserService.User.UserService).Assembly)
|
||
|
|
.Where(t => t.Name.EndsWith("Service"))
|
||
|
|
.AsImplementedInterfaces()
|
||
|
|
.InstancePerLifetimeScope();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|