-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseDestroyDeviceCommand.cs
48 lines (41 loc) · 1.91 KB
/
BaseDestroyDeviceCommand.cs
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
using CK.Core;
using System;
using System.Collections.Generic;
using System.Text;
namespace CK.DeviceModel;
/// <summary>
/// Non generic base for <see cref="DestroyDeviceCommand{THost}"/> command that
/// destroys a device.
/// </summary>
/// <remarks>
/// This class cannot be specialized. The only concrete type of this command is <see cref="DestroyDeviceCommand{THost}"/>.
/// </remarks>
public abstract class BaseDestroyDeviceCommand : DeviceCommandNoResult
{
private protected BaseDestroyDeviceCommand()
{
ImmediateSending = true;
ShouldCallDeviceOnCommandCompleted = false;
}
/// <summary>
/// Transforms any error into successful result.
/// </summary>
/// <param name="ex">The exception.</param>
/// <param name="result">The result setter.</param>
protected override sealed void OnError( Exception ex, ref CompletionSource.OnError result ) => result.SetResult();
/// <summary>
/// Transforms cancellation into successful result.
/// </summary>
/// <param name="result">The result setter.</param>
protected override sealed void OnCanceled( ref CompletionSource.OnCanceled result ) => result.SetResult();
/// <summary>
/// Returns <see cref="DeviceCommandStoppedBehavior.RunAnyway"/>: the device can obviously be destroyed while stopped.
/// Note that this is not used: basic commands are always run by design.
/// </summary>
protected internal override sealed DeviceCommandStoppedBehavior StoppedBehavior => DeviceCommandStoppedBehavior.RunAnyway;
/// <summary>
/// Returns <see cref="DeviceImmediateCommandStoppedBehavior.RunAnyway"/>: the device can obviously be destroyed while stopped.
/// Note that this is not used: basic commands are always run by design.
/// </summary>
protected internal override sealed DeviceImmediateCommandStoppedBehavior ImmediateStoppedBehavior => DeviceImmediateCommandStoppedBehavior.RunAnyway;
}