/// <inheritdoc /> public void ConfigureServices(IServiceCollection services) { // Add options. services.AddOptions <ImgeneusServerOptions>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("TcpServer").Bind(settings)); services.AddOptions <WorldConfiguration>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("WorldServer").Bind(settings)); services.AddOptions <DatabaseConfiguration>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("Database").Bind(settings)); services.AddOptions <InterServerConfig>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("InterServer").Bind(settings)); services.AddOptions <GuildConfiguration>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("Game:Guild").Bind(settings)); services.RegisterDatabaseServices(); services.AddHandlers(); services.AddSingleton <IInterServerClient, ISClient>(); services.AddSingleton <IWorldServer, WorldServer>(); services.AddSingleton <IGamePacketFactory, GamePacketFactory>(); services.AddSingleton <IGameWorld, GameWorld>(); services.AddSingleton <IGameDefinitionsPreloder, GameDefinitionsPreloder>(); services.AddSingleton <IMapsLoader, MapsLoader>(); services.AddSingleton <IMapFactory, MapFactory>(); services.AddSingleton <IMobFactory, MobFactory>(); services.AddSingleton <INpcFactory, NpcFactory>(); services.AddSingleton <IObeliskFactory, ObeliskFactory>(); services.AddSingleton <ICharacterConfiguration, CharacterConfiguration>((x) => CharacterConfiguration.LoadFromConfigFile()); services.AddSingleton <IGuildConfiguration, GuildConfiguration>((x) => GuildConfiguration.LoadFromConfigFile()); services.AddSingleton <IGuildHouseConfiguration, GuildHouseConfiguration>((x => GuildHouseConfiguration.LoadFromConfigFile())); services.AddSingleton <IItemEnchantConfiguration, ItemEnchantConfiguration>((x => ItemEnchantConfiguration.LoadFromConfigFile())); services.AddSingleton <IMoveTownsConfiguration, MoveTownsConfiguration>((x => MoveTownsConfiguration.LoadFromConfigFile())); services.AddSingleton <IItemCreateConfiguration, ItemCreateConfiguration>((x => ItemCreateConfiguration.LoadFromConfigFile())); services.AddSingleton <IChatManager, ChatManager>(); services.AddSingleton <INoticeManager, NoticeManager>(); services.AddSingleton <IGuildRankingManager, GuildRankingManager>(); services.AddSingleton <IEtinManager, EtinManager>(); services.AddSingleton <IDatabasePreloader, DatabasePreloader>((x) => { using (var scope = x.CreateScope()) { var logger = scope.ServiceProvider.GetRequiredService <ILogger <DatabasePreloader> >(); var db = scope.ServiceProvider.GetRequiredService <IDatabase>(); return(new DatabasePreloader(logger, db)); } }); services.AddScoped <ICharacterFactory, CharacterFactory>(); services.AddScoped <ISelectionScreenManager, SelectionScreenManager>(); services.AddScoped <IGameSession, GameSession>(); services.AddScoped <IStatsManager, StatsManager>(); services.AddScoped <ICountryProvider, CountryProvider>(); services.AddScoped <ILevelProvider, LevelProvider>(); services.AddScoped <ILevelingManager, LevelingManager>(); services.AddScoped <IHealthManager, HealthManager>(); services.AddScoped <ISpeedManager, SpeedManager>(); services.AddScoped <IAttackManager, AttackManager>(); services.AddScoped <ISkillsManager, SkillsManager>(); services.AddScoped <IBuffsManager, BuffsManager>(); services.AddScoped <IElementProvider, ElementProvider>(); services.AddScoped <IInventoryManager, InventoryManager>(); services.AddScoped <IStealthManager, StealthManager>(); services.AddScoped <IKillsManager, KillsManager>(); services.AddScoped <IVehicleManager, VehicleManager>(); services.AddScoped <IShapeManager, ShapeManager>(); services.AddScoped <IMovementManager, MovementManager>(); services.AddScoped <ILinkingManager, LinkingManager>(); services.AddScoped <IAdditionalInfoManager, AdditionalInfoManager>(); services.AddScoped <IMapProvider, MapProvider>(); services.AddScoped <ITeleportationManager, TeleportationManager>(); services.AddScoped <IDyeingManager, DyeingManager>(); services.AddScoped <IPartyManager, PartyManager>(); services.AddScoped <ITradeManager, TradeManager>(); services.AddScoped <IFriendsManager, FriendsManager>(); services.AddScoped <IDuelManager, DuelManager>(); services.AddScoped <IGuildManager, GuildManager>(); services.AddScoped <IBankManager, BankManager>(); services.AddScoped <IQuestsManager, QuestsManager>(); services.AddScoped <IUntouchableManager, UntouchableManager>(); services.AddScoped <IWarehouseManager, WarehouseManager>(); services.AddScoped <IAIManager, AIManager>(); services.AddScoped <IShopManager, ShopManager>(); services.AddScoped <ISkillCastingManager, SkillCastingManager>(); services.AddScoped <ICastProtectionManager, CastProtectionManager>(); services.AddTransient <ICryptoManager, CryptoManager>(); services.AddTransient <ILogsDatabase, LogsDbContext>(); services.AddTransient <ITimeService, TimeService>(); // Add admin website services.AddRazorPages(); services.AddServerSideBlazor(); services.AddDefaultIdentity <DbUser>(options => { options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequireLowercase = false; options.Password.RequiredLength = 1; }) .AddRoles <DbRole>() .AddEntityFrameworkStores <DatabaseContext>(); }
/// <inheritdoc /> public void ConfigureServices(IServiceCollection services) { // Add options. services.AddOptions <WorldConfiguration>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("WorldServer").Bind(settings)); services.AddOptions <DatabaseConfiguration>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("Database").Bind(settings)); services.AddOptions <InterServerConfig>() .Configure <IConfiguration>((settings, configuration) => configuration.GetSection("InterServer").Bind(settings)); services.RegisterDatabaseServices(); services.AddSingleton <IInterServerClient, ISClient>(); services.AddSingleton <IWorldServer, WorldServer>(); services.AddSingleton <IGameWorld, GameWorld>(); services.AddSingleton <ISelectionScreenFactory, SelectionScreenFactory>(); services.AddSingleton <IMapsLoader, MapsLoader>(); services.AddSingleton <IMapFactory, MapFactory>(); services.AddSingleton <IMobFactory, MobFactory>(); services.AddSingleton <INpcFactory, NpcFactory>(); services.AddSingleton <IObeliskFactory, ObeliskFactory>(); services.AddSingleton <ICharacterFactory, CharacterFactory>(); services.AddSingleton <ICharacterConfiguration, CharacterConfiguration>((x) => CharacterConfiguration.LoadFromConfigFile()); services.AddSingleton <IDatabasePreloader, DatabasePreloader>((x) => { using (var scope = x.CreateScope()) { var logger = scope.ServiceProvider.GetRequiredService <ILogger <DatabasePreloader> >(); var db = scope.ServiceProvider.GetRequiredService <IDatabase>(); return(new DatabasePreloader(logger, db)); } }); services.AddSingleton <IChatManager, ChatManager>(); services.AddSingleton <INoticeManager, NoticeManager>(); services.AddTransient <ILogsDatabase, LogsDbContext>(); services.AddTransient <ILinkingManager, LinkingManager>(); services.AddTransient <IDyeingManager, DyeingManager>(); services.AddTransient <IGuildManager, GuildManager>(); services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); services.AddHostedService <DatabaseWorker>(); }