//Construct from CSV data public Message(GenericCSVLine l) { //This is where we set the deserialization rules: what type should we parse each column as, etc... //Compound attributes could be managed here (constructing a DateTime from two columns, for example) text = l ["text"].asString(); name = l ["name"].asString(); status = l ["status"].asString(); favorite = l ["favorite"].asBool(); }
//Parse a single line, as a List of strings void ParseLine(int line_index, List <string> sourceLine) { if (line_index == 0) { lineHeaders = sourceLine.ToArray(); return; } GenericCSVLine line = new GenericCSVLine(); for (int i = 0; i < sourceLine.Count; i++) { line.AddField(lineHeaders [i], sourceLine [i]); } currentFile.Add(line); }