-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathAddServiceControlInstanceCommand.cs
More file actions
51 lines (44 loc) · 1.94 KB
/
Copy pathAddServiceControlInstanceCommand.cs
File metadata and controls
51 lines (44 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace ServiceControl.Config.Commands
{
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Framework;
using Framework.Commands;
using UI.InstanceAdd;
class AddServiceControlInstanceCommand : AwaitableAbstractCommand<object>
{
public AddServiceControlInstanceCommand(IServiceControlWindowManager windowManager, Func<ServiceControlAddViewModel> addInstance, ScmuCommandChecks commandChecks)
: base(null)
{
this.windowManager = windowManager;
this.addInstance = addInstance;
this.commandChecks = commandChecks;
}
public override async Task ExecuteAsync(object obj)
{
await ExecuteWithOptions(installError: true, installAudit: true, installServicePulse: true);
}
public async Task ExecuteWithOptions(bool installError, bool installAudit, bool installServicePulse, CancellationToken cancellationToken = default)
{
if (!await commandChecks.CanAddInstance(true, cancellationToken))
{
return;
}
var instanceViewModel = addInstance();
instanceViewModel.InstallErrorInstance = installError;
instanceViewModel.InstallAuditInstance = installAudit;
if (installError)
{
// The options list always carries both an On and an Off entry.
instanceViewModel.ServiceControl.EnableIntegratedServicePulse = instanceViewModel.ServiceControl
.EnableIntegratedServicePulseOptions.First(o => o.Value == installServicePulse);
}
await windowManager.ShowInnerDialog(instanceViewModel, cancellationToken: cancellationToken);
}
readonly Func<ServiceControlAddViewModel> addInstance;
readonly IServiceControlWindowManager windowManager;
readonly ScmuCommandChecks commandChecks;
}
}