private void StartApplication(StartupEventArgs e) { SetupAutomapper(); // TODO: Add IOC Container / Service locator var userRequestsHelper = new UserRequestsHelper(); var persistenceService = new PersistenceService(AppDataFolder); var torrentSessionService = new TorrentSessionService(DownloadsFolder); var torrentsSessionViewModel = new TransferListViewModel(userRequestsHelper, persistenceService, torrentSessionService); var mainWindowViewModel = new MainWindowViewModel(torrentsSessionViewModel); var window = new MainWindow(mainWindowViewModel); window.Show(); _notifyIconIconHelper = new SytemTrayIconHelper(window); // TODO: Add a message broker Current.Exit += (sender, args) => { torrentsSessionViewModel.OnAplicationExit(); torrentSessionService.OnApplicationExit(); }; if (e.Args.Any()) { torrentsSessionViewModel.AddNewTorrent(e.Args[0]); } _singleHelper.StartNewProcessListener(torrentsSessionViewModel, window); }
public TransferListViewModel(UserRequestsHelper userRequestsHelper, PersistenceService persistenceService, TorrentSessionService torrentSessionService) { _userRequestsHelper = userRequestsHelper; _persistenceService = persistenceService; _torrentSessionService = torrentSessionService; LoadTorrentInfos(); Torrents.CollectionChanged += Torrents_CollectionChanged; StartUpdateLoop(); CreateCommands(); }