private List <T> GetRecords <T>(ColumnIndex currentIndex, string[] keys) where T : QuarterlyDatabaseRecord, new() { var compositeKey = new StringBuilder(); foreach (var currentKey in keys) { compositeKey.Append(currentKey); } var matchingRecords = new List <T>(); var offsets = currentIndex.GetOffsets(compositeKey.ToString()); if (offsets != null) { foreach (var currentOffset in offsets) { reader.BaseStream.Position = currentOffset; reader.DiscardBufferedData(); var line = reader.ReadLine(); var newRecord = new T(); newRecord.Populate(line); matchingRecords.Add(newRecord); } } return(matchingRecords); }
/// <summary> /// Determines if there is a match between a list of column numbers and an index. /// </summary> /// <param name="columns"> /// The list of zero-based columns to compare against the index. /// </param> /// <param name="indexCandidate"> /// The index to compare. /// </param> /// <returns> /// True if all of the specified columns are represented in the specified /// index; false otherwise. /// </returns> private bool ColumnsMatch(int[] columns, ColumnIndex indexCandidate) { if (columns.Length != indexCandidate.Columns.Length) { return(false); } foreach (var currentColumn in columns) { if (indexCandidate.Columns.Contains(currentColumn) == false) { return(false); } } return(true); }