Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected bool IsActive()
/// <param name="session"></param>
protected CimSessionProxy CreateCimSessionProxy(CimSessionProxy originalProxy)
{
CimSessionProxy proxy = new CimSessionProxy(originalProxy);
CimSessionProxy proxy = new(originalProxy);
this.SubscribeEventAndAddProxytoCache(proxy);
return proxy;
}
Expand All @@ -259,7 +259,7 @@ protected CimSessionProxy CreateCimSessionProxy(CimSessionProxy originalProxy, b
/// <param name="session"></param>
protected CimSessionProxy CreateCimSessionProxy(CimSession session)
{
CimSessionProxy proxy = new CimSessionProxy(session);
CimSessionProxy proxy = new(session);
this.SubscribeEventAndAddProxytoCache(proxy);
return proxy;
}
Expand All @@ -282,7 +282,7 @@ protected CimSessionProxy CreateCimSessionProxy(CimSession session, bool passThr
/// <param name="computerName"></param>
protected CimSessionProxy CreateCimSessionProxy(string computerName)
{
CimSessionProxy proxy = new CimSessionProxy(computerName);
CimSessionProxy proxy = new(computerName);
this.SubscribeEventAndAddProxytoCache(proxy);
return proxy;
}
Expand All @@ -296,7 +296,7 @@ protected CimSessionProxy CreateCimSessionProxy(string computerName)
/// <returns></returns>
protected CimSessionProxy CreateCimSessionProxy(string computerName, CimInstance cimInstance)
{
CimSessionProxy proxy = new CimSessionProxy(computerName, cimInstance);
CimSessionProxy proxy = new(computerName, cimInstance);
this.SubscribeEventAndAddProxytoCache(proxy);
return proxy;
}
Expand Down Expand Up @@ -546,7 +546,7 @@ private void Cleanup()
/// <summary>
/// Lock object.
/// </summary>
private readonly object a_lock = new object();
private readonly object a_lock = new();

/// <summary>
/// Number of active operations.
Expand All @@ -568,7 +568,7 @@ private void Cleanup()
/// <summary>
/// Lock object.
/// </summary>
private readonly object cimSessionProxyCacheLock = new object();
private readonly object cimSessionProxyCacheLock = new();

/// <summary>
/// Cache all <see cref="CimSessionProxy"/> objects related to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ internal ParameterBinder(
/// throw exception
/// </para>
/// </summary>
private List<string> parametersetNamesList = new List<string>();
private List<string> parametersetNamesList = new();

/// <summary>
/// Parameter names list.
/// </summary>
private readonly List<string> parameterNamesList = new List<string>();
private readonly List<string> parameterNamesList = new();

/// <summary>
/// <para>
Expand All @@ -270,12 +270,12 @@ internal ParameterBinder(
/// throw exception
/// </para>
/// </summary>
private List<string> parametersetNamesListAtBeginProcess = new List<string>();
private List<string> parametersetNamesListAtBeginProcess = new();

/// <summary>
/// Parameter names list before begin process.
/// </summary>
private readonly List<string> parameterNamesListAtBeginProcess = new List<string>();
private readonly List<string> parameterNamesListAtBeginProcess = new();

/// <summary>
/// <para>
Expand Down Expand Up @@ -331,7 +331,7 @@ internal void SetParameter(string parameterName, bool isBeginProcess)

if (this.parametersetNamesList.Count == 0)
{
List<string> nameset = new List<string>();
List<string> nameset = new();
foreach (ParameterDefinitionEntry parameterDefinitionEntry in this.parameterDefinitionEntries[parameterName])
{
DebugHelper.WriteLogEx("parameterset name = '{0}'; mandatory = '{1}'", 1, parameterDefinitionEntry.ParameterSetName, parameterDefinitionEntry.IsMandatory);
Expand Down Expand Up @@ -370,7 +370,7 @@ internal void SetParameter(string parameterName, bool isBeginProcess)
}
else
{
List<string> nameset = new List<string>();
List<string> nameset = new();
foreach (ParameterDefinitionEntry entry in this.parameterDefinitionEntries[parameterName])
{
if (this.parametersetNamesList.Contains(entry.ParameterSetName))
Expand Down Expand Up @@ -418,7 +418,7 @@ internal string GetParameterSet()

string boundParameterSetName = null;
string defaultParameterSetName = null;
List<string> noMandatoryParameterSet = new List<string>();
List<string> noMandatoryParameterSet = new();

// Looking for parameter set which have mandatory parameters
foreach (string parameterSetName in this.parameterSetEntries.Keys)
Expand Down Expand Up @@ -687,7 +687,7 @@ protected virtual void DisposeInternal()
/// <summary>
/// Lock object.
/// </summary>
private readonly object myLock = new object();
private readonly object myLock = new();

/// <summary>
/// <para>
Expand Down Expand Up @@ -771,7 +771,7 @@ internal virtual CmdletOperationBase CmdletOperation
/// </summary>
internal void ThrowTerminatingError(Exception exception, string operation)
{
ErrorRecord errorRecord = new ErrorRecord(exception, operation, ErrorCategory.InvalidOperation, this);
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);
this.CmdletOperation.ThrowTerminatingError(errorRecord);
}

Expand Down Expand Up @@ -909,7 +909,7 @@ internal void ThrowInvalidAuthenticationTypeError(
ImpersonatedAuthenticationMechanism.Negotiate,
ImpersonatedAuthenticationMechanism.Kerberos,
ImpersonatedAuthenticationMechanism.NtlmDomain);
PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
PSArgumentOutOfRangeException exception = new(
parameterName, authentication, message);
ThrowTerminatingError(exception, operationName);
}
Expand All @@ -928,7 +928,7 @@ internal void ThrowConflictParameterWasSet(
string message = string.Format(CultureInfo.CurrentUICulture,
CimCmdletStrings.ConflictParameterWasSet,
parameterName, conflictParameterName);
PSArgumentException exception = new PSArgumentException(message, parameterName);
PSArgumentException exception = new(message, parameterName);
ThrowTerminatingError(exception, operationName);
}

Expand All @@ -944,7 +944,7 @@ internal void ThrowInvalidProperty(
string operationName,
IDictionary actualValue)
{
StringBuilder propList = new StringBuilder();
StringBuilder propList = new();
foreach (string property in propertiesList)
{
if (propList.Length > 0)
Expand All @@ -957,7 +957,7 @@ internal void ThrowInvalidProperty(

string message = string.Format(CultureInfo.CurrentUICulture, CimCmdletStrings.CouldNotFindPropertyFromGivenClass,
className, propList);
PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
PSArgumentOutOfRangeException exception = new(
parameterName, actualValue, message);
ThrowTerminatingError(exception, operationName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void GetCimAssociatedInstance(GetCimAssociatedInstanceCommand cmdlet)
nameSpace = ConstValue.GetNamespace(cmdlet.CimInstance.CimSystemProperties.Namespace);
}

List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();
switch (cmdlet.ParameterSetName)
{
case CimBaseCommand.ComputerSetName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ public CimGetCimClass()
/// <param name="cmdlet"><see cref="GetCimClassCommand"/> object.</param>
public void GetCimClass(GetCimClassCommand cmdlet)
{
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();
string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
CimGetCimClassContext context = new CimGetCimClassContext(
CimGetCimClassContext context = new(
cmdlet.ClassName,
cmdlet.MethodName,
cmdlet.PropertyName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void GetCimInstanceInternal(CimBaseCommand cmdlet)
IEnumerable<string> computerNames = ConstValue.GetComputerNames(
GetComputerName(cmdlet));
string nameSpace;
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();
bool isGetCimInstanceCommand = (cmdlet is GetCimInstanceCommand);
CimInstance targetCimInstance = null;
switch (cmdlet.ParameterSetName)
Expand Down Expand Up @@ -301,7 +301,7 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
GetCimInstanceCommand cmd = cmdlet as GetCimInstanceCommand;
if (cmd != null)
{
StringBuilder propertyList = new StringBuilder();
StringBuilder propertyList = new();
if (cmd.SelectProperties == null)
{
propertyList.Append('*');
Expand Down Expand Up @@ -397,7 +397,7 @@ private void SetSessionProxyProperties(
proxy.ResourceUri = removeCimInstance.ResourceUri;
}

CimRemoveCimInstanceContext context = new CimRemoveCimInstanceContext(
CimRemoveCimInstanceContext context = new(
ConstValue.GetNamespace(removeCimInstance.Namespace),
proxy);
proxy.ContextObject = context;
Expand All @@ -411,7 +411,7 @@ private void SetSessionProxyProperties(
proxy.ResourceUri = setCimInstance.ResourceUri;
}

CimSetCimInstanceContext context = new CimSetCimInstanceContext(
CimSetCimInstanceContext context = new(
ConstValue.GetNamespace(setCimInstance.Namespace),
setCimInstance.Property,
proxy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
{
IEnumerable<string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
string nameSpace;
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();
string action = string.Format(CultureInfo.CurrentUICulture, actionTemplate, cmdlet.MethodName);

switch (cmdlet.ParameterSetName)
Expand Down Expand Up @@ -194,7 +194,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
foreach (CimSessionProxy proxy in proxys)
{
// create context object
CimInvokeCimMethodContext context = new CimInvokeCimMethodContext(
CimInvokeCimMethodContext context = new(
nameSpace,
cmdlet.MethodName,
paramsCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void NewCimInstance(NewCimInstanceCommand cmdlet)
}

// create ciminstance on server
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();

switch (cmdlet.ParameterSetName)
{
Expand Down Expand Up @@ -267,13 +267,13 @@ private CimInstance CreateCimInstance(
IDictionary properties,
NewCimInstanceCommand cmdlet)
{
CimInstance cimInstance = new CimInstance(className, cimNamespace);
CimInstance cimInstance = new(className, cimNamespace);
if (properties == null)
{
return cimInstance;
}

List<string> keys = new List<string>();
List<string> keys = new();
if (key != null)
{
foreach (string keyName in key)
Expand Down Expand Up @@ -331,13 +331,13 @@ private CimInstance CreateCimInstance(
IDictionary properties,
NewCimInstanceCommand cmdlet)
{
CimInstance cimInstance = new CimInstance(cimClass);
CimInstance cimInstance = new(cimClass);
if (properties == null)
{
return cimInstance;
}

List<string> notfoundProperties = new List<string>();
List<string> notfoundProperties = new();
foreach (string property in properties.Keys)
{
if (cimInstance.CimInstanceProperties[property] == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet)

IEnumerable<string> computerNames = ConstValue.GetComputerNames(
GetComputerName(cmdlet));
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
List<CimSessionProxy> proxys = new();
switch (cmdlet.ParameterSetName)
{
case CimBaseCommand.CimInstanceComputerSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public virtual void OnCompleted()
// OnNext, OnError
try
{
AsyncResultCompleteEventArgs completeArgs = new AsyncResultCompleteEventArgs(
AsyncResultCompleteEventArgs completeArgs = new(
this.session, this.observable);
this.OnNewResult(this, completeArgs);
}
Expand All @@ -280,7 +280,7 @@ public virtual void OnError(Exception error)
{
try
{
AsyncResultErrorEventArgs errorArgs = new AsyncResultErrorEventArgs(
AsyncResultErrorEventArgs errorArgs = new(
this.session, this.observable, error, this.context);
this.OnNewResult(this, errorArgs);
}
Expand All @@ -300,7 +300,7 @@ protected void OnNextCore(object value)
DebugHelper.WriteLogEx("value = {0}.", 1, value);
try
{
AsyncResultObjectEventArgs resultArgs = new AsyncResultObjectEventArgs(
AsyncResultObjectEventArgs resultArgs = new(
this.session, this.observable, value);
this.OnNewResult(this, resultArgs);
}
Expand Down
Loading