private int GetSelectionId(Microsoft.ManagementConsole.Internal.SelectionCardinality type, object selectionObject)
{
int selectionId = -1;
bool flag = true;
if (selectionObject != null)
{
flag = !this._view.SnapIn.RunningTaskSelectionDatas.FindMatchingSelectionId(selectionObject, out selectionId);
if (flag)
{
ScopeNode scopeNode = this._view.ScopeNode;
flag = (scopeNode == null) || !scopeNode.CurrentSelectionDatas.FindMatchingSelectionId(selectionObject, out selectionId);
}
}
if (!flag)
{
return selectionId;
}
if (_nextSelectionId == 0x7fffffff)
{
TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Error, 12, "The max value for selection identifiers has been reached.");
throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.ExceptionMMCOutOfResources));
}
Interlocked.Increment(ref _nextSelectionId);
return _nextSelectionId;
}