public byte[] Write() { MemoryStream stream = new MemoryStream(Size); BinaryWriter writer = new BinaryWriter(stream, System.Text.Encoding.Unicode); writer.Write(Size); nFirstIndex.Write(writer); Column.WriteData(writer, oData, tTable); writer.Write(Pos); Changed = false; return(stream.ToArray()); }
/// <summary> /// Serializes the result into a byte array. /// </summary> /// <returns></returns> internal byte[] GetBytes() { MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); try { writer.Write((int)_mode); if (_mode == ResultType.UpdateCount) { writer.Write(_updateCount); } else if (_mode == ResultType.Error) { writer.Write(_error); } else { int l = _columnCount; writer.Write(l); Record n = _root; for (int i = 0; i < l; i++) { writer.Write((int)Type[i]); writer.Write(Label[i]); writer.Write(Table[i]); writer.Write(Name[i]); } while (n != null) { Column.WriteData(writer, l, Type, n.Data); n = n.Next; } } return(stream.ToArray()); } catch (Exception e) { LogHelper.Publish("Unexpected error on getBytes.", e); throw Trace.Error(Trace.TRANSFER_CORRUPTED); } }