public MakerListFile(FileInfo file) { CSVFileInfo = file; List <KeyType> keys = new List <KeyType>(); using (FileStream fs = file.OpenRead()) { using (StreamReader sr = new StreamReader(fs)) { int counter = 0; while (!sr.EndOfStream) { string line = sr.ReadLine(); if (counter == 0) //Category line { Category = (CategoryNo)int.Parse(line); } else if (counter == 1 || counter == 2) { } //Pointless lines else if (counter == 3) //Header line { foreach (string key in line.Trim().Split(',')) { keys.Add((KeyType)Enum.Parse(typeof(KeyType), key)); } } else //Data lines { if (string.IsNullOrEmpty(line)) { continue; } Dictionary <KeyType, string> lineData = new Dictionary <KeyType, string>(); var lineSplit = line.Trim().Split(','); for (int i = 0; i < lineSplit.Length; i++) { lineData[keys[i]] = lineSplit[i]; } Data.Add(lineData); } counter++; } } } }
public RealPair(CategoryNo cat, int id = -1) { this.cat = (int)cat; this.id = id; }