public async Task Handle(DataInitializationStarted notification, CancellationToken cancellationToken) { await modifierProvider.Initialize(); await pseudoModifierProvider.Initialize(); }
public async Task <Unit> Handle(InitializeCommand request, CancellationToken cancellationToken) { try { Completed = 0; Count = request.FirstRun ? 10 : 7; // Report initial progress await ReportProgress(); // Open a clean view of the initialization viewLocator.CloseAll(); if (settings.ShowSplashScreen) { await viewLocator.Open(View.Initialization); } // Set the UI language await RunCommandStep(new SetUiLanguageCommand(settings.Language_UI)); // Check for updates if (request.AutoUpdate && await mediator.Send(new CheckForUpdate(), cancellationToken)) { viewLocator.Close(View.Initialization); return(Unit.Value); } // Check to see if we should run Setup first before running the rest of the initialization process if (string.IsNullOrEmpty(settings.LeagueId) || string.IsNullOrEmpty(settings.Language_Parser) || string.IsNullOrEmpty(settings.Language_UI)) { viewLocator.Close(View.Initialization); await viewLocator.Open(View.Setup); return(Unit.Value); } // Set the game language await RunCommandStep(new SetGameLanguageCommand(settings.Language_Parser)); if (request.FirstRun) { var leagues = await mediator.Send(new GetLeaguesQuery(false)); var leaguesHash = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(leagues))); if (leaguesHash != settings.LeaguesHash) { await mediator.Send(new ClearCacheCommand()); await mediator.Send(new SaveSettingCommand(nameof(ISidekickSettings.LeaguesHash), leaguesHash)); } // Check to see if we should run Setup first before running the rest of the initialization process if (string.IsNullOrEmpty(settings.LeagueId) || !leagues.Any(x => x.Id == settings.LeagueId)) { await mediator.Send(new OpenNotificationCommand(resources.NewLeagues)); viewLocator.Close(View.Initialization); await viewLocator.Open(View.Setup); return(Unit.Value); } } await Run(() => parserPatterns.Initialize()); await Run(() => itemMetadataProvider.Initialize()); await Run(() => itemStaticDataProvider.Initialize()); await Run(() => modifierProvider.Initialize()); await Run(() => pseudoModifierProvider.Initialize()); if (request.FirstRun) { await Run(() => processProvider.Initialize(cancellationToken)); await Run(() => keyboardProvider.Initialize()); await Run(() => keybindProvider.Initialize()); } // If we have a successful initialization, we delay for half a second to show the "Ready" label on the UI before closing the view Completed = Count; await ReportProgress(); await Task.Delay(500); // Show a system notification await mediator.Send(new OpenNotificationCommand(string.Format(resources.Notification_Message, settings.Trade_Key_Check.ToKeybindString(), settings.Key_Close.ToKeybindString()), resources.Notification_Title)); viewLocator.Close(View.Initialization); return(Unit.Value); } catch (Exception ex) { logger.LogError(ex.Message); await mediator.Send(new OpenNotificationCommand(resources.Error)); await mediator.Send(new ShutdownCommand()); return(Unit.Value); } }