Fix IDE0032: UseAutoProperty part 2 (#14244)

https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0032
This commit is contained in:
xtqqczze 2020-11-24 10:44:09 +00:00 committed by GitHub
parent e218234116
commit 0e0cd0b6df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 292 additions and 1002 deletions

View file

@ -44,20 +44,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <see cref="CimSession"/>, <see cref="CimOperationOptions"/> object.
/// </para>
/// </summary>
protected XOperationContextBase Context
{
get
{
return this.context;
}
set
{
this.context = value;
}
}
private XOperationContextBase context;
protected XOperationContextBase Context { get; set; }
}
/// <summary>

View file

@ -31,35 +31,19 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="mandatory"></param>
internal ParameterDefinitionEntry(string parameterSetName, bool mandatory)
{
this.mandatory = mandatory;
this.parameterSetName = parameterSetName;
this.IsMandatory = mandatory;
this.ParameterSetName = parameterSetName;
}
/// <summary>
/// Property ParameterSetName.
/// </summary>
internal string ParameterSetName
{
get
{
return this.parameterSetName;
}
}
private readonly string parameterSetName = null;
internal string ParameterSetName { get; } = null;
/// <summary>
/// Whether the parameter is mandatory to the set.
/// </summary>
internal bool IsMandatory
{
get
{
return this.mandatory;
}
}
private readonly bool mandatory = false;
internal bool IsMandatory { get; } = false;
}
/// <summary>
@ -75,8 +59,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="mandatoryParameterCount"></param>
internal ParameterSetEntry(UInt32 mandatoryParameterCount)
{
this.mandatoryParameterCount = mandatoryParameterCount;
this.isDefaultParameterSet = false;
this.MandatoryParameterCount = mandatoryParameterCount;
this.IsDefaultParameterSet = false;
reset();
}
@ -86,8 +70,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="toClone"></param>
internal ParameterSetEntry(ParameterSetEntry toClone)
{
this.mandatoryParameterCount = toClone.MandatoryParameterCount;
this.isDefaultParameterSet = toClone.IsDefaultParameterSet;
this.MandatoryParameterCount = toClone.MandatoryParameterCount;
this.IsDefaultParameterSet = toClone.IsDefaultParameterSet;
reset();
}
@ -98,8 +82,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="mandatory"></param>
internal ParameterSetEntry(UInt32 mandatoryParameterCount, bool isDefault)
{
this.mandatoryParameterCount = mandatoryParameterCount;
this.isDefaultParameterSet = isDefault;
this.MandatoryParameterCount = mandatoryParameterCount;
this.IsDefaultParameterSet = isDefault;
reset();
}
@ -108,107 +92,39 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
internal void reset()
{
this.setMandatoryParameterCount = this.setMandatoryParameterCountAtBeginProcess;
this.isValueSet = this.isValueSetAtBeginProcess;
this.SetMandatoryParameterCount = this.SetMandatoryParameterCountAtBeginProcess;
this.IsValueSet = this.IsValueSetAtBeginProcess;
}
/// <summary>
/// Property <c>DefaultParameterSet</c>
/// </summary>
internal bool IsDefaultParameterSet
{
get
{
return this.isDefaultParameterSet;
}
}
private readonly bool isDefaultParameterSet = false;
internal bool IsDefaultParameterSet { get; } = false;
/// <summary>
/// Property <c>MandatoryParameterCount</c>
/// </summary>
internal UInt32 MandatoryParameterCount
{
get
{
return this.mandatoryParameterCount;
}
}
private readonly UInt32 mandatoryParameterCount = 0;
internal UInt32 MandatoryParameterCount { get; } = 0;
/// <summary>
/// Property <c>IsValueSet</c>
/// </summary>
internal bool IsValueSet
{
get
{
return this.isValueSet;
}
set
{
this.isValueSet = value;
}
}
private bool isValueSet = false;
internal bool IsValueSet { get; set; } = false;
/// <summary>
/// Property <c>IsValueSetAtBeginProcess</c>
/// </summary>
internal bool IsValueSetAtBeginProcess
{
get
{
return this.isValueSetAtBeginProcess;
}
set
{
this.isValueSetAtBeginProcess = value;
}
}
private bool isValueSetAtBeginProcess = false;
internal bool IsValueSetAtBeginProcess { get; set; } = false;
/// <summary>
/// Property <c>SetMandatoryParameterCount</c>
/// </summary>
internal UInt32 SetMandatoryParameterCount
{
get
{
return this.setMandatoryParameterCount;
}
set
{
this.setMandatoryParameterCount = value;
}
}
private UInt32 setMandatoryParameterCount = 0;
internal UInt32 SetMandatoryParameterCount { get; set; } = 0;
/// <summary>
/// Property <c>SetMandatoryParameterCountAtBeginProcess</c>
/// </summary>
internal UInt32 SetMandatoryParameterCountAtBeginProcess
{
get
{
return this.setMandatoryParameterCountAtBeginProcess;
}
set
{
this.setMandatoryParameterCountAtBeginProcess = value;
}
}
private UInt32 setMandatoryParameterCountAtBeginProcess = 0;
internal UInt32 SetMandatoryParameterCountAtBeginProcess { get; set; } = 0;
}
/// <summary>
@ -531,7 +447,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
try
{
this.parameterSetName = this.parameterBinder.GetParameterSet();
this.ParameterSetName = this.parameterBinder.GetParameterSet();
}
finally
{
@ -539,7 +455,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
}
}
DebugHelper.WriteLog("current parameterset is: " + this.parameterSetName, 4);
DebugHelper.WriteLog("current parameterset is: " + this.ParameterSetName, 4);
}
/// <summary>
@ -689,13 +605,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
private readonly object myLock = new();
/// <summary>
/// <para>
/// parameter set name
/// </para>
/// </summary>
private string parameterSetName;
/// <summary>
/// This flag is introduced to resolve the parameter set name
/// during process record
@ -747,13 +656,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Get current ParameterSetName of the cmdlet
/// </para>
/// </summary>
internal string ParameterSetName
{
get
{
return this.parameterSetName;
}
}
internal string ParameterSetName { get; private set; }
/// <summary>
/// Gets/Sets cmdlet operation wrapper object.

View file

@ -30,10 +30,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
string thePropertyName,
string theQualifierName)
{
this.className = theClassName;
this.methodName = theMethodName;
this.propertyName = thePropertyName;
this.qualifierName = theQualifierName;
this.ClassName = theClassName;
this.MethodName = theMethodName;
this.PropertyName = thePropertyName;
this.QualifierName = theQualifierName;
}
/// <summary>
@ -44,14 +44,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Wildcard expansion should be allowed.
/// </para>
/// </summary>
public string ClassName
{
get { return className; }
set { className = value; }
}
private string className;
public string ClassName { get; set; }
/// <summary>
/// <para>
@ -60,12 +53,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Then Filter the <see cref="CimClass"/> by given methodname
/// </para>
/// </summary>
internal string MethodName
{
get { return methodName; }
}
private readonly string methodName;
internal string MethodName { get; }
/// <summary>
/// <para>
@ -74,12 +62,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Filter the <see cref="CimClass"/> by given property name.
/// </para>
/// </summary>
internal string PropertyName
{
get { return propertyName; }
}
private readonly string propertyName;
internal string PropertyName { get; }
/// <summary>
/// <para>
@ -88,12 +71,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Filter the <see cref="CimClass"/> by given methodname
/// </para>
/// </summary>
internal string QualifierName
{
get { return qualifierName; }
}
private readonly string qualifierName;
internal string QualifierName { get; }
}
/// <summary>

View file

@ -45,15 +45,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Returns an exception
/// </para>
/// </summary>
public Exception Exception
{
get
{
return exception;
}
}
private readonly Exception exception;
public Exception Exception { get; }
/// <summary>
/// <para>
@ -64,7 +56,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public CimIndicationEventExceptionEventArgs(Exception theException)
{
context = null;
this.exception = theException;
this.Exception = theException;
}
}

View file

