Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected object GetBaseObject(object value)
protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType)
{
PSReference cimReference = value as PSReference;
if (cimReference != null)
if (cimReference is not null)
{
object baseObject = GetBaseObject(cimReference.Value);
CimInstance cimInstance = baseObject as CimInstance;
Expand Down Expand Up @@ -516,7 +516,7 @@ private void Cleanup()
}
}

if (this.cimSessionProxyCache != null)
if (this.cimSessionProxyCache is not null)
{
List<CimSessionProxy> temporaryProxy;
lock (this.cimSessionProxyCache)
Expand All @@ -534,7 +534,7 @@ private void Cleanup()
}

this.moreActionEvent.Dispose();
if (this.ackedEvent != null)
if (this.ackedEvent is not null)
{
this.ackedEvent.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
// Dispose managed resources.
if (this.completeEvent != null)
if (this.completeEvent is not null)
{
this.completeEvent.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ internal string GetParameterSet()
if ((entry.SetMandatoryParameterCount == entry.MandatoryParameterCount) &&
this.parametersetNamesList.Contains(parameterSetName))
{
if (boundParameterSetName != null)
if (boundParameterSetName is not null)
{
throw new PSArgumentException(CimCmdletStrings.UnableToResolveParameterSetName);
}
Expand Down Expand Up @@ -527,7 +527,7 @@ public class CimBaseCommand : Cmdlet, IDisposable
/// </summary>
internal void CheckParameterSet()
{
if (this.parameterBinder != null)
if (this.parameterBinder is not null)
{
try
{
Expand Down Expand Up @@ -557,7 +557,7 @@ internal void SetParameter(object value, string parameterName)
return;
}

if (this.parameterBinder != null)
if (this.parameterBinder is not null)
{
this.parameterBinder.SetParameter(parameterName, this.AtBeginProcess);
}
Expand Down Expand Up @@ -663,7 +663,7 @@ protected void Dispose(bool disposing)
protected virtual void DisposeInternal()
{
// Dispose managed resources.
if (this.operation != null)
if (this.operation is not null)
{
this.operation.Dispose();
}
Expand Down Expand Up @@ -976,7 +976,7 @@ internal CimCredential CreateCimCredentials(PSCredential psCredentials,
DebugHelper.WriteLogEx("PSCredential:{0}; PasswordAuthenticationMechanism:{1}; operationName:{2}; parameterName:{3}.", 0, psCredentials, passwordAuthentication, operationName, parameterName);

CimCredential credentials = null;
if (psCredentials != null)
if (psCredentials is not null)
{
NetworkCredential networkCredential = psCredentials.GetNetworkCredential();
DebugHelper.WriteLog("Domain:{0}; UserName:{1}; Password:{2}.", 1, networkCredential.Domain, networkCredential.UserName, psCredentials.Password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void SetSessionProxyProperties(
{
proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
proxy.KeyOnly = cmdlet.KeyOnly;
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
proxy.ResourceUri = cmdlet.ResourceUri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ internal static bool IsClassNameQuerySet(CimBaseCommand cmdlet)
{
DebugHelper.WriteLogEx();
GetCimInstanceCommand cmd = cmdlet as GetCimInstanceCommand;
if (cmd != null)
if (cmd is not null)
{
if (cmd.QueryDialect != null || cmd.SelectProperties != null || cmd.Filter != null)
if (cmd.QueryDialect is not null || cmd.SelectProperties is not null || cmd.Filter is not null)
{
return true;
}
Expand All @@ -301,7 +301,7 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
{
DebugHelper.WriteLogEx();
GetCimInstanceCommand cmd = cmdlet as GetCimInstanceCommand;
if (cmd != null)
if (cmd is not null)
{
StringBuilder propertyList = new StringBuilder();
if (cmd.SelectProperties is null)
Expand Down Expand Up @@ -385,7 +385,7 @@ private void SetSessionProxyProperties(
proxy.KeyOnly = getCimInstance.KeyOnly;
proxy.Shallow = getCimInstance.Shallow;
proxy.OperationTimeout = getCimInstance.OperationTimeoutSec;
if (getCimInstance.ResourceUri != null)
if (getCimInstance.ResourceUri is not null)
{
proxy.ResourceUri = getCimInstance.ResourceUri;
}
Expand All @@ -394,7 +394,7 @@ private void SetSessionProxyProperties(
{
RemoveCimInstanceCommand removeCimInstance = cmdlet as RemoveCimInstanceCommand;
proxy.OperationTimeout = removeCimInstance.OperationTimeoutSec;
if (removeCimInstance.ResourceUri != null)
if (removeCimInstance.ResourceUri is not null)
{
proxy.ResourceUri = removeCimInstance.ResourceUri;
}
Expand All @@ -408,7 +408,7 @@ private void SetSessionProxyProperties(
{
SetCimInstanceCommand setCimInstance = cmdlet as SetCimInstanceCommand;
proxy.OperationTimeout = setCimInstance.OperationTimeoutSec;
if (setCimInstance.ResourceUri != null)
if (setCimInstance.ResourceUri is not null)
{
proxy.ResourceUri = setCimInstance.ResourceUri;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ protected CimSessionProxy CreateSessionProxy(
/// <param name="cmdlet"></param>
private void SetPreProcess(CimSessionProxy proxy, GetCimInstanceCommand cmdlet)
{
if (cmdlet.KeyOnly || (cmdlet.SelectProperties != null))
if (cmdlet.KeyOnly || (cmdlet.SelectProperties is not null))
{
proxy.ObjectPreProcess = new FormatPartialCimInstance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ private void Initialize(
private void NewSubscriptionResultHandler(object src, CimSubscriptionEventArgs args)
{
EventHandler<CimIndicationEventArgs> temp = this.CimIndicationArrived;
if (temp != null)
if (temp is not null)
{
// raise the event
CimSubscriptionResultEventArgs resultArgs = args as CimSubscriptionResultEventArgs;
if (resultArgs != null)
if (resultArgs is not null)
temp(this, new CimIndicationEventInstanceEventArgs(resultArgs.Result));
else
{
CimSubscriptionExceptionEventArgs exceptionArgs = args as CimSubscriptionExceptionEventArgs;
if (exceptionArgs != null)
if (exceptionArgs is not null)
temp(this, new CimIndicationEventExceptionEventArgs(exceptionArgs.Exception));
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ public void Stop()
{
if (status == Status.Started)
{
if (this.cimRegisterCimIndication != null)
if (this.cimRegisterCimIndication is not null)
{
DebugHelper.WriteLog("Dispose CimRegisterCimIndication object", 4);
this.cimRegisterCimIndication.Dispose();
Expand All @@ -348,7 +348,7 @@ public void Stop()
/// <param name="cmdlet"></param>
internal void SetCmdlet(Cmdlet cmdlet)
{
if (this.cimRegisterCimIndication != null)
if (this.cimRegisterCimIndication is not null)
{
this.cimRegisterCimIndication.Cmdlet = cmdlet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
case CimBaseCommand.ResourceUriComputerSet:
{
string target = string.Format(CultureInfo.CurrentUICulture, targetClass, cmdlet.ClassName);
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
nameSpace = cmdlet.Namespace;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
case CimBaseCommand.CimInstanceSessionSet:
{
string target = cmdlet.CimInstance.ToString();
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
nameSpace = cmdlet.Namespace;
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public void InvokeCimMethodOnCimInstance(CimInstance cimInstance, XOperationCont
{
DebugHelper.WriteLogEx();
CimInvokeCimMethodContext cimInvokeCimMethodContext = context as CimInvokeCimMethodContext;
Debug.Assert(cimInvokeCimMethodContext != null, "CimInvokeCimMethod::InvokeCimMethodOnCimInstance should has CimInvokeCimMethodContext != NULL.");
Debug.Assert(cimInvokeCimMethodContext is not null, "CimInvokeCimMethod::InvokeCimMethodOnCimInstance should has CimInvokeCimMethodContext is not null.");

string action = string.Format(CultureInfo.CurrentUICulture, actionTemplate, cimInvokeCimMethodContext.MethodName);
if (!operation.ShouldProcess(cimInstance.ToString(), action))
Expand Down Expand Up @@ -280,7 +280,7 @@ private void SetSessionProxyProperties(
InvokeCimMethodCommand cmdlet)
{
proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
proxy.ResourceUri = cmdlet.ResourceUri;
}
Expand Down Expand Up @@ -385,7 +385,7 @@ private CimMethodParametersCollection CreateParametersCollection(
CimMethodParameter parameter = null;
CimMethodDeclaration declaration = null;
string className = null;
if (cimClass != null)
if (cimClass is not null)
{
className = cimClass.CimSystemProperties.ClassName;
declaration = cimClass.CimClassMethods[methodName];
Expand All @@ -395,13 +395,13 @@ private CimMethodParametersCollection CreateParametersCollection(
CultureInfo.CurrentUICulture, CimCmdletStrings.InvalidMethod, methodName, className));
}
}
else if (cimInstance != null)
else if (cimInstance is not null)
{
className = cimInstance.CimClass.CimSystemProperties.ClassName;
declaration = cimInstance.CimClass.CimClassMethods[methodName];
}

if (declaration != null)
if (declaration is not null)
{
CimMethodParameterDeclaration paramDeclaration = declaration.Parameters[parameterName];
if (paramDeclaration is null)
Expand Down Expand Up @@ -433,7 +433,7 @@ private CimMethodParametersCollection CreateParametersCollection(
{
CimType referenceType = CimType.Unknown;
object referenceObject = GetReferenceOrReferenceArrayObject(parameterValue, ref referenceType);
if (referenceObject != null)
if (referenceObject is not null)
{
parameter = CimMethodParameter.Create(
parameterName,
Expand All @@ -451,7 +451,7 @@ private CimMethodParametersCollection CreateParametersCollection(
}
}

if (parameter != null)
if (parameter is not null)
collection.Add(parameter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void SetSessionProxyProperties(
NewCimInstanceCommand cmdlet)
{
proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
proxy.ResourceUri = cmdlet.ResourceUri;
}
Expand Down Expand Up @@ -274,7 +274,7 @@ private CimInstance CreateCimInstance(
}

List<string> keys = new List<string>();
if (key != null)
if (key is not null)
{
foreach (string keyName in key)
{
Expand All @@ -297,7 +297,7 @@ private CimInstance CreateCimInstance(
DebugHelper.WriteLog("Create and add new property to ciminstance: name = {0}; value = {1}; flags = {2}", 5, propertyName, propertyValue, flag);

PSReference cimReference = propertyValue as PSReference;
if (cimReference != null)
if (cimReference is not null)
{
CimProperty newProperty = CimProperty.Create(propertyName, GetBaseObject(cimReference.Value), CimType.Reference, flag);
cimInstance.CimInstanceProperties.Add(newProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actio

// NOTES: should move after this.Disposed, but need to log the exception
CimWriteError cimWriteError = actionArgs.Action as CimWriteError;
if (cimWriteError != null)
if (cimWriteError is not null)
{
this.exception = cimWriteError.Exception;
if (!this.ackedEvent.IsSet)
Expand All @@ -229,7 +229,7 @@ private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actio
}

EventHandler<CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult;
if (temp != null)
if (temp is not null)
{
DebugHelper.WriteLog("Raise an exception event", 2);

Expand All @@ -240,13 +240,13 @@ private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actio
}

CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject;
if (cimWriteResultObject != null)
if (cimWriteResultObject is not null)
{
CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult;
if (result != null)
if (result is not null)
{
EventHandler<CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult;
if (temp != null)
if (temp is not null)
{
DebugHelper.WriteLog("Raise an result event", 2);
temp(this, new CimSubscriptionResultEventArgs(result));
Expand Down Expand Up @@ -276,10 +276,10 @@ private void WaitForAckMessage()
{
DebugHelper.WriteLogEx();
this.ackedEvent.Wait();
if (this.exception != null)
if (this.exception is not null)
{
DebugHelper.WriteLogEx("error happened", 0);
if (this.Cmdlet != null)
if (this.Cmdlet is not null)
{
DebugHelper.WriteLogEx("Throw Terminating error", 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet)
case CimBaseCommand.CimInstanceComputerSet:
case CimBaseCommand.CimInstanceSessionSet:
string nameSpace = null;
if (cmdlet.ResourceUri != null)
if (cmdlet.ResourceUri is not null)
{
nameSpace = GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ internal void RemoveCimInstance(CimInstance cimInstance, XOperationContextBase c
}

CimRemoveCimInstanceContext removeContext = context as CimRemoveCimInstanceContext;
Debug.Assert(removeContext != null, "CimRemoveCimInstance::RemoveCimInstance should has CimRemoveCimInstanceContext != NULL.");
Debug.Assert(removeContext is not null, "CimRemoveCimInstance::RemoveCimInstance should has CimRemoveCimInstanceContext is not null.");

CimSessionProxy proxy = CreateCimSessionProxy(removeContext.Proxy);
proxy.DeleteInstanceAsync(removeContext.Namespace, cimInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public override void OnNext(CimMethodResultBase value)
string resultObjectPSType = null;
PSObject resultObject = null;
CimMethodResult methodResult = value as CimMethodResult;
if (methodResult != null)
if (methodResult is not null)
{
resultObjectPSType = PSTypeCimMethodResult;
resultObject = new PSObject();
Expand All @@ -460,7 +460,7 @@ public override void OnNext(CimMethodResultBase value)
else
{
CimMethodStreamedResult methodStreamedResult = value as CimMethodStreamedResult;
if (methodStreamedResult != null)
if (methodStreamedResult is not null)
{
resultObjectPSType = PSTypeCimMethodStreamedResult;
resultObject = new PSObject();
Expand All @@ -470,7 +470,7 @@ public override void OnNext(CimMethodResultBase value)
}
}

if (resultObject != null)
if (resultObject is not null)
{
resultObject.Properties.Add(new PSNoteProperty(@"PSComputerName", this.CurrentSession.ComputerName));
resultObject.TypeNames.Insert(0, resultObjectPSType);
Expand Down
Loading