forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropertySettingJob.cs
More file actions
46 lines (43 loc) · 1.85 KB
/
Copy pathPropertySettingJob.cs
File metadata and controls
46 lines (43 loc) · 1.85 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
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using Microsoft.Management.Infrastructure;
using Microsoft.PowerShell.Cim;
namespace Microsoft.PowerShell.Cmdletization.Cim
{
/// <summary>
/// Job wrapping invocation of a CreateInstance or ModifyInstance intrinsic CIM method
/// </summary>
internal abstract class PropertySettingJob<T> : MethodInvocationJobBase<T>
{
internal PropertySettingJob(CimJobContext jobContext, bool passThru, CimInstance objectToModify, MethodInvocationInfo methodInvocationInfo)
: base(
jobContext,
passThru,
objectToModify.ToString(),
methodInvocationInfo)
{
}
internal void ModifyLocalCimInstance(CimInstance cimInstance)
{
foreach (MethodParameter methodParameter in this.GetMethodInputParameters())
{
CimValueConverter.AssertIntrinsicCimType(methodParameter.ParameterType);
CimProperty propertyBeingModified = cimInstance.CimInstanceProperties[methodParameter.Name];
if (propertyBeingModified != null)
{
propertyBeingModified.Value = methodParameter.Value;
}
else
{
CimProperty propertyBeingAdded = CimProperty.Create(
methodParameter.Name,
methodParameter.Value,
CimValueConverter.GetCimTypeEnum(methodParameter.ParameterType),
CimFlags.None);
cimInstance.CimInstanceProperties.Add(propertyBeingAdded);
}
}
}
}
}