/// <summary> /// Query session list by given session objects array. /// </summary> /// <param name="cimsessions"></param> /// <returns>List of session wrapper objects.</returns> internal IEnumerable <PSObject> QuerySession(IEnumerable <CimSession> cimsessions, out IEnumerable <ErrorRecord> errorRecords) { HashSet <PSObject> sessions = new(); HashSet <uint> sessionIds = new(); List <ErrorRecord> errRecords = new(); errorRecords = errRecords; foreach (CimSession cimsession in cimsessions) { if (this.curCimSessionWrapper.ContainsKey(cimsession)) { CimSessionWrapper wrapper = this.curCimSessionWrapper[cimsession]; if (!sessionIds.Contains(wrapper.SessionId)) { sessionIds.Add(wrapper.SessionId); sessions.Add(wrapper.GetPSObject()); } } else { AddErrorRecord(ref errRecords, CimSessionClassName, CimSessionObject); } } return(sessions); }
/// <summary> /// Query session list by given instance id array. /// </summary> /// <param name="instanceIds"></param> /// <returns>List of session wrapper objects.</returns> internal IEnumerable <PSObject> QuerySession( IEnumerable <Guid> instanceIds, out IEnumerable <ErrorRecord> errorRecords) { HashSet <PSObject> sessions = new(); HashSet <uint> sessionIds = new(); List <ErrorRecord> errRecords = new(); errorRecords = errRecords; foreach (Guid instanceid in instanceIds) { if (this.curCimSessionsByInstanceId.ContainsKey(instanceid)) { CimSessionWrapper wrapper = this.curCimSessionsByInstanceId[instanceid]; if (!sessionIds.Contains(wrapper.SessionId)) { sessionIds.Add(wrapper.SessionId); sessions.Add(wrapper.GetPSObject()); } } else { AddErrorRecord(ref errRecords, instanceidPropName, instanceid); } } return(sessions); }