public override void ToBson(byte[] buffer, ref int offset) { int startingOffset = offset; // leave space for the size offset += 4; foreach (DictionaryEntry member in _members) { ((JProperty)member.Value).ToBson(((JProperty)member.Value).Name, buffer, ref offset); } // Write the trailing nul if (buffer != null) { buffer[offset] = (byte)0; } ++offset; // Write the completed size if (buffer != null) { SerializationUtilities.Marshall(buffer, ref startingOffset, offset - startingOffset); } }
public override void ToBson(byte[] buffer, ref int offset) { int startingOffset = offset; // leave space for the size offset += 4; for (int i = 0; i < _contents.Length; ++i) { _contents[i].ToBson(i.ToString(), buffer, ref offset); } // Write the trailing nul if (buffer != null) { buffer[offset] = (byte)0; } ++offset; // Write the completed size if (buffer != null) { SerializationUtilities.Marshall(buffer, ref startingOffset, offset - startingOffset); } }
public override void ToBson(byte[] buffer, ref int offset) { if (buffer != null) { if (this.Value != null) { SerializationUtilities.Marshall(buffer, ref offset, this.Value); } } else { offset += this.GetBsonSize(); } }
public byte[] ToBson() { var size = this.GetBsonSize("") + 5; var buffer = new byte[size]; int offset = 4; this.ToBson("", buffer, ref offset); // Write the trailing nul buffer[offset++] = (byte)0; // Write the completed size int zero = 0; SerializationUtilities.Marshall(buffer, ref zero, offset); return(buffer); }