@ -40,36 +40,20 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimSessionProxy theProxy)
{
this.proxy = theProxy;
this.methodName = theMethodName;
this.collection = theCollection;
this.MethodName = theMethodName;
this.ParametersCollection = theCollection;
this.nameSpace = theNamespace;
}
/// <summary>
/// <para>namespace</para>
/// </summary>
internal string MethodName
{
get
{
return this.methodName;
}
}
private readonly string methodName;
internal string MethodName { get; }
/// <summary>
/// <para>parameters collection</para>
/// </summary>
internal CimMethodParametersCollection ParametersCollection
{
get
{
return this.collection;
}
}
private readonly CimMethodParametersCollection collection;
internal CimMethodParametersCollection ParametersCollection { get; }
}
/// <summary>

View file

@ -27,7 +27,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public CimPromptUser(string message,
CimPromptType prompt)
{
this.message = message;
this.Message = message;
this.prompt = prompt;
}
@ -54,7 +54,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
// NOTES: prepare the whatif message and caption
try
{
result = cmdlet.ShouldContinue(message, "caption", ref yestoall, ref notoall);
result = cmdlet.ShouldContinue(Message, "caption", ref yestoall, ref notoall);
if (yestoall)
{
this.responseType = CimResponseType.YesToAll;
@ -87,7 +87,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
case CimPromptType.Normal:
try
{
result = cmdlet.ShouldProcess(message);
result = cmdlet.ShouldProcess(Message);
if (result)
{
this.responseType = CimResponseType.Yes;
@ -121,15 +121,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Prompt message.
/// </summary>
public string Message
{
get
{
return message;
}
}
private readonly string message;
public string Message { get; }
/// <summary>
/// Prompt type -Normal or Critical.

View file

@ -47,15 +47,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// subscription result
/// </para>
/// </summary>
public CimSubscriptionResult Result
{
get
{
return result;
}
}
private readonly CimSubscriptionResult result;
public CimSubscriptionResult Result { get; }
/// <summary>
/// <para>Constructor</para>
@ -65,7 +57,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimSubscriptionResult theResult)
{
this.context = null;
this.result = theResult;
this.Result = theResult;
}
}
@ -81,15 +73,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// subscription result
/// </para>
/// </summary>
public Exception Exception
{
get
{
return exception;
}
}
private readonly Exception exception;
public Exception Exception { get; }
/// <summary>
/// <para>Constructor</para>
@ -99,7 +83,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
Exception theException)
{
this.context = null;
this.exception = theException;
this.Exception = theException;
}
}
@ -219,7 +203,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimWriteError cimWriteError = actionArgs.Action as CimWriteError;
if (cimWriteError != null)
{
this.exception = cimWriteError.Exception;
this.Exception = cimWriteError.Exception;
if (!this.ackedEvent.IsSet)
{
// an exception happened
@ -233,10 +217,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLog("Raise an exception event", 2);
temp(this, new CimSubscriptionExceptionEventArgs(this.exception));
temp(this, new CimSubscriptionExceptionEventArgs(this.Exception));
}
DebugHelper.WriteLog("Got an exception: {0}", 2, exception);
DebugHelper.WriteLog("Got an exception: {0}", 2, Exception);
}
CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject;
@ -276,7 +260,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLogEx();
this.ackedEvent.Wait();
if (this.exception != null)
if (this.Exception != null)
{
DebugHelper.WriteLogEx("error happened", 0);
if (this.Cmdlet != null)
@ -285,14 +269,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
// throw terminating error
ErrorRecord errorRecord = ErrorToErrorRecord.ErrorRecordFromAnyException(
new InvocationContext(this.TargetComputerName, null), this.exception, null);
new InvocationContext(this.TargetComputerName, null), this.Exception, null);
this.Cmdlet.ThrowTerminatingError(errorRecord);
}
else
{
DebugHelper.WriteLogEx("Throw exception", 1);
// throw exception out
throw this.exception;
throw this.Exception;
}
}
@ -363,15 +347,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Exception occurred while start the subscription.
/// </summary>
internal Exception Exception
{
get
{
return exception;
}
}
private Exception exception;
internal Exception Exception { get; private set; }
#endregion

View file

@ -37,21 +37,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="ErrorSource"></param>
internal CimResultContext(object ErrorSource)
{
this.errorSource = ErrorSource;
this.ErrorSource = ErrorSource;
}
/// <summary>
/// ErrorSource property.
/// </summary>
internal object ErrorSource
{
get
{
return this.errorSource;
}
}
private readonly object errorSource;
internal object ErrorSource { get; }
}
#endregion
@ -228,7 +220,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="observable">Operation that can be observed.</param>
public CimResultObserver(CimSession session, IObservable<object> observable)
{
this.session = session;
this.CurrentSession = session;
this.observable = observable;
}
@ -241,7 +233,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
IObservable<object> observable,
CimResultContext cimResultContext)
{
this.session = session;
this.CurrentSession = session;
this.observable = observable;
this.context = cimResultContext;
}
@ -260,7 +252,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
try
{
AsyncResultCompleteEventArgs completeArgs = new(
this.session, this.observable);
this.CurrentSession, this.observable);
this.OnNewResult(this, completeArgs);
}
catch (Exception ex)
@ -281,7 +273,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
try
{
AsyncResultErrorEventArgs errorArgs = new(
this.session, this.observable, error, this.context);
this.CurrentSession, this.observable, error, this.context);
this.OnNewResult(this, errorArgs);
}
catch (Exception ex)
@ -301,7 +293,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
try
{
AsyncResultObjectEventArgs resultArgs = new(
this.session, this.observable, value);
this.CurrentSession, this.observable, value);
this.OnNewResult(this, resultArgs);
}
catch (Exception ex)
@ -334,15 +326,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Session object of the operation.
/// </summary>
protected CimSession CurrentSession
{
get
{
return session;
}
}
private readonly CimSession session;
protected CimSession CurrentSession { get; }
/// <summary>
/// Async operation that can be observed.

View file

