mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
I (Jason Shirk) ran https://github.com/dotnet/codeformatter with the default rules, basically: codeformatter /nocopyright "/c:DEBUG,UNIX,CORECLR" @files.rsp This caused a few problems building, which were fixed up manually. Notable changes: `this.` is removed unless needed to disambiguate. private instance fields are renamed to have a `_` prefix. private static fields are renamed to have a `s_` prefix. I left some projects alone (like PackageManagement) and also left some generated code alone.
64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
/********************************************************************++
|
|
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);
|
|
}
|
|
}
|
|
}
|