// this constructor is called from XAML - use fixed dependencies public MiningViewModel() { // enforce a minimum of ten seconds for the polling period var pollingPeriod = TimeSpan.FromSeconds(Math.Max(TimeSpan.FromSeconds(10).TotalSeconds, Settings.Default.MinerWatchdogPollingPeriod.TotalSeconds)); if (pollingPeriod != Settings.Default.MinerWatchdogPollingPeriod) { AddMessage(string.Format("Setting MinerWatchdogPollingPeriod to minimum polling period [{0}].", pollingPeriod)); } IController controller = null; ISummaryDataManager dataManager = null; if (!IsDesignMode) { var minerComms = new MinerCommunication(Settings.Default.MinerProcessName, Settings.Default.LaunchCommand, Settings.Default.ImportantProcessNames.Cast <string>()); controller = new Controller(minerComms, pollingPeriod); dataManager = new SummaryDataManager(Settings.Default.SaveInterval); } var idleTimeProvider = new IdleTimeProvider(); var windowController = new WindowController(); var conn = new Connection(new ProductHeaderValue(Title.Replace(" ", string.Empty))); var api = new ApiConnection(conn); var releasesClient = new ReleasesClient(api); var versionService = new VersionService(releasesClient, GitHubOwner, GitHubRepo); this.InitializeDesignTime(controller, idleTimeProvider, dataManager, windowController, versionService); }
// this constructor is called from XAML - use fixed dependencies public MiningViewModel() { // enforce a minimum of ten seconds for the polling period var pollingPeriod = TimeSpan.FromSeconds(Math.Max(TimeSpan.FromSeconds(10).TotalSeconds, Settings.Default.MinerWatchdogPollingPeriod.TotalSeconds)); if (pollingPeriod != Settings.Default.MinerWatchdogPollingPeriod) { AddMessage(string.Format("Setting MinerWatchdogPollingPeriod to minimum polling period [{0}].", pollingPeriod)); } IController controller = null; ISummaryDataManager dataManager = null; if (!IsDesignMode) { var minerComms = new MinerCommunication(Settings.Default.MinerProcessName, Settings.Default.LaunchCommand, Settings.Default.ImportantProcessNames.Cast<string>()); controller = new Controller(minerComms, pollingPeriod); dataManager = new SummaryDataManager(Settings.Default.SaveInterval); } var idleTimeProvider = new IdleTimeProvider(); var windowController = new WindowController(); var conn = new Connection(new ProductHeaderValue(Title.Replace(" ", string.Empty))); var api = new ApiConnection(conn); var releasesClient = new ReleasesClient(api); var versionService = new VersionService(releasesClient, GitHubOwner, GitHubRepo); this.InitializeDesignTime(controller, idleTimeProvider, dataManager, windowController, versionService); }