@ -24,67 +24,27 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Id of the cimsession.
/// </summary>
public uint SessionId
{
get
{
return this.sessionId;
}
}
private readonly uint sessionId;
public uint SessionId { get; }
/// <summary>
/// InstanceId of the cimsession.
/// </summary>
public Guid InstanceId
{
get
{
return this.instanceId;
}
}
private readonly Guid instanceId;
public Guid InstanceId { get; }
/// <summary>
/// Name of the cimsession.
/// </summary>
public string Name
{
get
{
return this.name;
}
}
private readonly string name;
public string Name { get; }
/// <summary>
/// Computer name of the cimsession.
/// </summary>
public string ComputerName
{
get
{
return this.computerName;
}
}
private readonly string computerName;
public string ComputerName { get; }
/// <summary>
/// Wrapped cimsession object.
/// </summary>
public CimSession CimSession
{
get
{
return this.cimSession;
}
}
private readonly CimSession cimSession;
public CimSession CimSession { get; }
/// <summary>
/// Computer name of the cimsession.
@ -127,11 +87,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimSession theCimSession,
ProtocolType theProtocol)
{
this.sessionId = theSessionId;
this.instanceId = theInstanceId;
this.name = theName;
this.computerName = theComputerName;
this.cimSession = theCimSession;
this.SessionId = theSessionId;
this.InstanceId = theInstanceId;
this.Name = theName;
this.ComputerName = theComputerName;
this.CimSession = theCimSession;
this.psObject = null;
this.protocol = theProtocol;
}
@ -140,18 +100,18 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
if (psObject == null)
{
psObject = new PSObject(this.cimSession);
psObject.Properties.Add(new PSNoteProperty(CimSessionState.idPropName, this.sessionId));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.namePropName, this.name));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.instanceidPropName, this.instanceId));
psObject = new PSObject(this.CimSession);
psObject.Properties.Add(new PSNoteProperty(CimSessionState.idPropName, this.SessionId));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.namePropName, this.Name));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.instanceidPropName, this.InstanceId));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.computernamePropName, this.ComputerName));
psObject.Properties.Add(new PSNoteProperty(CimSessionState.protocolPropName, this.Protocol));
}
else
{
psObject.Properties[CimSessionState.idPropName].Value = this.SessionId;
psObject.Properties[CimSessionState.namePropName].Value = this.name;
psObject.Properties[CimSessionState.instanceidPropName].Value = this.instanceId;
psObject.Properties[CimSessionState.namePropName].Value = this.Name;
psObject.Properties[CimSessionState.instanceidPropName].Value = this.InstanceId;
psObject.Properties[CimSessionState.computernamePropName].Value = this.ComputerName;
psObject.Properties[CimSessionState.protocolPropName].Value = this.Protocol;
}
@ -919,22 +879,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimSessionWrapper wrapper)
{
this.proxy = theProxy;
this.cimSessionWrapper = wrapper;
this.CimSessionWrapper = wrapper;
this.nameSpace = null;
}
/// <summary>
/// <para>Namespace</para>
/// </summary>
internal CimSessionWrapper CimSessionWrapper
{
get
{
return this.cimSessionWrapper;
}
}
private readonly CimSessionWrapper cimSessionWrapper;
internal CimSessionWrapper CimSessionWrapper { get; }
}
/// <summary>
@ -945,7 +897,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
internal CimNewSession() : base()
{
this.cimTestSession = new CimTestSession();
this._disposed = false;
this.Disposed = false;
}
/// <summary>
@ -1062,15 +1014,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Indicates whether this object was disposed or not.
/// </para>
/// </summary>
protected bool Disposed
{
get
{
return _disposed;
}
}
private bool _disposed;
protected bool Disposed { get; private set; }
/// <summary>
/// <para>
@ -1104,13 +1048,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="disposing">Whether it is directly called.</param>
protected virtual void Dispose(bool disposing)
{
if (!this._disposed)
if (!this.Disposed)
{
if (disposing)
{
// free managed resources
this.cimTestSession.Dispose();
this._disposed = true;
this.Disposed = true;
}
// free native resources if there are any
}

View file

@ -325,7 +325,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
DebugHelper.WriteLogEx("protocol = {0}", 1, proxy.Protocol);
CreateSetSession(null, proxy.CimSession, null, proxy.OperationOptions, proxy.IsTemporaryCimSession);
this.protocol = proxy.Protocol;
this.Protocol = proxy.Protocol;
this.OperationTimeout = proxy.OperationTimeout;
this.isDefaultSession = proxy.isDefaultSession;
}
@ -463,19 +463,19 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
}
InitOption(operOptions);
this.protocol = ProtocolType.Wsman;
this.isTemporaryCimSession = temporaryCimSession;
this.Protocol = ProtocolType.Wsman;
this.IsTemporaryCimSession = temporaryCimSession;
if (cimSession != null)
{
this.session = cimSession;
this.CimSession = cimSession;
CimSessionState state = CimSessionBase.GetCimSessionState();
if (state != null)
{
CimSessionWrapper wrapper = state.QuerySession(cimSession);
if (wrapper != null)
{
this.protocol = wrapper.GetProtocolType();
this.Protocol = wrapper.GetProtocolType();
}
}
}
@ -486,29 +486,29 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
if (sessionOptions is DComSessionOptions)
{
string defaultComputerName = ConstValue.IsDefaultComputerName(computerName) ? ConstValue.NullComputerName : computerName;
this.session = CimSession.Create(defaultComputerName, sessionOptions);
this.protocol = ProtocolType.Dcom;
this.CimSession = CimSession.Create(defaultComputerName, sessionOptions);
this.Protocol = ProtocolType.Dcom;
}
else
{
this.session = CimSession.Create(computerName, sessionOptions);
this.CimSession = CimSession.Create(computerName, sessionOptions);
}
}
else
{
this.session = CreateCimSessionByComputerName(computerName);
this.CimSession = CreateCimSessionByComputerName(computerName);
}
this.isTemporaryCimSession = true;
this.IsTemporaryCimSession = true;
}
if (this.isTemporaryCimSession)
if (this.IsTemporaryCimSession)
{
AddCimSessionToTemporaryCache(this.session);
AddCimSessionToTemporaryCache(this.CimSession);
}
this.invocationContextObject = new InvocationContext(this);
DebugHelper.WriteLog("Protocol {0}, Is temporary session ? {1}", 1, this.protocol, this.isTemporaryCimSession);
DebugHelper.WriteLog("Protocol {0}, Is temporary session ? {1}", 1, this.Protocol, this.IsTemporaryCimSession);
}
#endregion
@ -522,14 +522,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
get
{
return (UInt32)this.options.Timeout.TotalSeconds;
return (UInt32)this.OperationOptions.Timeout.TotalSeconds;
}
set
{
DebugHelper.WriteLogEx("OperationTimeout {0},", 0, value);
this.options.Timeout = TimeSpan.FromSeconds((double)value);
this.OperationOptions.Timeout = TimeSpan.FromSeconds((double)value);
}
}
@ -540,14 +540,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
get
{
return this.options.ResourceUri;
return this.OperationOptions.ResourceUri;
}
set
{
DebugHelper.WriteLogEx("ResourceUri {0},", 0, value);
this.options.ResourceUri = value;
this.OperationOptions.ResourceUri = value;
}
}
@ -559,13 +559,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
get
{
return this.options.EnableMethodResultStreaming;
return this.OperationOptions.EnableMethodResultStreaming;
}
set
{
DebugHelper.WriteLogEx("EnableMethodResultStreaming {0}", 0, value);
this.options.EnableMethodResultStreaming = value;
this.OperationOptions.EnableMethodResultStreaming = value;
}
}
@ -580,7 +580,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
DebugHelper.WriteLogEx("EnablePromptUser {0}", 0, value);
if (value)
{
this.options.PromptUser = this.PromptUser;
this.OperationOptions.PromptUser = this.PromptUser;
}
}
}
@ -594,15 +594,15 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
// this.options.PromptUserForceFlag...
// this.options.WriteErrorMode
this.options.WriteErrorMode = CimCallbackMode.Inquire;
this.OperationOptions.WriteErrorMode = CimCallbackMode.Inquire;
// !!!NOTES: Does not subscribe to PromptUser for CimCmdlets now
// since cmdlet does not provider an approach
// to let user select how to handle prompt message
// this can be enabled later if needed.
this.options.WriteError = this.WriteError;
this.options.WriteMessage = this.WriteMessage;
this.options.WriteProgress = this.WriteProgress;
this.OperationOptions.WriteError = this.WriteError;
this.OperationOptions.WriteMessage = this.WriteMessage;
this.OperationOptions.WriteProgress = this.WriteProgress;
}
/// <summary>
@ -610,7 +610,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
public SwitchParameter KeyOnly
{
set { this.options.KeysOnly = value.IsPresent; }
set { this.OperationOptions.KeysOnly = value.IsPresent; }
}
/// <summary>
@ -622,11 +622,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
if (value.IsPresent)
{
this.options.Flags = CimOperationFlags.PolymorphismShallow;
this.OperationOptions.Flags = CimOperationFlags.PolymorphismShallow;
}
else
{
this.options.Flags = CimOperationFlags.None;
this.OperationOptions.Flags = CimOperationFlags.None;
}
}
}
@ -640,11 +640,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
if (operOptions != null)
{
this.options = new CimOperationOptions(operOptions);
this.OperationOptions = new CimOperationOptions(operOptions);
}
else if (this.options == null)
else if (this.OperationOptions == null)
{
this.options = new CimOperationOptions();
this.OperationOptions = new CimOperationOptions();
}
this.EnableMethodResultStreaming = true;
@ -665,10 +665,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
DebugHelper.WriteLogEx();
// Remove the CimSession from cache but don't dispose it
RemoveCimSessionFromTemporaryCache(this.session, false);
CimSession sessionToReturn = this.session;
this.session = null;
this.isTemporaryCimSession = false;
RemoveCimSessionFromTemporaryCache(this.CimSession, false);
CimSession sessionToReturn = this.CimSession;
this.CimSession = null;
this.IsTemporaryCimSession = false;
return sessionToReturn;
}
@ -707,7 +707,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
this.operation = null;
}
if (this.session != null && this.ContextObject == null)
if (this.CimSession != null && this.ContextObject == null)
{
DebugHelper.WriteLog("Dispose this proxy object @ RemoveOperation");
this.Dispose();
@ -734,7 +734,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
EventHandler<CmdletActionEventArgs> temp = this.OnNewCmdletAction;
if (temp != null)
{
temp(this.session, actionArgs);
temp(this.CimSession, actionArgs);
}
else
{
@ -759,7 +759,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
OperationEventArgs args = new(
cancelOperation, operation, false);
this.OnOperationCreated?.Invoke(this.session, args);
this.OnOperationCreated?.Invoke(this.CimSession, args);
this.PostOperationCreateEvent(args);
}
@ -779,7 +779,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
OperationEventArgs args = new(
null, operation, success);
PreOperationDeleteEvent(args);
this.OnOperationDeleted?.Invoke(this.session, args);
this.OnOperationDeleted?.Invoke(this.CimSession, args);
this.PostOperationDeleteEvent(args);
this.RemoveOperation(operation);
@ -1065,15 +1065,15 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public void CreateInstanceAsync(string namespaceName, CimInstance instance)
{
Debug.Assert(instance != null, "Caller should verify that instance != NULL.");
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.options.EnableMethodResultStreaming);
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.OperationOptions.EnableMethodResultStreaming);
this.CheckAvailability();
this.targetCimInstance = instance;
this.TargetCimInstance = instance;
this.operationName = CimCmdletStrings.CimOperationNameCreateInstance;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"instance", instance);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncResult<CimInstance> asyncResult = this.session.CreateInstanceAsync(namespaceName, instance, this.options);
CimAsyncResult<CimInstance> asyncResult = this.CimSession.CreateInstanceAsync(namespaceName, instance, this.OperationOptions);
ConsumeCimInstanceAsync(asyncResult, new CimResultContext(instance));
}
@ -1087,13 +1087,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
Debug.Assert(instance != null, "Caller should verify that instance != NULL.");
DebugHelper.WriteLogEx("namespace = {0}; classname = {1};", 0, namespaceName, instance.CimSystemProperties.ClassName);
this.CheckAvailability();
this.targetCimInstance = instance;
this.TargetCimInstance = instance;
this.operationName = CimCmdletStrings.CimOperationNameDeleteInstance;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"instance", instance);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncStatus asyncResult = this.session.DeleteInstanceAsync(namespaceName, instance, this.options);
CimAsyncStatus asyncResult = this.CimSession.DeleteInstanceAsync(namespaceName, instance, this.OperationOptions);
ConsumeObjectAsync(asyncResult, new CimResultContext(instance));
}
@ -1105,15 +1105,15 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public void GetInstanceAsync(string namespaceName, CimInstance instance)
{
Debug.Assert(instance != null, "Caller should verify that instance != NULL.");
DebugHelper.WriteLogEx("namespace = {0}; classname = {1}; keyonly = {2}", 0, namespaceName, instance.CimSystemProperties.ClassName, this.options.KeysOnly);
DebugHelper.WriteLogEx("namespace = {0}; classname = {1}; keyonly = {2}", 0, namespaceName, instance.CimSystemProperties.ClassName, this.OperationOptions.KeysOnly);
this.CheckAvailability();
this.targetCimInstance = instance;
this.TargetCimInstance = instance;
this.operationName = CimCmdletStrings.CimOperationNameGetInstance;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"instance", instance);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncResult<CimInstance> asyncResult = this.session.GetInstanceAsync(namespaceName, instance, this.options);
CimAsyncResult<CimInstance> asyncResult = this.CimSession.GetInstanceAsync(namespaceName, instance, this.OperationOptions);
ConsumeCimInstanceAsync(asyncResult, new CimResultContext(instance));
}
@ -1127,13 +1127,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
Debug.Assert(instance != null, "Caller should verify that instance != NULL.");
DebugHelper.WriteLogEx("namespace = {0}; classname = {1}", 0, namespaceName, instance.CimSystemProperties.ClassName);
this.CheckAvailability();
this.targetCimInstance = instance;
this.TargetCimInstance = instance;
this.operationName = CimCmdletStrings.CimOperationNameModifyInstance;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"instance", instance);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncResult<CimInstance> asyncResult = this.session.ModifyInstanceAsync(namespaceName, instance, this.options);
CimAsyncResult<CimInstance> asyncResult = this.CimSession.ModifyInstanceAsync(namespaceName, instance, this.OperationOptions);
ConsumeObjectAsync(asyncResult, new CimResultContext(instance));
}
@ -1158,7 +1158,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
Debug.Assert(sourceInstance != null, "Caller should verify that sourceInstance != NULL.");
DebugHelper.WriteLogEx("Instance class {0}, association class {1}", 0, sourceInstance.CimSystemProperties.ClassName, associationClassName);
this.CheckAvailability();
this.targetCimInstance = sourceInstance;
this.TargetCimInstance = sourceInstance;
this.operationName = CimCmdletStrings.CimOperationNameEnumerateAssociatedInstances;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
@ -1168,7 +1168,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
this.operationParameters.Add(@"sourceRole", sourceRole);
this.operationParameters.Add(@"resultRole", resultRole);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimInstance> asyncResult = this.session.EnumerateAssociatedInstancesAsync(namespaceName, sourceInstance, associationClassName, resultClassName, sourceRole, resultRole, this.options);
CimAsyncMultipleResults<CimInstance> asyncResult = this.CimSession.EnumerateAssociatedInstancesAsync(namespaceName, sourceInstance, associationClassName, resultClassName, sourceRole, resultRole, this.OperationOptions);
ConsumeCimInstanceAsync(asyncResult, new CimResultContext(sourceInstance));
}
@ -1179,15 +1179,15 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="className"></param>
public void EnumerateInstancesAsync(string namespaceName, string className)
{
DebugHelper.WriteLogEx("KeyOnly {0}", 0, this.options.KeysOnly);
DebugHelper.WriteLogEx("KeyOnly {0}", 0, this.OperationOptions.KeysOnly);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameEnumerateInstances;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"className", className);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimInstance> asyncResult = this.session.EnumerateInstancesAsync(namespaceName, className, this.options);
CimAsyncMultipleResults<CimInstance> asyncResult = this.CimSession.EnumerateInstancesAsync(namespaceName, className, this.OperationOptions);
string errorSource = string.Format(CultureInfo.CurrentUICulture, "{0}:{1}", namespaceName, className);
ConsumeCimInstanceAsync(asyncResult, new CimResultContext(errorSource));
}
@ -1224,16 +1224,16 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
string queryDialect,
string queryExpression)
{
DebugHelper.WriteLogEx("KeyOnly = {0}", 0, this.options.KeysOnly);
DebugHelper.WriteLogEx("KeyOnly = {0}", 0, this.OperationOptions.KeysOnly);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameQueryInstances;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"queryDialect", queryDialect);
this.operationParameters.Add(@"queryExpression", queryExpression);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimInstance> asyncResult = this.session.QueryInstancesAsync(namespaceName, queryDialect, queryExpression, this.options);
CimAsyncMultipleResults<CimInstance> asyncResult = this.CimSession.QueryInstancesAsync(namespaceName, queryDialect, queryExpression, this.OperationOptions);
ConsumeCimInstanceAsync(asyncResult, null);
}
@ -1246,12 +1246,12 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLogEx("namespace {0}", 0, namespaceName);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameEnumerateClasses;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimClass> asyncResult = this.session.EnumerateClassesAsync(namespaceName, null, this.options);
CimAsyncMultipleResults<CimClass> asyncResult = this.CimSession.EnumerateClassesAsync(namespaceName, null, this.OperationOptions);
ConsumeCimClassAsync(asyncResult, null);
}
@ -1263,13 +1263,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public void EnumerateClassesAsync(string namespaceName, string className)
{
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameEnumerateClasses;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"className", className);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimClass> asyncResult = this.session.EnumerateClassesAsync(namespaceName, className, this.options);
CimAsyncMultipleResults<CimClass> asyncResult = this.CimSession.EnumerateClassesAsync(namespaceName, className, this.OperationOptions);
string errorSource = string.Format(CultureInfo.CurrentUICulture, "{0}:{1}", namespaceName, className);
ConsumeCimClassAsync(asyncResult, new CimResultContext(errorSource));
}
@ -1283,13 +1283,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLogEx("namespace = {0}, className = {1}", 0, namespaceName, className);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameGetClass;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"className", className);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncResult<CimClass> asyncResult = this.session.GetClassAsync(namespaceName, className, this.options);
CimAsyncResult<CimClass> asyncResult = this.CimSession.GetClassAsync(namespaceName, className, this.OperationOptions);
string errorSource = string.Format(CultureInfo.CurrentUICulture, "{0}:{1}", namespaceName, className);
ConsumeCimClassAsync(asyncResult, new CimResultContext(errorSource));
}
@ -1308,16 +1308,16 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimMethodParametersCollection methodParameters)
{
Debug.Assert(instance != null, "Caller should verify that instance != NULL.");
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.options.EnableMethodResultStreaming);
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.OperationOptions.EnableMethodResultStreaming);
this.CheckAvailability();
this.targetCimInstance = instance;
this.TargetCimInstance = instance;
this.operationName = CimCmdletStrings.CimOperationNameInvokeMethod;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"instance", instance);
this.operationParameters.Add(@"methodName", methodName);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimMethodResultBase> asyncResult = this.session.InvokeMethodAsync(namespaceName, instance, methodName, methodParameters, this.options);
CimAsyncMultipleResults<CimMethodResultBase> asyncResult = this.CimSession.InvokeMethodAsync(namespaceName, instance, methodName, methodParameters, this.OperationOptions);
ConsumeCimInvokeMethodResultAsync(asyncResult, instance.CimSystemProperties.ClassName, methodName, new CimResultContext(instance));
}
@ -1334,16 +1334,16 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
string methodName,
CimMethodParametersCollection methodParameters)
{
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.options.EnableMethodResultStreaming);
DebugHelper.WriteLogEx("EnableMethodResultStreaming = {0}", 0, this.OperationOptions.EnableMethodResultStreaming);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameInvokeMethod;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
this.operationParameters.Add(@"className", className);
this.operationParameters.Add(@"methodName", methodName);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
CimAsyncMultipleResults<CimMethodResultBase> asyncResult = this.session.InvokeMethodAsync(namespaceName, className, methodName, methodParameters, this.options);
CimAsyncMultipleResults<CimMethodResultBase> asyncResult = this.CimSession.InvokeMethodAsync(namespaceName, className, methodName, methodParameters, this.OperationOptions);
string errorSource = string.Format(CultureInfo.CurrentUICulture, "{0}:{1}", namespaceName, className);
ConsumeCimInvokeMethodResultAsync(asyncResult, className, methodName, new CimResultContext(errorSource));
}
@ -1363,7 +1363,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLogEx("QueryDialect = '{0}'; queryExpression = '{1}'", 0, queryDialect, queryExpression);
this.CheckAvailability();
this.targetCimInstance = null;
this.TargetCimInstance = null;
this.operationName = CimCmdletStrings.CimOperationNameSubscribeIndication;
this.operationParameters.Clear();
this.operationParameters.Add(@"namespaceName", namespaceName);
@ -1371,8 +1371,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
this.operationParameters.Add(@"queryExpression", queryExpression);
this.WriteOperationStartMessage(this.operationName, this.operationParameters);
this.options.Flags |= CimOperationFlags.ReportOperationStarted;
CimAsyncMultipleResults<CimSubscriptionResult> asyncResult = this.session.SubscribeAsync(namespaceName, queryDialect, queryExpression, this.options);
this.OperationOptions.Flags |= CimOperationFlags.ReportOperationStarted;
CimAsyncMultipleResults<CimSubscriptionResult> asyncResult = this.CimSession.SubscribeAsync(namespaceName, queryDialect, queryExpression, this.OperationOptions);
ConsumeCimSubscriptionResultAsync(asyncResult, null);
}
@ -1385,8 +1385,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
DebugHelper.WriteLogEx("Start test connection", 0);
this.CheckAvailability();
this.targetCimInstance = null;
CimAsyncResult<CimInstance> asyncResult = this.session.TestConnectionAsync();
this.TargetCimInstance = null;
CimAsyncResult<CimInstance> asyncResult = this.CimSession.TestConnectionAsync();
// ignore the test connection result objects
ConsumeCimInstanceAsync(asyncResult, true, null);
}
@ -1451,42 +1451,15 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// The session will be closed while disposing this proxy object
/// if it is created by constuctor.
/// </summary>
internal CimSession CimSession
{
get
{
return this.session;
}
}
private CimSession session;
internal CimSession CimSession { get; private set; }
/// <summary>
/// The current CimInstance object, against which issued
/// current operation, it could be null.
/// </summary>
internal CimInstance TargetCimInstance
{
get
{
return this.targetCimInstance;
}
}
internal CimInstance TargetCimInstance { get; private set; } = null;
private CimInstance targetCimInstance = null;
/// <summary>
/// Flag controls whether session object should be closed or not.
/// </summary>
private bool isTemporaryCimSession;
internal bool IsTemporaryCimSession
{
get
{
return isTemporaryCimSession;
}
}
internal bool IsTemporaryCimSession { get; private set; }
/// <summary>
/// The CimOperationOptions object, which specifies the options
@ -1496,15 +1469,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// The setting MUST be set before start new operation on the
/// this proxy object.
/// </summary>
internal CimOperationOptions OperationOptions
{
get
{
return this.options;
}
}
private CimOperationOptions options;
internal CimOperationOptions OperationOptions { get; private set; }
/// <summary>
/// All operations completed.
@ -1584,33 +1549,12 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Current protocol name
/// DCOM or WSMAN.
/// </summary>
internal ProtocolType Protocol
{
get
{
return protocol;
}
}
private ProtocolType protocol;
internal ProtocolType Protocol { get; private set; }
/// <summary>
/// Cross operation context object.
/// </summary>
internal XOperationContextBase ContextObject
{
get
{
return this.contextObject;
}
set
{
this.contextObject = value;
}
}
private XOperationContextBase contextObject;
internal XOperationContextBase ContextObject { get; set; }
/// <summary>
/// Invocation context object.
@ -1621,20 +1565,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// A preprocess object to pre-processing the result object,
/// for example, adding PSTypeName, etc.
/// </summary>
internal IObjectPreProcess ObjectPreProcess
{
get
{
return this.objectPreprocess;
}
set
{
this.objectPreprocess = value;
}
}
private IObjectPreProcess objectPreprocess;
internal IObjectPreProcess ObjectPreProcess { get; set; }
/// <summary>
/// <see cref="isDefaultSession"/> is <see langword="true"/> if this <see cref="CimSessionProxy"/> was
@ -1684,10 +1615,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
// Dispose managed resources.
this.DisposeCancelOperation();
if (this.options != null)
if (this.OperationOptions != null)
{
this.options.Dispose();
this.options = null;
this.OperationOptions.Dispose();
this.OperationOptions = null;
}
DisposeTemporaryCimSession();
@ -1710,12 +1641,12 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
private void DisposeTemporaryCimSession()
{
if (this.isTemporaryCimSession && this.session != null)
if (this.IsTemporaryCimSession && this.CimSession != null)
{
// remove the cimsession from temporary cache
RemoveCimSessionFromTemporaryCache(this.session);
this.isTemporaryCimSession = false;
this.session = null;
RemoveCimSessionFromTemporaryCache(this.CimSession);
this.IsTemporaryCimSession = false;
this.CimSession = null;
}
}
#endregion
@ -1751,11 +1682,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimResultObserver<CimInstance> observer;
if (ignoreResultObjects)
{
observer = new IgnoreResultObserver(this.session, asyncResult);
observer = new IgnoreResultObserver(this.CimSession, asyncResult);
}
else
{
observer = new CimResultObserver<CimInstance>(this.session, asyncResult, cimResultContext);
observer = new CimResultObserver<CimInstance>(this.CimSession, asyncResult, cimResultContext);
}
observer.OnNewResult += this.ResultEventHandler;
@ -1776,7 +1707,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimResultContext cimResultContext)
{
CimResultObserver<object> observer = new(
this.session, asyncResult, cimResultContext);
this.CimSession, asyncResult, cimResultContext);
observer.OnNewResult += this.ResultEventHandler;
this.operationID = Interlocked.Increment(ref gOperationCounter);
@ -1797,7 +1728,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimResultContext cimResultContext)
{
CimResultObserver<CimClass> observer = new(
this.session, asyncResult, cimResultContext);
this.CimSession, asyncResult, cimResultContext);
observer.OnNewResult += this.ResultEventHandler;
this.operationID = Interlocked.Increment(ref gOperationCounter);
@ -1818,7 +1749,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
CimResultContext cimResultContext)
{
CimSubscriptionResultObserver observer = new(
this.session, asyncResult, cimResultContext);
this.CimSession, asyncResult, cimResultContext);
observer.OnNewResult += this.ResultEventHandler;
this.operationID = Interlocked.Increment(ref gOperationCounter);
this.AddOperation(asyncResult);
@ -1841,7 +1772,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
string methodName,
CimResultContext cimResultContext)
{
CimMethodResultObserver observer = new(this.session, asyncResult, cimResultContext)
CimMethodResultObserver observer = new(this.CimSession, asyncResult, cimResultContext)
{
ClassName = className,
MethodName = methodName
@ -1872,7 +1803,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
}
}
DebugHelper.WriteLog("KeyOnly {0},", 1, this.options.KeysOnly);
DebugHelper.WriteLog("KeyOnly {0},", 1, this.OperationOptions.KeysOnly);
}
/// <summary>
@ -1882,9 +1813,9 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
private void AssertSession()
{
if (this.IsDisposed || (this.session == null))
if (this.IsDisposed || (this.CimSession == null))
{
DebugHelper.WriteLogEx("Invalid CimSessionProxy object, disposed? {0}; session object {1}", 1, this.IsDisposed, this.session);
DebugHelper.WriteLogEx("Invalid CimSessionProxy object, disposed? {0}; session object {1}", 1, this.IsDisposed, this.CimSession);
throw new ObjectDisposedException(this.ToString());
}
}
@ -1903,7 +1834,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
if (option is DComSessionOptions)
{
DebugHelper.WriteLog("Create dcom cimSession");
this.protocol = ProtocolType.Dcom;
this.Protocol = ProtocolType.Dcom;
return CimSession.Create(ConstValue.NullComputerName, option);
}
else
@ -2176,7 +2107,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public CimSessionProxyNewCimInstance(string computerName, CimNewCimInstance operation)
: base(computerName)
{
this.newCimInstance = operation;
this.NewCimInstanceOperation = operation;
}
/// <summary>
@ -2189,7 +2120,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public CimSessionProxyNewCimInstance(CimSession session, CimNewCimInstance operation)
: base(session)
{
this.newCimInstance = operation;
this.NewCimInstanceOperation = operation;
}
#endregion
@ -2223,15 +2154,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#region private members
private readonly CimNewCimInstance newCimInstance = null;
internal CimNewCimInstance NewCimInstanceOperation
{
get
{
return this.newCimInstance;
}
}
internal CimNewCimInstance NewCimInstanceOperation { get; } = null;
#endregion
}

