forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstanceMethodInvocationJob.cs
More file actions
63 lines (54 loc) · 2.23 KB
/
Copy pathInstanceMethodInvocationJob.cs
File metadata and controls
63 lines (54 loc) · 2.23 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
61
62
63
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using Microsoft.Management.Infrastructure;
using Microsoft.Management.Infrastructure.Options;
using Dbg = System.Management.Automation.Diagnostics;
namespace Microsoft.PowerShell.Cmdletization.Cim
{
/// <summary>
/// Job wrapping invocation of an extrinsic CIM method
/// </summary>
internal class InstanceMethodInvocationJob : ExtrinsicMethodInvocationJob
{
private readonly CimInstance _targetInstance;
internal InstanceMethodInvocationJob(CimJobContext jobContext, bool passThru, CimInstance targetInstance, MethodInvocationInfo methodInvocationInfo)
: base(
jobContext,
passThru,
targetInstance.ToString(),
methodInvocationInfo)
{
Dbg.Assert(targetInstance != null, "Caller should verify targetInstance != null");
_targetInstance = targetInstance;
}
internal override IObservable<CimMethodResultBase> GetCimOperation()
{
if (!this.ShouldProcess())
{
return null;
}
CimMethodParametersCollection methodParameters = this.GetCimMethodParametersCollection();
CimOperationOptions operationOptions = this.CreateOperationOptions();
operationOptions.EnableMethodResultStreaming = true;
IObservable<CimMethodResultBase> observable = this.JobContext.Session.InvokeMethodAsync(
this.JobContext.Namespace,
_targetInstance,
this.MethodName,
methodParameters,
operationOptions);
return observable;
}
internal override object PassThruObject
{
get { return _targetInstance; }
}
internal override CimCustomOptionsDictionary CalculateJobSpecificCustomOptions()
{
return CimCustomOptionsDictionary.MergeOptions(
base.CalculateJobSpecificCustomOptions(),
_targetInstance);
}
}
}