protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); AssureAppDataDirectoriesExist(); /////////////////////////////////////////////////////////////////////////////////////////////// //////// ////////// //////// Composition Root and Setup ////////// //////// ////////// /////////////////////////////////////////////////////////////////////////////////////////////// var connectionService = new ConnectionService(); var eventBus = new ClientEventBus(connectionService); var commandHandlerCollection = new SingleHandlerCollection <DomainCommand>(); var commandMessageBus = new LocalMessageBus <DomainCommand>(commandHandlerCollection); var commandBus = new CommandBus(commandMessageBus); var persistenceService = new LocalSettingsXMLPersistenceService(GlobalConstants.LocalSettingsPersistenceFile); var localSettingsRepository = new LocalSettingsRepository(persistenceService); localSettingsRepository.LoadRepository(); var clientMedicalPracticeRepository = new ClientMedicalPracticeRepository(connectionService); var clientPatientRepository = new ClientPatientRepository(connectionService); var clienttherapyPlaceTypeRepository = new ClientTherapyPlaceTypeRepository(connectionService); var clientLabelRepository = new ClientLabelRepository(connectionService); var clientReadmodelRepository = new ClientReadModelRepository(eventBus, clientPatientRepository, clientMedicalPracticeRepository, clientLabelRepository, connectionService); var workFlow = new ClientWorkflow(); var session = new Session(connectionService, workFlow); var fatalErrorHandler = new FatalErrorHandler(session); var commandService = new CommandService(session, clientReadmodelRepository, commandBus); var userActionBuilder = new UserActionBuilder(commandService); // CommandHandler var addAppointmentCommandHandler = new AddAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var deleteAppointmentCommandHandler = new DeleteAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var replaceAppointmentCommandHandler = new ReplaceAppointmentCommandHandler(connectionService, session, clientPatientRepository, clientMedicalPracticeRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); commandBus.RegisterCommandHandler(addAppointmentCommandHandler); commandBus.RegisterCommandHandler(deleteAppointmentCommandHandler); commandBus.RegisterCommandHandler(replaceAppointmentCommandHandler); // initiate ViewModelCommunication var handlerCollection = new MultiHandlerCollection <ViewModelMessage>(); IMessageBus <ViewModelMessage> viewModelMessageBus = new LocalMessageBus <ViewModelMessage>(handlerCollection); IViewModelCollectionList viewModelCollections = new ViewModelCollectionList(); IViewModelCommunication viewModelCommunication = new ViewModelCommunication(viewModelMessageBus, viewModelCollections); var mainWindowBuilder = new MainWindowBuilder(localSettingsRepository, clientPatientRepository, clientMedicalPracticeRepository, clientReadmodelRepository, clienttherapyPlaceTypeRepository, clientLabelRepository, commandService, viewModelCommunication, session, "0.1.0.0", // TODO: get real versionNumber fatalErrorHandler.HandleFatalError); var mainWindow = mainWindowBuilder.BuildWindow(); mainWindow.ShowDialog(); /////////////////////////////////////////////////////////////////////////////////////////////// //////// ////////// //////// Clean Up and store data after main Window was closed ////////// //////// ////////// /////////////////////////////////////////////////////////////////////////////////////////////// localSettingsRepository.PersistRepository(); connectionService.Dispose(); }
protected override void EndProcessing() { base.EndProcessing(); service.Dispose(); }