View file

@ -33,50 +33,26 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
bool passThru)
{
this.proxy = theProxy;
this.property = theProperty;
this.Property = theProperty;
this.nameSpace = theNamespace;
this.parameterSetName = theParameterSetName;
this.passThru = passThru;
this.ParameterSetName = theParameterSetName;
this.PassThru = passThru;
}
/// <summary>
/// <para>property value</para>
/// </summary>
internal IDictionary Property
{
get
{
return this.property;
}
}
private readonly IDictionary property;
internal IDictionary Property { get; }
/// <summary>
/// <para>parameter set name</para>
/// </summary>
internal string ParameterSetName
{
get
{
return this.parameterSetName;
}
}
private readonly string parameterSetName;
internal string ParameterSetName { get; }
/// <summary>
/// <para>PassThru value</para>
/// </summary>
internal bool PassThru
{
get
{
return this.passThru;
}
}
private readonly bool passThru;
internal bool PassThru { get; }
}
/// <summary>

View file

@ -322,8 +322,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="error"></param>
public CimWriteError(CimInstance error, InvocationContext context)
{
this.error = error;
this.invocationContext = context;
this.Error = error;
this.CimInvocationContext = context;
}
/// <summary>
@ -332,9 +332,9 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <param name="exception"></param>
public CimWriteError(Exception exception, InvocationContext context, CimResultContext cimResultContext)
{
this.exception = exception;
this.invocationContext = context;
this.cimResultContext = cimResultContext;
this.Exception = exception;
this.CimInvocationContext = context;
this.ResultContext = cimResultContext;
}
/// <summary>
@ -348,10 +348,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
Debug.Assert(cmdlet != null, "Caller should verify that cmdlet != null");
try
{
Exception errorException = (error != null) ? new CimException(error) : this.Exception;
Exception errorException = (Error != null) ? new CimException(Error) : this.Exception;
// PS engine takes care of handling error action
cmdlet.WriteError(ErrorToErrorRecord.ErrorRecordFromAnyException(this.invocationContext, errorException, this.cimResultContext));
cmdlet.WriteError(ErrorToErrorRecord.ErrorRecordFromAnyException(this.CimInvocationContext, errorException, this.ResultContext));
// if user wants to continue, we will get here
this.responseType = CimResponseType.Yes;
@ -375,59 +375,19 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Error instance
/// </para>
/// </summary>
private readonly CimInstance error;
internal CimInstance Error
{
get
{
return error;
}
}
internal CimInstance Error { get; }
/// <summary>
/// <para>
/// Exception object
/// </para>
/// </summary>
internal Exception Exception
{
get
{
return exception;
}
}
internal Exception Exception { get; }
private readonly Exception exception;
internal InvocationContext CimInvocationContext { get; }
/// <summary>
/// <para>
/// <see cref="InvocationContext"/> object that contains
/// the information while issuing the current operation
/// </para>
/// </summary>
private readonly InvocationContext invocationContext;
internal InvocationContext CimInvocationContext
{
get
{
return invocationContext;
}
}
/// <summary>
/// <see cref="CimResultConte"/>
/// </summary>
private readonly CimResultContext cimResultContext;
internal CimResultContext ResultContext
{
get
{
return cimResultContext;
}
}
internal CimResultContext ResultContext { get; }
#endregion
}

