public static void ExtractCollectionFromResult(this IEnumerator<EventData> enumerator, bool fullDetails, List<IPSEventData> records, Func<EventData, bool> keepTheRecord) { while (enumerator.MoveNext()) { var current = enumerator.Current; if (keepTheRecord(current)) { records.Add(fullDetails ? (IPSEventData)new PSEventData(current) : (IPSEventData)new PSEventDataNoDetails(current)); } } } }