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
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 @@ -207,7 +207,7 @@ protected void AddCimSessionProxy(CimSessionProxy sessionproxy)
{
lock (cimSessionProxyCacheLock)
{
if (this.cimSessionProxyCache == null)
if (this.cimSessionProxyCache is null)
{
this.cimSessionProxyCache = new List<CimSessionProxy>();
}
Expand Down Expand Up @@ -349,15 +349,15 @@ protected virtual void SubscribeToCimSessionProxyEvent(CimSessionProxy proxy)
protected object GetBaseObject(object value)
{
PSObject psObject = value as PSObject;
if (psObject == null)
if (psObject is null)
{
return value;
}
else
{
object baseObject = psObject.BaseObject;
var arrayObject = baseObject as object[];
if (arrayObject == null)
if (arrayObject is null)
{
return baseObject;
}
Expand Down Expand Up @@ -389,7 +389,7 @@ protected object GetReferenceOrReferenceArrayObject(object value, ref CimType re
{
object baseObject = GetBaseObject(cimReference.Value);
CimInstance cimInstance = baseObject as CimInstance;
if (cimInstance == null)
if (cimInstance is null)
{
return null;
}
Expand All @@ -400,7 +400,7 @@ protected object GetReferenceOrReferenceArrayObject(object value, ref CimType re
else
{
object[] cimReferenceArray = value as object[];
if (cimReferenceArray == null)
if (cimReferenceArray is null)
{
return null;
}
Expand All @@ -413,14 +413,14 @@ protected object GetReferenceOrReferenceArrayObject(object value, ref CimType re
for (int i = 0; i < cimReferenceArray.Length; i++)
{
PSReference tempCimReference = cimReferenceArray[i] as PSReference;
if (tempCimReference == null)
if (tempCimReference is null)
{
return null;
}

object baseObject = GetBaseObject(tempCimReference.Value);
cimInstanceArray[i] = baseObject as CimInstance;
if (cimInstanceArray[i] == null)
if (cimInstanceArray[i] is null)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ internal void SetParameter(string parameterName, bool isBeginProcess)
{
DebugHelper.WriteLogEx("parameterset name = '{0}'; mandatory = '{1}'", 1, parameterDefinitionEntry.ParameterSetName, parameterDefinitionEntry.IsMandatory);
ParameterSetEntry psEntry = this.parameterSetEntries[parameterDefinitionEntry.ParameterSetName];
if (psEntry == null)
if (psEntry is null)
continue;

if (parameterDefinitionEntry.IsMandatory)
Expand Down Expand Up @@ -460,7 +460,7 @@ internal string GetParameterSet()
}

// Looking for parameter set which has no mandatory parameters
if (boundParameterSetName == null)
if (boundParameterSetName is null)
{
// throw if there are > 1 parameter set
if (noMandatoryParameterSet.Count > 1)
Expand All @@ -474,13 +474,13 @@ internal string GetParameterSet()
}

// Looking for default parameter set
if (boundParameterSetName == null)
if (boundParameterSetName is null)
{
boundParameterSetName = defaultParameterSetName;
}

// throw if still can not find the parameter set name
if (boundParameterSetName == null)
if (boundParameterSetName is null)
{
throw new PSArgumentException(CimCmdletStrings.UnableToResolveParameterSetName);
}
Expand Down Expand Up @@ -552,7 +552,7 @@ internal void SetParameter(object value, string parameterName)
// Null value could be set by caller unintentionally,
// or by powershell to reset the parameter to default value
// before the next parameter binding, and ProcessRecord call
if (value == null)
if (value is null)
{
return;
}
Expand Down Expand Up @@ -731,7 +731,7 @@ internal CimAsyncOperation AsyncOperation
{
lock (this.myLock)
{
Debug.Assert(this.operation == null, "Caller should verify that operation is null");
Debug.Assert(this.operation is null, "Caller should verify that operation is null");
this.operation = value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void GetCimAssociatedInstance(GetCimAssociatedInstanceCommand cmdlet)
IEnumerable<string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
// use the namespace from parameter
string nameSpace = cmdlet.Namespace;
if ((nameSpace == null) && (cmdlet.ResourceUri == null))
if ((nameSpace is null) && (cmdlet.ResourceUri is null))
{
// try to use namespace of ciminstance, then fall back to default namespace
nameSpace = ConstValue.GetNamespace(cmdlet.CimInstance.CimSystemProperties.Namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void GetCimClass(GetCimClassCommand cmdlet)
{
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
string className = (cmdlet.ClassName is null) ? @"*" : cmdlet.ClassName;
CimGetCimClassContext context = new CimGetCimClassContext(
cmdlet.ClassName,
cmdlet.MethodName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
if (cmd != null)
{
StringBuilder propertyList = new StringBuilder();
if (cmd.SelectProperties == null)
if (cmd.SelectProperties is null)
{
propertyList.Append("*");
}
Expand All @@ -321,7 +321,7 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
}
}

return (cmd.Filter == null) ?
return (cmd.Filter is null) ?
string.Format(CultureInfo.CurrentUICulture, queryWithoutWhere, propertyList, cmd.ClassName) :
string.Format(CultureInfo.CurrentUICulture, queryWithWhere, propertyList, cmd.ClassName, cmd.Filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public CimInstance NewEvent
{
get
{
return (result == null) ? null : result.Instance;
return (result is null) ? null : result.Instance;
}
}

Expand All @@ -92,7 +92,7 @@ public string MachineId
{
get
{
return (result == null) ? null : result.MachineId;
return (result is null) ? null : result.MachineId;
}
}

Expand All @@ -103,7 +103,7 @@ public string Bookmark
{
get
{
return (result == null) ? null : result.Bookmark;
return (result is null) ? null : result.Bookmark;
}
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public void Start()
{
if (status == Status.Default)
{
if (this.cimSession == null)
if (this.cimSession is null)
{
cimRegisterCimIndication.RegisterCimIndication(
this.computerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private CimMethodParametersCollection CreateParametersCollection(
DebugHelper.WriteLogEx();

CimMethodParametersCollection collection = null;
if (parameters == null)
if (parameters is null)
{
return collection;
}
Expand Down Expand Up @@ -389,7 +389,7 @@ private CimMethodParametersCollection CreateParametersCollection(
{
className = cimClass.CimSystemProperties.ClassName;
declaration = cimClass.CimClassMethods[methodName];
if (declaration == null)
if (declaration is null)
{
throw new ArgumentException(string.Format(
CultureInfo.CurrentUICulture, CimCmdletStrings.InvalidMethod, methodName, className));
Expand All @@ -404,7 +404,7 @@ private CimMethodParametersCollection CreateParametersCollection(
if (declaration != null)
{
CimMethodParameterDeclaration paramDeclaration = declaration.Parameters[parameterName];
if (paramDeclaration == null)
if (paramDeclaration is null)
{
throw new ArgumentException(string.Format(
CultureInfo.CurrentUICulture, CimCmdletStrings.InvalidMethodParameter, parameterName, methodName, className));
Expand All @@ -420,7 +420,7 @@ private CimMethodParametersCollection CreateParametersCollection(
}
else
{
if (parameterValue == null)
if (parameterValue is null)
{
// try the best to get the type while value is null
parameter = CimMethodParameter.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ internal void GetCimInstance(CimInstance cimInstance, XOperationContextBase cont
DebugHelper.WriteLogEx();

CimNewCimInstanceContext newCimInstanceContext = context as CimNewCimInstanceContext;
if (newCimInstanceContext == null)
if (newCimInstanceContext is null)
{
DebugHelper.WriteLog("Invalid (null) CimNewCimInstanceContext", 1);
return;
}

CimSessionProxy proxy = CreateCimSessionProxy(newCimInstanceContext.Proxy);
string nameSpace = (cimInstance.CimSystemProperties.Namespace == null) ? newCimInstanceContext.Namespace : cimInstance.CimSystemProperties.Namespace;
string nameSpace = (cimInstance.CimSystemProperties.Namespace is null) ? newCimInstanceContext.Namespace : cimInstance.CimSystemProperties.Namespace;
proxy.GetInstanceAsync(nameSpace, cimInstance);
}

Expand Down Expand Up @@ -268,7 +268,7 @@ private CimInstance CreateCimInstance(
NewCimInstanceCommand cmdlet)
{
CimInstance cimInstance = new CimInstance(className, cimNamespace);
if (properties == null)
if (properties is null)
{
return cimInstance;
}
Expand Down Expand Up @@ -332,15 +332,15 @@ private CimInstance CreateCimInstance(
NewCimInstanceCommand cmdlet)
{
CimInstance cimInstance = new CimInstance(cimClass);
if (properties == null)
if (properties is null)
{
return cimInstance;
}

List<string> notfoundProperties = new List<string>();
foreach (string property in properties.Keys)
{
if (cimInstance.CimInstanceProperties[property] == null)
if (cimInstance.CimInstanceProperties[property] is null)
{
notfoundProperties.Add(property);
cmdlet.ThrowInvalidProperty(notfoundProperties, cmdlet.CimClass.CimSystemProperties.ClassName, @"Property", action, properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void RegisterCimIndication(
UInt32 operationTimeout)
{
DebugHelper.WriteLogEx("queryDialect = '{0}'; queryExpression = '{1}'", 0, queryDialect, queryExpression);
if (cimSession == null)
if (cimSession is null)
{
throw new ArgumentNullException(string.Format(CultureInfo.CurrentUICulture, CimCmdletStrings.NullArgument, @"cimSession"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public virtual void OnNext(T value)
{
DebugHelper.WriteLogEx("value = {0}.", 1, value);
// do not allow null value
if (value == null)
if (value is null)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ internal CimSessionWrapper(

internal PSObject GetPSObject()
{
if (psObject == null)
if (psObject is null)
{
psObject = new PSObject(this.cimSession);
psObject.Properties.Add(new PSNoteProperty(CimSessionState.idPropName, this.sessionId));
Expand Down Expand Up @@ -965,7 +965,7 @@ internal void NewCimSession(NewCimSessionCommand cmdlet,
foreach (string computerName in computerNames)
{
CimSessionProxy proxy;
if (sessionOptions == null)
if (sessionOptions is null)
{
DebugHelper.WriteLog("Create CimSessionOption due to NewCimSessionCommand has null sessionoption", 1);
sessionOptions = CimSessionProxy.CreateCimSessionOption(computerName,
Expand Down Expand Up @@ -1150,7 +1150,7 @@ public void GetCimSession(GetCimSessionCommand cmdlet)
switch (cmdlet.ParameterSetName)
{
case CimBaseCommand.ComputerNameSet:
if (cmdlet.ComputerName == null)
if (cmdlet.ComputerName is null)
{
sessionToGet = this.sessionState.QuerySession(ConstValue.DefaultSessionName, out errorRecords);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ private void InitOption(CimOperationOptions operOptions)
{
this.options = new CimOperationOptions(operOptions);
}
else if (this.options == null)
else if (this.options is null)
{
this.options = new CimOperationOptions();
}
Expand Down Expand Up @@ -735,7 +735,7 @@ private void RemoveOperation(IObservable<object> operation)
this.operation = null;
}

if (this.session != null && this.ContextObject == null)
if (this.session != null && this.ContextObject is null)
{
DebugHelper.WriteLog("Dispose this proxy object @ RemoveOperation");
this.Dispose();
Expand Down Expand Up @@ -1049,7 +1049,7 @@ internal void ResultEventHandler(
/// <param name="o"></param>
private static void AddShowComputerNameMarker(object o)
{
if (o == null)
if (o is null)
{
return;
}
Expand Down Expand Up @@ -1547,7 +1547,7 @@ internal CimOperationOptions OperationOptions
/// </summary>
private bool Completed
{
get { return this.operation == null; }
get { return this.operation is null; }
}

/// <summary>
Expand Down Expand Up @@ -1918,7 +1918,7 @@ private void CheckAvailability()
/// </summary>
private void AssertSession()
{
if (this.IsDisposed || (this.session == null))
if (this.IsDisposed || (this.session is null))
{
DebugHelper.WriteLogEx("Invalid CimSessionProxy object, disposed? {0}; session object {1}", 1, this.IsDisposed, this.session);
throw new ObjectDisposedException(this.ToString());
Expand Down Expand Up @@ -2094,7 +2094,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args)

CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject;
CimClass cimClass = writeResultObject.Result as CimClass;
if (cimClass == null)
if (cimClass is null)
{
return true;
}
Expand Down Expand Up @@ -2248,7 +2248,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args)

CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject;
CimInstance cimInstance = writeResultObject.Result as CimInstance;
if (cimInstance == null)
if (cimInstance is null)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private bool SetProperty(IDictionary properties, ref CimInstance cimInstance, re
else // For dynamic instance, it is valid to add a new property
{
CimProperty newProperty;
if (value == null)
if (value is null)
{
newProperty = CimProperty.Create(
key,
Expand Down
Loading