View file

@ -22,25 +22,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Channel id.
/// </summary>
private readonly UInt32 channel;
/// <summary>
/// Message to write to the channel.
/// </summary>
private readonly string message;
#endregion
#region Properties
internal UInt32 Channel
{
get { return channel; }
}
internal UInt32 Channel { get; }
internal string Message
{
get { return message; }
}
internal string Message { get; }
#endregion
@ -50,8 +38,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public CimWriteMessage(UInt32 channel,
string message)
{
this.channel = channel;
this.message = message;
this.Channel = channel;
this.Message = message;
}
/// <summary>
@ -64,16 +52,16 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{
ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
switch ((CimWriteMessageChannel)channel)
switch ((CimWriteMessageChannel)Channel)
{
case CimWriteMessageChannel.Verbose:
cmdlet.WriteVerbose(message);
cmdlet.WriteVerbose(Message);
break;
case CimWriteMessageChannel.Warning:
cmdlet.WriteWarning(message);
cmdlet.WriteWarning(Message);
break;
case CimWriteMessageChannel.Debug:
cmdlet.WriteDebug(message);
cmdlet.WriteDebug(Message);
break;
default:
break;

View file

@ -43,20 +43,20 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
UInt32 thePercentageCompleted,
UInt32 theSecondsRemaining)
{
this.activity = theActivity;
this.activityID = theActivityID;
this.currentOperation = theCurrentOperation;
this.Activity = theActivity;
this.ActivityID = theActivityID;
this.CurrentOperation = theCurrentOperation;
if (string.IsNullOrEmpty(theStatusDescription))
{
this.statusDescription = CimCmdletStrings.DefaultStatusDescription;
this.StatusDescription = CimCmdletStrings.DefaultStatusDescription;
}
else
{
this.statusDescription = theStatusDescription;
this.StatusDescription = theStatusDescription;
}
this.percentageCompleted = thePercentageCompleted;
this.secondsRemaining = theSecondsRemaining;
this.PercentageCompleted = thePercentageCompleted;
this.SecondsRemaining = theSecondsRemaining;
}
/// <summary>
@ -70,84 +70,54 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
DebugHelper.WriteLog(
"...Activity {0}: id={1}, remain seconds ={2}, percentage completed = {3}",
4,
this.activity,
this.activityID,
this.secondsRemaining,
this.percentageCompleted);
this.Activity,
this.ActivityID,
this.SecondsRemaining,
this.PercentageCompleted);
ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
ProgressRecord record = new(
this.activityID,
this.activity,
this.statusDescription);
record.Activity = this.activity;
this.ActivityID,
this.Activity,
this.StatusDescription);
record.Activity = this.Activity;
record.ParentActivityId = 0;
record.SecondsRemaining = (int)this.secondsRemaining;
record.PercentComplete = (int)this.percentageCompleted;
record.SecondsRemaining = (int)this.SecondsRemaining;
record.PercentComplete = (int)this.PercentageCompleted;
cmdlet.WriteProgress(record);
}
#region members
/// <summary>
/// Activity of the given activity.
/// Gets the activity of the given activity.
/// </summary>
private readonly string activity;
internal string Activity { get; }
/// <summary>
/// Activity identifier of the given activity.
/// Gets the activity identifier of the given activity.
/// </summary>
private readonly int activityID;
internal int ActivityID { get; }
/// <summary>
/// Current operation text of the given activity.
/// Gets the current operation text of the given activity.
/// </summary>
private readonly string currentOperation;
internal string CurrentOperation { get; }
/// <summary>
/// Status description of the given activity.
/// Gets the status description of the given activity.
/// </summary>
private readonly string statusDescription;
internal string StatusDescription { get; }
/// <summary>
/// Percentage completed of the given activity.
/// Gets the percentage completed of the given activity.
/// </summary>
private readonly UInt32 percentageCompleted;
internal UInt32 PercentageCompleted { get; }
/// <summary>
/// How many seconds remained for the given activity.
/// Gets the number of seconds remaining for the given activity.
/// </summary>
private readonly UInt32 secondsRemaining;
internal string Activity
{
get { return activity; }
}
internal int ActivityID
{
get { return activityID; }
}
internal string CurrentOperation
{
get { return currentOperation; }
}
internal string StatusDescription
{
get { return statusDescription; }
}
internal UInt32 PercentageCompleted
{
get { return percentageCompleted; }
}
internal UInt32 SecondsRemaining
{
get { return secondsRemaining; }
}
internal UInt32 SecondsRemaining { get; }
#endregion
}

