public MainViewModel(IScriptLocatorService scriptLocatorService, IScriptRunnerService scriptRunnerService, AlertService alertService) { _alertService = alertService; _scriptLocatorService = scriptLocatorService; _scriptRunnerService = scriptRunnerService; _scriptLocatorService.OnScriptsUpdated += x => { Scripts = new ObservableCollection <PowershellScript>(x); }; _scriptRunnerService.ScriptRunComplete += x => { MainWindow.RootDispatcher.Invoke(() => { //HACK! This forces update of the LastRun property. Correct way would be to implement INotifyPropertyChanged in derived class. int index = Scripts.IndexOf(x); if (index != -1) { Scripts.RemoveAt(index); Scripts.Insert(index, x); } }); }; }
public ScriptRunnerService(IMessageService logMessageService, IScriptLocatorService scriptLocatorService) { _logMessageService = logMessageService; _scriptLocatorService = scriptLocatorService; }