public static List <FullCell> ReadCells(string filename) { FileStream stream = File.OpenRead(filename); BinaryReader reader = new BinaryReader(stream); //read the number of headers int numOfHeaders = reader.ReadInt32(); //for each header, read a string and add it to the static headers FullCell.headers = new string[numOfHeaders]; for (int i = 0; i < numOfHeaders; i++) { if (reader.BaseStream.Position != reader.BaseStream.Length) { headers[i] = reader.ReadString(); } } List <FullCell> cells = new List <FullCell>(); //read the cells while (reader.BaseStream.Position != reader.BaseStream.Length) { FullCell cell = ReadCell(reader, numOfHeaders); cells.Add(cell); } reader.Close(); stream.Close(); return(cells); }
/// <summary> /// Writes a singular cell to a binary writer /// </summary> /// <param name="writer"></param> /// <param name="cell"></param> public static void WriteCell(BinaryWriter writer, FullCell cell) { writer.Write(cell.cellNumber); foreach (double val in cell.values) { writer.Write(val); } }
public bool CompareTo(FullCell f1) { if (cellNumber != f1.cellNumber) { return(false); } for (int i = 0; i < headers.Length; i++) { if (values[i] != f1.values[i]) { return(false); } } return(true); }