View file

@ -19,7 +19,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
public CimWriteResultObject(object result, XOperationContextBase theContext)
{
this.result = result;
this.Result = result;
this.Context = theContext;
}
@ -32,22 +32,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
public override void Execute(CmdletOperationBase cmdlet)
{
ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
cmdlet.WriteObject(result, this.Context);
cmdlet.WriteObject(Result, this.Context);
}
#region members
/// <summary>
/// Result object.
/// </summary>
internal object Result
{
get
{
return result;
}
}
private readonly object result;
internal object Result { get; }
#endregion
}
}

View file

@ -53,14 +53,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Parameter(
Position = 1,
ValueFromPipelineByPropertyName = true)]
public string Association
{
get { return association; }
set { association = value; }
}
private string association;
public string Association { get; set; }
/// <summary>
/// The following is the definition of the input parameter "ResultClassName".
@ -68,14 +61,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// the given instance.
/// </summary>
[Parameter]
public string ResultClassName
{
get { return resultClassName; }
set { resultClassName = value; }
}
private string resultClassName;
public string ResultClassName { get; set; }
/// <summary>
/// <para>
@ -90,11 +76,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias(CimBaseCommand.AliasCimInstance)]
public CimInstance InputObject
{
get { return cimInstance; }
get { return CimInstance; }
set
{
cimInstance = value;
CimInstance = value;
base.SetParameter(value, nameCimInstance);
}
}
@ -102,12 +88,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Property for internal usage purpose.
/// </summary>
internal CimInstance CimInstance
{
get { return cimInstance; }
}
private CimInstance cimInstance;
internal CimInstance CimInstance { get; private set; }
/// <summary>
/// The following is the definition of the input parameter "Namespace".
@ -115,14 +96,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// is registered.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public string Namespace
{
get { return nameSpace; }
set { nameSpace = value; }
}
private string nameSpace;
public string Namespace { get; set; }
/// <summary>
/// The following is the definition of the input parameter "OperationTimeoutSec".
@ -133,14 +107,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter(ValueFromPipelineByPropertyName = true)]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// <para>
@ -220,14 +187,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter]
public SwitchParameter KeyOnly
{
get { return keyOnly; }
set { keyOnly = value; }
}
private SwitchParameter keyOnly;
public SwitchParameter KeyOnly { get; set; }
#endregion

