//<summary>The intention of this method is to use it //to send data over the wire. to a network client</summary> public byte[] ToByteArray() { System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); this.Header.BinWrite(bw); foreach (Column c in this.Columns) { c.BinWrite(bw); } while (this.HasRows) { Row r = this.NextRow(); r.BinWrite(bw); } bw.Flush(); bw.Close(); return(ms.GetBuffer()); }
// <summary> // Writes a row to disk // </summary> public void AddRow(Row r) { if (r.Table != this) { throw new InvalidOperationException("Can't add row - doesn't belong to this table"); } _fs.Seek(_fs.Length, 0); BinaryWriter bw = new BinaryWriter(_fs); r.BinWrite(bw); this.Header.RowCount += 1; _fs.Seek(0, 0); this.Header.BinWrite(bw); bw.Flush(); }