コード例 #1
0
        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);
                    }
                });
            };
        }
コード例 #2
0
 public ScriptRunnerService(IMessageService logMessageService,
                            IScriptLocatorService scriptLocatorService)
 {
     _logMessageService    = logMessageService;
     _scriptLocatorService = scriptLocatorService;
 }