View file

@ -54,14 +54,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Parameter(
Position = 0,
ValueFromPipelineByPropertyName = true)]
public string ClassName
{
get { return className; }
set { className = value; }
}
private string className;
public string ClassName { get; set; }
/// <summary>
/// <para>
@ -77,14 +70,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Parameter(
Position = 1,
ValueFromPipelineByPropertyName = true)]
public string Namespace
{
get { return nameSpace; }
set { nameSpace = value; }
}
private string nameSpace;
public string Namespace { get; set; }
/// <summary>
/// The following is the definition of the input parameter "OperationTimeoutSec".
@ -93,14 +79,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter(ValueFromPipelineByPropertyName = true)]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// The following is the definition of the input parameter "Session".
@ -158,14 +137,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public string MethodName
{
get { return methodName; }
set { methodName = value; }
}
private string methodName;
public string MethodName { get; set; }
/// <summary>
/// <para>
@ -175,14 +147,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public string PropertyName
{
get { return propertyName; }
set { propertyName = value; }
}
private string propertyName;
public string PropertyName { get; set; }
/// <summary>
/// <para>
@ -192,14 +157,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public string QualifierName
{
get { return qualifierName; }
set { qualifierName = value; }
}
private string qualifierName;
public string QualifierName { get; set; }
#endregion

View file

@ -241,14 +241,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// <para>The following is the definition of the input parameter "InputObject".
@ -276,11 +269,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias(CimBaseCommand.AliasCimInstance)]
public CimInstance InputObject
{
get { return cimInstance; }
get { return CimInstance; }
set
{
cimInstance = value;
CimInstance = value;
base.SetParameter(value, nameCimInstance);
}
}
@ -288,12 +281,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Property for internal usage purpose.
/// </summary>
internal CimInstance CimInstance
{
get { return cimInstance; }
}
private CimInstance cimInstance;
internal CimInstance CimInstance { get; private set; }
/// <summary>
/// The following is the definition of the input parameter "Query".
@ -421,23 +409,18 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias("SelectProperties")]
public string[] Property
{
get { return property; }
get { return SelectProperties; }
set
{
property = value;
SelectProperties = value;
base.SetParameter(value, nameSelectProperties);
}
}
/// <summary>
/// Property for internal usage.
/// </summary>
internal string[] SelectProperties
{
get { return property; }
}
private string[] property;
internal string[] SelectProperties { get; private set; }
#endregion
@ -519,7 +502,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
case CimBaseCommand.ClassNameSessionSet:
// validate the classname & property
this.className = ValidationHelper.ValidateArgumentIsValidName(nameClassName, this.className);
this.property = ValidationHelper.ValidateArgumentIsValidName(nameSelectProperties, this.property);
this.SelectProperties = ValidationHelper.ValidateArgumentIsValidName(nameSelectProperties, this.SelectProperties);
break;
default:
break;

