Files
PowerShell/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/InstanceMethodInvocationJob.cs
T
PowerShell Team 403ae3f53f Initial run of code formatter
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.
2016-08-01 15:57:03 -07:00

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);
}
}
}