public void Initialize() { ServiceProvider.MessageBuilder = new MessageBuilder(); ServiceProvider.MainMenuFactory = new MainMenuListFactory(); ServiceProvider.CurrencyProvider = new DefaultCurrencyProvider(); StorageFactory storageFactory = new StorageFactory(); ServiceProvider.EventSourcingContextFactory = storageFactory; ServiceProvider.ReadModelContextFactory = storageFactory; ServiceProvider.StorageContainerFactory = storageFactory; Domain(); PriceCalculator priceCalculator = new PriceCalculator(eventDispatcher.Handlers); ServiceProvider.PriceConverter = priceCalculator; ReadModels(); ServiceProvider.QueryDispatcher = new UserQueryDispatcher(queryDispatcher, () => UserKey); ServiceProvider.CommandDispatcher = new UserCommandDispatcher(commandDispatcher, () => UserKey); ServiceProvider.EventHandlers = eventDispatcher.Handlers; UpgradeService upgradeService = new UpgradeService(ServiceProvider.CommandDispatcher, EventStore, EventFormatter, storageFactory, storageFactory, storageFactory, priceCalculator, () => UserKey); ServiceProvider.UpgradeService = upgradeService; ServiceProvider.TileService = new TileService(); ServiceProvider.DevelopmentTools = new DevelopmentService(upgradeService, storageFactory); ServiceProvider.RestartService = new RestartService(launchArguments); ServiceProvider.UserPreferences = new ApplicationSettingsService(new CompositeTypeFormatterFactory(typeProvider), storageFactory); CurrencyCache currencyCache = new CurrencyCache(eventDispatcher.Handlers, queryDispatcher); using (var eventSourcing = ServiceProvider.EventSourcingContextFactory.Create()) eventSourcing.Database.EnsureCreated(); using (var readModels = ServiceProvider.ReadModelContextFactory.Create()) readModels.Database.EnsureCreated(); currencyCache.InitializeAsync(ServiceProvider.QueryDispatcher); priceCalculator.InitializeAsync(ServiceProvider.QueryDispatcher); }
private async Task InitializeCacheAsync(PriceCalculator priceCalculator, CurrencyCache currencyCache) { await currencyCache.InitializeAsync(ServiceProvider.QueryDispatcher); await priceCalculator.InitializeAsync(ServiceProvider.QueryDispatcher); }