View file

@ -182,11 +182,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias(CimBaseCommand.AliasCimInstance)]
public CimInstance InputObject
{
get { return cimInstance; }
get { return CimInstance; }
set
{
cimInstance = value;
CimInstance = value;
base.SetParameter(value, nameCimInstance);
}
}
@ -194,12 +194,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Property for internal usage purpose.
/// </summary>
internal CimInstance CimInstance
{
get { return cimInstance; }
}
private CimInstance cimInstance;
internal CimInstance CimInstance { get; private set; }
/// <summary>
/// <para>The following is the definition of the input parameter "ComputerName".
@ -287,14 +282,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Parameter(Position = 1, ValueFromPipelineByPropertyName = true)]
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public IDictionary Arguments
{
get { return arguments; }
set { arguments = value; }
}
private IDictionary arguments;
public IDictionary Arguments { get; set; }
/// <summary>
/// The following is the definition of the input parameter "MethodName".
@ -355,14 +343,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
#endregion

View file

@ -169,14 +169,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
ValueFromPipelineByPropertyName = true)]
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
[Alias("Arguments")]
public IDictionary Property
{
get { return property; }
set { property = value; }
}
private IDictionary property;
public IDictionary Property { get; set; }
/// <summary>
/// The following is the definition of the input parameter "Namespace".
@ -215,14 +208,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// <para>

View file

@ -52,14 +52,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Parameter(Position = 1, ParameterSetName = CredentialParameterSet)]
[Credential()]
public PSCredential Credential
{
get { return credential; }
set { credential = value; }
}
private PSCredential credential;
public PSCredential Credential { get; set; }
/// <summary>
/// The following is the definition of the input parameter "CertificateThumbprint".
@ -67,14 +60,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true,
ParameterSetName = CertificateParameterSet)]
public string CertificateThumbprint
{
get { return certificatethumbprint; }
set { certificatethumbprint = value; }
}
private string certificatethumbprint;
public string CertificateThumbprint { get; set; }
/// <summary>
/// The following is the definition of the input parameter "ComputerName".
@ -87,14 +73,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] ComputerName
{
get { return computername; }
set { computername = value; }
}
private string[] computername;
public string[] ComputerName { get; set; }
/// <summary>
/// <para>
@ -108,14 +87,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public string Name
{
get { return name; }
set { name = value; }
}
private string name;
public string Name { get; set; }
/// <summary>
/// <para>
@ -150,17 +122,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter SkipTestConnection
{
get { return skipTestConnection; }
set
{
skipTestConnection = value;
}
}
private SwitchParameter skipTestConnection;
public SwitchParameter SkipTestConnection { get; set; }
/// <summary>
/// The following is the definition of the input parameter "Port".
@ -196,14 +158,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// object is passed, then connection is made using WsMan.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public Microsoft.Management.Infrastructure.Options.CimSessionOptions SessionOption
{
get { return sessionOption; }
set { sessionOption = value; }
}
private Microsoft.Management.Infrastructure.Options.CimSessionOptions sessionOption;
public Microsoft.Management.Infrastructure.Options.CimSessionOptions SessionOption { get; set; }
#endregion
@ -256,11 +211,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
// clone the sessionOption object
if (this.SessionOption is WSManSessionOptions)
{
options = new WSManSessionOptions(this.sessionOption as WSManSessionOptions);
options = new WSManSessionOptions(this.SessionOption as WSManSessionOptions);
}
else
{
options = new DComSessionOptions(this.sessionOption as DComSessionOptions);
options = new DComSessionOptions(this.SessionOption as DComSessionOptions);
}
}
@ -319,7 +274,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
}
}
if (this.authenticationSet || (this.credential != null))
if (this.authenticationSet || (this.Credential != null))
{
PasswordAuthenticationMechanism authentication = this.authenticationSet ? this.Authentication : PasswordAuthenticationMechanism.Default;
if (this.authenticationSet)

View file

@ -416,28 +416,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Specifies the UI Culture to use. i.e. en-us, ar-sa.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public CultureInfo UICulture
{
get { return uiculture; }
set { uiculture = value; }
}
private CultureInfo uiculture;
public CultureInfo UICulture { get; set; }
/// <summary>
/// The following is the definition of the input parameter "Culture".
/// Specifies the culture to use. i.e. en-us, ar-sa.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public CultureInfo Culture
{
get { return culture; }
set { culture = value; }
}
private CultureInfo culture;
public CultureInfo Culture { get; set; }
#endregion

View file

@ -35,14 +35,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para>
/// </summary>
[Parameter]
public string Namespace
{
get { return nameSpace; }
set { nameSpace = value; }
}
private string nameSpace;
public string Namespace { get; set; }
/// <summary>
/// The following is the definition of the input parameter "ClassName".
@ -122,14 +115,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(CimBaseCommand.AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// The following is the definition of the input parameter "Session".

View file

@ -142,14 +142,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// The following is the definition of the input parameter "InputObject".
@ -168,11 +161,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias(CimBaseCommand.AliasCimInstance)]
public CimInstance InputObject
{
get { return cimInstance; }
get { return CimInstance; }
set
{
cimInstance = value;
CimInstance = value;
base.SetParameter(value, nameCimInstance);
}
}
@ -180,12 +173,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Property for internal usage purpose.
/// </summary>
internal CimInstance CimInstance
{
get { return cimInstance; }
}
private CimInstance cimInstance;
internal CimInstance CimInstance { get; private set; }
/// <summary>
/// The following is the definition of the input parameter "Query".

View file

@ -139,14 +139,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Alias(AliasOT)]
[Parameter]
public UInt32 OperationTimeoutSec
{
get { return operationTimeout; }
set { operationTimeout = value; }
}
private UInt32 operationTimeout;
public UInt32 OperationTimeoutSec { get; set; }
/// <summary>
/// The following is the definition of the input parameter "InputObject".
@ -165,11 +158,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
[Alias(CimBaseCommand.AliasCimInstance)]
public CimInstance InputObject
{
get { return cimInstance; }
get { return CimInstance; }
set
{
cimInstance = value;
CimInstance = value;
base.SetParameter(value, nameCimInstance);
}
}
@ -177,12 +170,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Property for internal usage purpose.
/// </summary>
internal CimInstance CimInstance
{
get { return cimInstance; }
}
private CimInstance cimInstance;
internal CimInstance CimInstance { get; private set; }
/// <summary>
/// The following is the definition of the input parameter "Query".
@ -277,20 +265,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary>
[Parameter]
[ValidateNotNull]
public SwitchParameter PassThru
{
get
{
return this.passThru;
}
set
{
this.passThru = value;
}
}
private SwitchParameter passThru;
public SwitchParameter PassThru { get; set; }
#endregion

View file

@ -138,31 +138,14 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary>
/// Flag used to control generating log message into file.
/// </summary>
private static bool generateLog = true;
internal static bool GenerateLog
{
get { return generateLog; }
set { generateLog = value; }
}
internal static bool GenerateLog { get; set; } = true;
/// <summary>
/// Whether the log been initialized.
/// </summary>
private static bool logInitialized = false;
/// <summary>
/// Flag used to control generating message into powershell.
/// </summary>
private static bool generateVerboseMessage = true;
internal static bool GenerateVerboseMessage
{
get { return generateVerboseMessage; }
set { generateVerboseMessage = value; }
}
internal static bool GenerateVerboseMessage { get; set; } = true;
/// <summary>
/// Flag used to control generating message into powershell.
@ -337,7 +320,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
}
}
if (generateLog)
if (GenerateLog)
{
if (indent < 0)
{