Cleaned up services context

This commit is contained in:
cake
2025-12-09 07:30:52 +01:00
parent 675918624d
commit 2e14fc2f8f

View File

@@ -96,279 +96,450 @@ public sealed class Plugin : IDalamudPlugin
});
lb.SetMinimumLevel(LogLevel.Trace);
})
.ConfigureServices(collection =>
.ConfigureServices(services =>
{
var configDir = pluginInterface.ConfigDirectory.FullName;
// Core infrastructure
services.AddSingleton(new WindowSystem("LightlessSync"));
services.AddSingleton<FileDialogManager>();
services.AddSingleton(new Dalamud.Localization("LightlessSync.Localization.", string.Empty, useEmbedded: true));
services.AddSingleton(gameGui);
services.AddSingleton(addonLifecycle);
// Core singletons
services.AddSingleton<LightlessMediator>();
services.AddSingleton<FileCacheManager>();
services.AddSingleton<ServerConfigurationManager>();
services.AddSingleton<ProfileTagService>();
services.AddSingleton<ApiController>();
services.AddSingleton<PerformanceCollectorService>();
services.AddSingleton<HubFactory>();
services.AddSingleton<FileUploadManager>();
services.AddSingleton<FileTransferOrchestrator>();
services.AddSingleton<LightlessPlugin>();
services.AddSingleton<LightlessProfileManager>();
services.AddSingleton<TextureCompressionService>();
services.AddSingleton<TextureDownscaleService>();
services.AddSingleton<GameObjectHandlerFactory>();
services.AddSingleton<FileDownloadManagerFactory>();
services.AddSingleton<PairProcessingLimiter>();
services.AddSingleton<XivDataAnalyzer>();
services.AddSingleton<CharacterAnalyzer>();
services.AddSingleton<TokenProvider>();
services.AddSingleton<PluginWarningNotificationService>();
services.AddSingleton<FileCompactor>();
services.AddSingleton<TagHandler>();
services.AddSingleton<PairRequestService>();
services.AddSingleton<ZoneChatService>();
services.AddSingleton<IdDisplayHandler>();
services.AddSingleton<PlayerPerformanceService>();
services.AddSingleton<TextureMetadataHelper>(sp =>
new TextureMetadataHelper(sp.GetRequiredService<ILogger<TextureMetadataHelper>>(), gameData));
services.AddSingleton(sp => new Lazy<ApiController>(() => sp.GetRequiredService<ApiController>()));
services.AddSingleton(sp => new PairFactory(
sp.GetRequiredService<ILoggerFactory>(),
sp.GetRequiredService<PairLedger>(),
sp.GetRequiredService<LightlessMediator>(),
new Lazy<ServerConfigurationManager>(() => sp.GetRequiredService<ServerConfigurationManager>()),
sp.GetRequiredService<Lazy<ApiController>>()));
services.AddSingleton(sp => new TransientResourceManager(
sp.GetRequiredService<ILogger<TransientResourceManager>>(),
sp.GetRequiredService<TransientConfigService>(),
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<ActorObjectService>(),
sp.GetRequiredService<GameObjectHandlerFactory>()));
// Lightless Chara data
services.AddSingleton<CharaDataManager>();
services.AddSingleton<CharaDataFileHandler>();
services.AddSingleton<CharaDataCharacterHandler>();
services.AddSingleton<CharaDataNearbyManager>();
services.AddSingleton<CharaDataGposeTogetherManager>();
// Game / VFX / IPC
services.AddSingleton(sp => new VfxSpawnManager(
sp.GetRequiredService<ILogger<VfxSpawnManager>>(),
gameInteropProvider,
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new BlockedCharacterHandler(
sp.GetRequiredService<ILogger<BlockedCharacterHandler>>(),
gameInteropProvider));
services.AddSingleton(sp => new IpcProvider(
sp.GetRequiredService<ILogger<IpcProvider>>(),
pluginInterface,
sp.GetRequiredService<CharaDataManager>(),
sp.GetRequiredService<LightlessMediator>()));
// Tag (Groups) UIs
services.AddSingleton<SelectPairForTagUi>();
services.AddSingleton<RenamePairTagUi>();
services.AddSingleton<SelectSyncshellForTagUi>();
services.AddSingleton<RenameSyncshellTagUi>();
// Eventing / utilities
services.AddSingleton(sp => new EventAggregator(
configDir,
sp.GetRequiredService<ILogger<EventAggregator>>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new ActorObjectService(
sp.GetRequiredService<ILogger<ActorObjectService>>(),
framework,
gameInteropProvider,
objectTable,
clientState,
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new DalamudUtilService(
sp.GetRequiredService<ILogger<DalamudUtilService>>(),
clientState,
objectTable,
framework,
gameGui,
condition,
gameData,
targetManager,
gameConfig,
sp.GetRequiredService<ActorObjectService>(),
sp.GetRequiredService<BlockedCharacterHandler>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PerformanceCollectorService>(),
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<PlayerPerformanceConfigService>(),
new Lazy<PairFactory>(() => sp.GetRequiredService<PairFactory>())));
// Pairing and Dtr integration
services.AddSingleton<PairManager>();
services.AddSingleton<PairStateCache>();
services.AddSingleton<PairPerformanceMetricsCache>();
services.AddSingleton<PairLedger>();
services.AddSingleton<PairUiService>();
services.AddSingleton<IPairHandlerAdapterFactory, PairHandlerAdapterFactory>();
services.AddSingleton(sp => new PairHandlerRegistry(
sp.GetRequiredService<IPairHandlerAdapterFactory>(),
sp.GetRequiredService<PairManager>(),
sp.GetRequiredService<PairStateCache>(),
sp.GetRequiredService<PairPerformanceMetricsCache>(),
sp.GetRequiredService<ILogger<PairHandlerRegistry>>()));
services.AddSingleton(sp => new DtrEntry(
sp.GetRequiredService<ILogger<DtrEntry>>(),
dtrBar,
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PairUiService>(),
sp.GetRequiredService<PairRequestService>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<ServerConfigurationManager>(),
sp.GetRequiredService<LightFinderService>(),
sp.GetRequiredService<LightFinderScannerService>(),
sp.GetRequiredService<DalamudUtilService>()));
services.AddSingleton(sp => new PairCoordinator(
sp.GetRequiredService<ILogger<PairCoordinator>>(),
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PairHandlerRegistry>(),
sp.GetRequiredService<PairManager>(),
sp.GetRequiredService<PairLedger>(),
sp.GetRequiredService<ServerConfigurationManager>(),
sp.GetRequiredService<PairPerformanceMetricsCache>()));
// Light finder / redraw / context menu
services.AddSingleton<RedrawManager>();
services.AddSingleton<LightFinderService>();
services.AddSingleton(sp => new LightFinderPlateHandler(
sp.GetRequiredService<ILogger<LightFinderPlateHandler>>(),
sp.GetRequiredService<LightlessMediator>(),
pluginInterface,
sp.GetRequiredService<LightlessConfigService>(),
objectTable,
gameGui));
services.AddSingleton(sp => new LightFinderScannerService(
sp.GetRequiredService<ILogger<LightFinderScannerService>>(),
framework,
sp.GetRequiredService<LightFinderService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<LightFinderPlateHandler>(),
sp.GetRequiredService<ActorObjectService>()));
services.AddSingleton(sp => new ContextMenuService(
contextMenu,
pluginInterface,
gameData,
sp.GetRequiredService<ILogger<ContextMenuService>>(),
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<ApiController>(),
objectTable,
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<PairRequestService>(),
sp.GetRequiredService<PairUiService>(),
clientState,
sp.GetRequiredService<LightFinderScannerService>(),
sp.GetRequiredService<LightFinderService>(),
sp.GetRequiredService<LightlessProfileManager>(),
sp.GetRequiredService<LightlessMediator>()));
// IPC callers / manager
services.AddSingleton(sp => new IpcCallerPenumbra(
sp.GetRequiredService<ILogger<IpcCallerPenumbra>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<RedrawManager>(),
sp.GetRequiredService<ActorObjectService>()));
services.AddSingleton(sp => new IpcCallerGlamourer(
sp.GetRequiredService<ILogger<IpcCallerGlamourer>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<RedrawManager>()));
services.AddSingleton(sp => new IpcCallerCustomize(
sp.GetRequiredService<ILogger<IpcCallerCustomize>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcCallerHeels(
sp.GetRequiredService<ILogger<IpcCallerHeels>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcCallerHonorific(
sp.GetRequiredService<ILogger<IpcCallerHonorific>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcCallerMoodles(
sp.GetRequiredService<ILogger<IpcCallerMoodles>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcCallerPetNames(
sp.GetRequiredService<ILogger<IpcCallerPetNames>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcCallerBrio(
sp.GetRequiredService<ILogger<IpcCallerBrio>>(),
pluginInterface,
sp.GetRequiredService<DalamudUtilService>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddSingleton(sp => new IpcManager(
sp.GetRequiredService<ILogger<IpcManager>>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<IpcCallerPenumbra>(),
sp.GetRequiredService<IpcCallerGlamourer>(),
sp.GetRequiredService<IpcCallerCustomize>(),
sp.GetRequiredService<IpcCallerHeels>(),
sp.GetRequiredService<IpcCallerHonorific>(),
sp.GetRequiredService<IpcCallerMoodles>(),
sp.GetRequiredService<IpcCallerPetNames>(),
sp.GetRequiredService<IpcCallerBrio>()));
// Notifications / HTTP
services.AddSingleton(sp => new NotificationService(
sp.GetRequiredService<ILogger<NotificationService>>(),
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<DalamudUtilService>(),
notificationManager,
chatGui,
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PairRequestService>(),
sp.GetRequiredService<PairUiService>(),
sp.GetRequiredService<PairFactory>()));
services.AddSingleton(sp =>
{
collection.AddSingleton(new WindowSystem("LightlessSync"));
collection.AddSingleton<FileDialogManager>();
collection.AddSingleton(new Dalamud.Localization("LightlessSync.Localization.", "", useEmbedded: true));
collection.AddSingleton(gameGui);
var httpClient = new HttpClient();
var ver = Assembly.GetExecutingAssembly().GetName().Version;
httpClient.DefaultRequestHeaders.UserAgent.Add(
new ProductInfoHeaderValue("LightlessSync", $"{ver!.Major}.{ver.Minor}.{ver.Build}"));
return httpClient;
});
// add lightless related singletons
collection.AddSingleton<LightlessMediator>();
collection.AddSingleton<FileCacheManager>();
collection.AddSingleton<ServerConfigurationManager>();
collection.AddSingleton<ProfileTagService>();
collection.AddSingleton<ApiController>();
collection.AddSingleton<PerformanceCollectorService>();
collection.AddSingleton<HubFactory>();
collection.AddSingleton<FileUploadManager>();
collection.AddSingleton<FileTransferOrchestrator>();
collection.AddSingleton<LightlessPlugin>();
collection.AddSingleton<LightlessProfileManager>();
collection.AddSingleton<TextureCompressionService>();
collection.AddSingleton<TextureMetadataHelper>(s =>
{
var logger = s.GetRequiredService<ILogger<TextureMetadataHelper>>();
return new TextureMetadataHelper(logger, gameData);
});
collection.AddSingleton<TextureDownscaleService>();
collection.AddSingleton<GameObjectHandlerFactory>();
collection.AddSingleton<FileDownloadManagerFactory>();
collection.AddSingleton<PairProcessingLimiter>();
collection.AddSingleton(s => new PairFactory(
s.GetRequiredService<ILoggerFactory>(),
s.GetRequiredService<PairLedger>(),
s.GetRequiredService<LightlessMediator>(),
new Lazy<ServerConfigurationManager>(() => s.GetRequiredService<ServerConfigurationManager>()),
s.GetRequiredService<Lazy<ApiController>>()));
collection.AddSingleton<XivDataAnalyzer>();
collection.AddSingleton<CharacterAnalyzer>();
collection.AddSingleton<TokenProvider>();
collection.AddSingleton<PluginWarningNotificationService>();
collection.AddSingleton<FileCompactor>();
collection.AddSingleton<TagHandler>();
collection.AddSingleton(s => new Lazy<ApiController>(() => s.GetRequiredService<ApiController>()));
collection.AddSingleton<PairRequestService>();
collection.AddSingleton<ZoneChatService>();
collection.AddSingleton<IdDisplayHandler>();
collection.AddSingleton<PlayerPerformanceService>();
collection.AddSingleton(s => new TransientResourceManager(s.GetRequiredService<ILogger<TransientResourceManager>>(),
s.GetRequiredService<TransientConfigService>(),
s.GetRequiredService<DalamudUtilService>(),
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<ActorObjectService>(),
s.GetRequiredService<GameObjectHandlerFactory>()));
// Lightless Config services
services.AddSingleton(sp => new UiThemeConfigService(configDir));
services.AddSingleton(sp => new ChatConfigService(configDir));
services.AddSingleton(sp =>
{
var cfg = new LightlessConfigService(configDir);
var theme = sp.GetRequiredService<UiThemeConfigService>();
LightlessSync.UI.Style.MainStyle.Init(cfg, theme);
return cfg;
});
services.AddSingleton(sp => new ServerConfigService(configDir));
services.AddSingleton(sp => new NotesConfigService(configDir));
services.AddSingleton(sp => new PairTagConfigService(configDir));
services.AddSingleton(sp => new SyncshellTagConfigService(configDir));
services.AddSingleton(sp => new TransientConfigService(configDir));
services.AddSingleton(sp => new XivDataStorageService(configDir));
services.AddSingleton(sp => new PlayerPerformanceConfigService(configDir));
services.AddSingleton(sp => new CharaDataConfigService(configDir));
collection.AddSingleton<CharaDataManager>();
collection.AddSingleton<CharaDataFileHandler>();
collection.AddSingleton<CharaDataCharacterHandler>();
collection.AddSingleton<CharaDataNearbyManager>();
collection.AddSingleton<CharaDataGposeTogetherManager>();
// Config adapters
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<LightlessConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<UiThemeConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<ChatConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<ServerConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<NotesConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<PairTagConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<SyncshellTagConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<TransientConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<XivDataStorageService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<PlayerPerformanceConfigService>());
services.AddSingleton<IConfigService<ILightlessConfiguration>>(sp => sp.GetRequiredService<CharaDataConfigService>());
collection.AddSingleton(s => new VfxSpawnManager(s.GetRequiredService<ILogger<VfxSpawnManager>>(),
gameInteropProvider, s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new BlockedCharacterHandler(s.GetRequiredService<ILogger<BlockedCharacterHandler>>(), gameInteropProvider));
collection.AddSingleton((s) => new IpcProvider(s.GetRequiredService<ILogger<IpcProvider>>(),
pluginInterface,
s.GetRequiredService<CharaDataManager>(),
s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton<SelectPairForTagUi>();
collection.AddSingleton<RenamePairTagUi>();
collection.AddSingleton<SelectSyncshellForTagUi>();
collection.AddSingleton<RenameSyncshellTagUi>();
collection.AddSingleton((s) => new EventAggregator(pluginInterface.ConfigDirectory.FullName,
s.GetRequiredService<ILogger<EventAggregator>>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService<ILogger<DalamudUtilService>>(),
clientState, objectTable, framework, gameGui, condition, gameData, targetManager, gameConfig,
s.GetRequiredService<ActorObjectService>(), s.GetRequiredService<BlockedCharacterHandler>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<PerformanceCollectorService>(),
s.GetRequiredService<LightlessConfigService>(), s.GetRequiredService<PlayerPerformanceConfigService>(), new Lazy<PairFactory>(() => s.GetRequiredService<PairFactory>())));
collection.AddSingleton<PairManager>();
collection.AddSingleton<PairStateCache>();
collection.AddSingleton<PairPerformanceMetricsCache>();
collection.AddSingleton<IPairHandlerAdapterFactory, PairHandlerAdapterFactory>();
collection.AddSingleton(s => new PairHandlerRegistry(
s.GetRequiredService<IPairHandlerAdapterFactory>(),
s.GetRequiredService<PairManager>(),
s.GetRequiredService<PairStateCache>(),
s.GetRequiredService<PairPerformanceMetricsCache>(),
s.GetRequiredService<ILogger<PairHandlerRegistry>>()));
collection.AddSingleton<PairLedger>();
collection.AddSingleton<PairUiService>();
collection.AddSingleton((s) => new DtrEntry(
s.GetRequiredService<ILogger<DtrEntry>>(),
dtrBar,
s.GetRequiredService<LightlessConfigService>(),
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<PairUiService>(),
s.GetRequiredService<PairRequestService>(),
s.GetRequiredService<ApiController>(),
s.GetRequiredService<ServerConfigurationManager>(),
s.GetRequiredService<LightFinderService>(),
s.GetRequiredService<LightFinderScannerService>(),
s.GetRequiredService<DalamudUtilService>()));
collection.AddSingleton(s => new PairCoordinator(
s.GetRequiredService<ILogger<PairCoordinator>>(),
s.GetRequiredService<LightlessConfigService>(),
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<PairHandlerRegistry>(),
s.GetRequiredService<PairManager>(),
s.GetRequiredService<PairLedger>(),
s.GetRequiredService<ServerConfigurationManager>(),
s.GetRequiredService<PairPerformanceMetricsCache>()));
collection.AddSingleton<RedrawManager>();
collection.AddSingleton<LightFinderService>();
collection.AddSingleton(addonLifecycle);
collection.AddSingleton(p => new ContextMenuService(contextMenu, pluginInterface, gameData, p.GetRequiredService<ILogger<ContextMenuService>>(), p.GetRequiredService<DalamudUtilService>(), p.GetRequiredService<ApiController>(), objectTable,
p.GetRequiredService<LightlessConfigService>(),
p.GetRequiredService<PairRequestService>(),
p.GetRequiredService<PairUiService>(),
clientState,
p.GetRequiredService<LightFinderScannerService>(),
p.GetRequiredService<LightFinderService>(),
p.GetRequiredService<LightlessProfileManager>(),
p.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerPenumbra(s.GetRequiredService<ILogger<IpcCallerPenumbra>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<RedrawManager>(),
s.GetRequiredService<ActorObjectService>()));
collection.AddSingleton((s) => new IpcCallerGlamourer(s.GetRequiredService<ILogger<IpcCallerGlamourer>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<RedrawManager>()));
collection.AddSingleton((s) => new IpcCallerCustomize(s.GetRequiredService<ILogger<IpcCallerCustomize>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerHeels(s.GetRequiredService<ILogger<IpcCallerHeels>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerHonorific(s.GetRequiredService<ILogger<IpcCallerHonorific>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerMoodles(s.GetRequiredService<ILogger<IpcCallerMoodles>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerPetNames(s.GetRequiredService<ILogger<IpcCallerPetNames>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcCallerBrio(s.GetRequiredService<ILogger<IpcCallerBrio>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>()));
collection.AddSingleton((s) => new IpcManager(s.GetRequiredService<ILogger<IpcManager>>(),
s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<IpcCallerPenumbra>(), s.GetRequiredService<IpcCallerGlamourer>(),
s.GetRequiredService<IpcCallerCustomize>(), s.GetRequiredService<IpcCallerHeels>(), s.GetRequiredService<IpcCallerHonorific>(),
s.GetRequiredService<IpcCallerMoodles>(), s.GetRequiredService<IpcCallerPetNames>(), s.GetRequiredService<IpcCallerBrio>()));
collection.AddSingleton((s) => new NotificationService(
s.GetRequiredService<ILogger<NotificationService>>(),
s.GetRequiredService<LightlessConfigService>(),
s.GetRequiredService<DalamudUtilService>(),
notificationManager,
chatGui,
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<PairRequestService>(),
s.GetRequiredService<PairUiService>(),
s.GetRequiredService<PairFactory>()));
collection.AddSingleton((s) =>
{
var httpClient = new HttpClient();
var ver = Assembly.GetExecutingAssembly().GetName().Version;
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("LightlessSync", ver!.Major + "." + ver!.Minor + "." + ver!.Build));
return httpClient;
});
collection.AddSingleton((s) => new UiThemeConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new ChatConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) =>
{
var cfg = new LightlessConfigService(pluginInterface.ConfigDirectory.FullName);
var theme = s.GetRequiredService<UiThemeConfigService>();
LightlessSync.UI.Style.MainStyle.Init(cfg, theme);
return cfg;
});
collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new NotesConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new PairTagConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new SyncshellTagConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new TransientConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new XivDataStorageService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new PlayerPerformanceConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new CharaDataConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<LightlessConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<UiThemeConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<ChatConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<ServerConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<NotesConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<PairTagConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<SyncshellTagConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<TransientConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<XivDataStorageService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<PlayerPerformanceConfigService>());
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<CharaDataConfigService>());
collection.AddSingleton<ConfigurationMigrator>();
collection.AddSingleton<ConfigurationSaveService>();
collection.AddSingleton(sp => new ActorObjectService(
sp.GetRequiredService<ILogger<ActorObjectService>>(),
framework,
gameInteropProvider,
objectTable,
clientState,
sp.GetRequiredService<LightlessMediator>()));
collection.AddSingleton<HubFactory>();
collection.AddSingleton(s => new LightFinderScannerService(s.GetRequiredService<ILogger<LightFinderScannerService>>(), framework, s.GetRequiredService<LightFinderService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<LightFinderPlateHandler>(), s.GetRequiredService<ActorObjectService>()));
collection.AddSingleton((s) => new LightFinderPlateHandler(s.GetRequiredService<ILogger<LightFinderPlateHandler>>(),
s.GetRequiredService<LightlessMediator>(), pluginInterface,
s.GetRequiredService<LightlessConfigService>(),
objectTable, gameGui));
services.AddSingleton<ConfigurationMigrator>();
services.AddSingleton<ConfigurationSaveService>();
// add scoped services
collection.AddScoped<DrawEntityFactory>();
collection.AddScoped<CacheMonitor>();
collection.AddScoped<UiFactory>();
collection.AddScoped<SelectTagForPairUi>();
collection.AddScoped<SelectTagForSyncshellUi>();
collection.AddScoped<WindowMediatorSubscriberBase, SettingsUi>();
collection.AddScoped<WindowMediatorSubscriberBase, CompactUi>();
collection.AddScoped<WindowMediatorSubscriberBase, IntroUi>();
collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
collection.AddScoped<WindowMediatorSubscriberBase, JoinSyncshellUI>();
collection.AddScoped<WindowMediatorSubscriberBase, CreateSyncshellUI>();
collection.AddScoped<WindowMediatorSubscriberBase, EventViewerUI>();
collection.AddScoped<WindowMediatorSubscriberBase, CharaDataHubUi>();
collection.AddScoped<WindowMediatorSubscriberBase, UpdateNotesUi>();
collection.AddScoped<WindowMediatorSubscriberBase, ZoneChatUi>();
// Scoped factories / UI
services.AddScoped<DrawEntityFactory>();
services.AddScoped<CacheMonitor>();
services.AddScoped<UiFactory>();
services.AddScoped<SelectTagForPairUi>();
services.AddScoped<SelectTagForSyncshellUi>();
services.AddScoped<WindowMediatorSubscriberBase, SettingsUi>();
services.AddScoped<WindowMediatorSubscriberBase, CompactUi>();
services.AddScoped<WindowMediatorSubscriberBase, IntroUi>();
services.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
services.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
services.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
services.AddScoped<WindowMediatorSubscriberBase, JoinSyncshellUI>();
services.AddScoped<WindowMediatorSubscriberBase, CreateSyncshellUI>();
services.AddScoped<WindowMediatorSubscriberBase, EventViewerUI>();
services.AddScoped<WindowMediatorSubscriberBase, CharaDataHubUi>();
services.AddScoped<WindowMediatorSubscriberBase, UpdateNotesUi>();
services.AddScoped<WindowMediatorSubscriberBase, ZoneChatUi>();
collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>((s) => new EditProfileUi(s.GetRequiredService<ILogger<EditProfileUi>>(),
s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<ApiController>(), s.GetRequiredService<UiSharedService>(), s.GetRequiredService<FileDialogManager>(),
s.GetRequiredService<LightlessProfileManager>(), s.GetRequiredService<ProfileTagService>(), s.GetRequiredService<PerformanceCollectorService>()));
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
collection.AddScoped<WindowMediatorSubscriberBase, LightFinderUI>((s) => new LightFinderUI(s.GetRequiredService<ILogger<LightFinderUI>>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<PerformanceCollectorService>(), s.GetRequiredService<LightFinderService>(), s.GetRequiredService<LightlessConfigService>(), s.GetRequiredService<UiSharedService>(), s.GetRequiredService<ApiController>(), s.GetRequiredService<LightFinderScannerService>()));
collection.AddScoped<WindowMediatorSubscriberBase, SyncshellFinderUI>((s) => new SyncshellFinderUI(s.GetRequiredService<ILogger<SyncshellFinderUI>>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<PerformanceCollectorService>(), s.GetRequiredService<LightFinderService>(), s.GetRequiredService<UiSharedService>(), s.GetRequiredService<ApiController>(), s.GetRequiredService<LightFinderScannerService>(), s.GetRequiredService<PairUiService>(), s.GetRequiredService<DalamudUtilService>()));
collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
collection.AddScoped<WindowMediatorSubscriberBase, LightlessNotificationUi>((s) =>
new LightlessNotificationUi(
s.GetRequiredService<ILogger<LightlessNotificationUi>>(),
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<PerformanceCollectorService>(),
s.GetRequiredService<LightlessConfigService>()));
collection.AddScoped<IPopupHandler, CensusPopupHandler>();
collection.AddScoped<CacheCreationService>();
collection.AddScoped<PlayerDataFactory>();
collection.AddScoped<VisibleUserDataDistributor>();
collection.AddScoped((s) => new UiService(s.GetRequiredService<ILogger<UiService>>(), pluginInterface.UiBuilder, s.GetRequiredService<LightlessConfigService>(),
s.GetRequiredService<WindowSystem>(), s.GetServices<WindowMediatorSubscriberBase>(),
s.GetRequiredService<UiFactory>(),
s.GetRequiredService<FileDialogManager>(),
s.GetRequiredService<LightlessMediator>(),
s.GetRequiredService<PairFactory>()));
collection.AddScoped((s) => new CommandManagerService(commandManager, s.GetRequiredService<PerformanceCollectorService>(),
s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<ApiController>(),
s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<LightlessConfigService>()));
collection.AddScoped((s) => new UiSharedService(s.GetRequiredService<ILogger<UiSharedService>>(), s.GetRequiredService<IpcManager>(), s.GetRequiredService<ApiController>(),
s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<LightlessConfigService>(), s.GetRequiredService<DalamudUtilService>(),
pluginInterface, textureProvider, s.GetRequiredService<Dalamud.Localization>(), s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<TokenProvider>(),
s.GetRequiredService<LightlessMediator>()));
collection.AddScoped((s) => new NameplateService(s.GetRequiredService<ILogger<NameplateService>>(), s.GetRequiredService<LightlessConfigService>(), clientState, gameGui, objectTable, gameInteropProvider,
s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<PairUiService>()));
services.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>(sp => new EditProfileUi(
sp.GetRequiredService<ILogger<EditProfileUi>>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<UiSharedService>(),
sp.GetRequiredService<FileDialogManager>(),
sp.GetRequiredService<LightlessProfileManager>(),
sp.GetRequiredService<ProfileTagService>(),
sp.GetRequiredService<PerformanceCollectorService>()));
collection.AddHostedService(p => p.GetRequiredService<ConfigurationSaveService>());
collection.AddHostedService(p => p.GetRequiredService<ActorObjectService>());
collection.AddHostedService(p => p.GetRequiredService<LightlessMediator>());
collection.AddHostedService(p => p.GetRequiredService<ZoneChatService>());
collection.AddHostedService(p => p.GetRequiredService<NotificationService>());
collection.AddHostedService(p => p.GetRequiredService<FileCacheManager>());
collection.AddHostedService(p => p.GetRequiredService<ConfigurationMigrator>());
collection.AddHostedService(p => p.GetRequiredService<DalamudUtilService>());
collection.AddHostedService(p => p.GetRequiredService<PerformanceCollectorService>());
collection.AddHostedService(p => p.GetRequiredService<DtrEntry>());
collection.AddHostedService(p => p.GetRequiredService<EventAggregator>());
collection.AddHostedService(p => p.GetRequiredService<IpcProvider>());
collection.AddHostedService(p => p.GetRequiredService<LightlessPlugin>());
collection.AddHostedService(p => p.GetRequiredService<ContextMenuService>());
collection.AddHostedService(p => p.GetRequiredService<LightFinderService>());
collection.AddHostedService(p => p.GetRequiredService<LightFinderPlateHandler>());
})
.Build();
services.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
services.AddScoped<WindowMediatorSubscriberBase, LightFinderUI>(sp => new LightFinderUI(
sp.GetRequiredService<ILogger<LightFinderUI>>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PerformanceCollectorService>(),
sp.GetRequiredService<LightFinderService>(),
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<UiSharedService>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<LightFinderScannerService>()));
services.AddScoped<WindowMediatorSubscriberBase, SyncshellFinderUI>(sp => new SyncshellFinderUI(
sp.GetRequiredService<ILogger<SyncshellFinderUI>>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PerformanceCollectorService>(),
sp.GetRequiredService<LightFinderService>(),
sp.GetRequiredService<UiSharedService>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<LightFinderScannerService>(),
sp.GetRequiredService<PairUiService>(),
sp.GetRequiredService<DalamudUtilService>()));
services.AddScoped<IPopupHandler, BanUserPopupHandler>();
services.AddScoped<IPopupHandler, CensusPopupHandler>();
services.AddScoped<WindowMediatorSubscriberBase, LightlessNotificationUi>(sp =>
new LightlessNotificationUi(
sp.GetRequiredService<ILogger<LightlessNotificationUi>>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PerformanceCollectorService>(),
sp.GetRequiredService<LightlessConfigService>()));
services.AddScoped<CacheCreationService>();
services.AddScoped<PlayerDataFactory>();
services.AddScoped<VisibleUserDataDistributor>();
services.AddScoped(sp => new UiService(
sp.GetRequiredService<ILogger<UiService>>(),
pluginInterface.UiBuilder,
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<WindowSystem>(),
sp.GetServices<WindowMediatorSubscriberBase>(),
sp.GetRequiredService<UiFactory>(),
sp.GetRequiredService<FileDialogManager>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PairFactory>()));
services.AddScoped(sp => new CommandManagerService(
commandManager,
sp.GetRequiredService<PerformanceCollectorService>(),
sp.GetRequiredService<ServerConfigurationManager>(),
sp.GetRequiredService<CacheMonitor>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<LightlessConfigService>()));
services.AddScoped(sp => new UiSharedService(
sp.GetRequiredService<ILogger<UiSharedService>>(),
sp.GetRequiredService<IpcManager>(),
sp.GetRequiredService<ApiController>(),
sp.GetRequiredService<CacheMonitor>(),
sp.GetRequiredService<FileDialogManager>(),
sp.GetRequiredService<LightlessConfigService>(),
sp.GetRequiredService<DalamudUtilService>(),
pluginInterface,
textureProvider,
sp.GetRequiredService<Dalamud.Localization>(),
sp.GetRequiredService<ServerConfigurationManager>(),
sp.GetRequiredService<TokenProvider>(),
sp.GetRequiredService<LightlessMediator>()));
services.AddScoped(sp => new NameplateService(
sp.GetRequiredService<ILogger<NameplateService>>(),
sp.GetRequiredService<LightlessConfigService>(),
clientState,
gameGui,
objectTable,
gameInteropProvider,
sp.GetRequiredService<LightlessMediator>(),
sp.GetRequiredService<PairUiService>()));
// Hosted services
services.AddHostedService(sp => sp.GetRequiredService<ConfigurationSaveService>());
services.AddHostedService(sp => sp.GetRequiredService<ActorObjectService>());
services.AddHostedService(sp => sp.GetRequiredService<LightlessMediator>());
services.AddHostedService(sp => sp.GetRequiredService<ZoneChatService>());
services.AddHostedService(sp => sp.GetRequiredService<NotificationService>());
services.AddHostedService(sp => sp.GetRequiredService<FileCacheManager>());
services.AddHostedService(sp => sp.GetRequiredService<ConfigurationMigrator>());
services.AddHostedService(sp => sp.GetRequiredService<DalamudUtilService>());
services.AddHostedService(sp => sp.GetRequiredService<PerformanceCollectorService>());
services.AddHostedService(sp => sp.GetRequiredService<DtrEntry>());
services.AddHostedService(sp => sp.GetRequiredService<EventAggregator>());
services.AddHostedService(sp => sp.GetRequiredService<IpcProvider>());
services.AddHostedService(sp => sp.GetRequiredService<LightlessPlugin>());
services.AddHostedService(sp => sp.GetRequiredService<ContextMenuService>());
services.AddHostedService(sp => sp.GetRequiredService<LightFinderService>());
services.AddHostedService(sp => sp.GetRequiredService<LightFinderPlateHandler>());
}).Build();
_ = _host.StartAsync();
}