public void WriteRecord(int recordIdx, object data) { if (recordIdx >= this.recordList.Count || 0 > recordIdx) { throw new InvalidRecordException(); } // encode the data //byte[] record = RecordDataEncoder.GetBytes(data); byte[] record = StoragePage.Serialize(data); if (0 > this.GetAvailableSpace() + this.GetRecordSize(recordIdx) - this.GetRecordSize(record)) { throw new InsuffcientSpaceException(); } this.recordList[recordIdx] = record; }
public int AddRecord(object data) { byte[] record = StoragePage.Serialize(data); if (0 > this.GetAvailableSpace() - this.GetRecordSize(record)) { throw new InsuffcientSpaceException(); } // lets find a space to insert this data int index = this.recordList.IndexOf(null); if (-1 == index) { index = this.recordList.Count; } // add the data this.recordList.Insert(index, record); // return to index return(this.recordList.IndexOf(record)); }