I'm trying to validate some data in a CSV file I'm parsing through. The users feed my program a CSV file and I want them to be able to validate any combination (and/or) of columns 2 though 7 and specify the output order. So far what I have is something like this
using (StreamReader sr = new StreamReader(inputFile.FullName))
{
while (!sr.EndOfStream)
{
string DataLine = sr.ReadLine();
OrderedDataLine= GetColumnOrder(DataLine);
if (ColumnOrderFound) //set in GetColumnOrder
{
if (UserChoseToValidateCol1) { ValidateCol1(OrderedDataLine);}
if (UserChoseToValidateCol2) { ValidateCol2(OrderedDataLine);}
//etc... for all columns
}
}
}
My OrderedDataLine
object is required to hold 3 pieces of information: the column type, the destination column number, and the value to be printed. Right now it looks like this: SortedList<DownloadSection, int>
where DownloadSection
is an enum for each of my possible column types. In .NET 4 I would be able to use a list of Tuples but no such luck in 3.5. Any ideas of what kind of object can store 3 distinct pieces of information?
I don't know if I'm tunnel visioned and maybe there's a better way to do this...
Tuple
Elements
where they are normally calledItems
. Not a big deal though. – Twentyone