@@ -385,6 +385,17 @@ public override ArraySegment<byte> ReadCStringBytes()
385385 }
386386 }
387387
388+ /// <inheritdoc/>
389+ public override Decimal128 ReadDecimal128 ( )
390+ {
391+ ThrowIfDisposed ( ) ;
392+ ThrowIfEndOfStream ( 16 ) ;
393+
394+ var lowBits = ( ulong ) ReadInt64 ( ) ;
395+ var highBits = ( ulong ) ReadInt64 ( ) ;
396+ return Decimal128 . FromIEEEBits ( highBits , lowBits ) ;
397+ }
398+
388399 /// <inheritdoc/>
389400 public override double ReadDouble ( )
390401 {
@@ -531,7 +542,7 @@ public override void WriteCString(string value)
531542 throw new ArgumentNullException ( "value" ) ;
532543 }
533544 ThrowIfDisposed ( ) ;
534-
545+
535546 var maxLength = CStringUtf8Encoding . GetMaxByteCount ( value . Length ) + 1 ;
536547 PrepareToWrite ( maxLength ) ;
537548
@@ -586,11 +597,19 @@ public override void WriteCStringBytes(byte[] value)
586597 SetPositionAfterWrite ( _position + length + 1 ) ;
587598 }
588599
600+ /// <inheritdoc/>
601+ public override void WriteDecimal128 ( Decimal128 value )
602+ {
603+ ThrowIfDisposed ( ) ;
604+ WriteInt64 ( ( long ) value . GetIEEELowBits ( ) ) ;
605+ WriteInt64 ( ( long ) value . GetIEEEHighBits ( ) ) ;
606+ }
607+
589608 /// <inheritdoc/>
590609 public override void WriteDouble ( double value )
591610 {
592611 ThrowIfDisposed ( ) ;
593-
612+
594613 PrepareToWrite ( 8 ) ;
595614
596615 var bytes = BitConverter . GetBytes ( value ) ;
@@ -603,7 +622,7 @@ public override void WriteDouble(double value)
603622 public override void WriteInt32 ( int value )
604623 {
605624 ThrowIfDisposed ( ) ;
606-
625+
607626 PrepareToWrite ( 4 ) ;
608627
609628 var segment = _buffer . AccessBackingBytes ( _position ) ;
@@ -630,7 +649,7 @@ public override void WriteInt32(int value)
630649 public override void WriteInt64 ( long value )
631650 {
632651 ThrowIfDisposed ( ) ;
633-
652+
634653 PrepareToWrite ( 8 ) ;
635654
636655 var bytes = BitConverter . GetBytes ( value ) ;
@@ -643,7 +662,7 @@ public override void WriteInt64(long value)
643662 public override void WriteObjectId ( ObjectId value )
644663 {
645664 ThrowIfDisposed ( ) ;
646-
665+
647666 PrepareToWrite ( 12 ) ;
648667
649668 var segment = _buffer . AccessBackingBytes ( _position ) ;
@@ -664,7 +683,7 @@ public override void WriteObjectId(ObjectId value)
664683 public override void WriteString ( string value , UTF8Encoding encoding )
665684 {
666685 ThrowIfDisposed ( ) ;
667-
686+
668687 var maxLength = encoding . GetMaxByteCount ( value . Length ) + 5 ;
669688 PrepareToWrite ( maxLength ) ;
670689
0 commit comments