forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteInstanceJob.cs
More file actions
60 lines (52 loc) · 2.02 KB
/
Copy pathDeleteInstanceJob.cs
File metadata and controls
60 lines (52 loc) · 2.02 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
52
53
54
55
56
57
58
59
60
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using Microsoft.Management.Infrastructure;
using Dbg = System.Management.Automation.Diagnostics;
namespace Microsoft.PowerShell.Cmdletization.Cim
{
/// <summary>
/// Job wrapping invocation of a DeleteInstance intrinsic CIM method
/// </summary>
internal class DeleteInstanceJob : MethodInvocationJobBase<object>
{
private readonly CimInstance _objectToDelete;
internal DeleteInstanceJob(CimJobContext jobContext, bool passThru, CimInstance objectToDelete, MethodInvocationInfo methodInvocationInfo)
: base(
jobContext,
passThru,
objectToDelete.ToString(),
methodInvocationInfo)
{
Dbg.Assert(objectToDelete != null, "Caller should verify objectToDelete != null");
_objectToDelete = objectToDelete;
}
internal override IObservable<object> GetCimOperation()
{
if (!this.ShouldProcess())
{
return null;
}
IObservable<object> observable = this.JobContext.Session.DeleteInstanceAsync(
this.JobContext.Namespace,
_objectToDelete,
this.CreateOperationOptions());
return observable;
}
public override void OnNext(object item)
{
Dbg.Assert(false, "DeleteInstance should not result in ObjectReady callbacks");
}
internal override object PassThruObject
{
get { return _objectToDelete; }
}
internal override CimCustomOptionsDictionary CalculateJobSpecificCustomOptions()
{
return CimCustomOptionsDictionary.MergeOptions(
base.CalculateJobSpecificCustomOptions(),
_objectToDelete);
}
}
}