@@ -216,40 +216,21 @@ BSON document stored in ``myFile.bson``:
216
216
``System.IO.Stream`` object. This means that you can read or write any location
217
217
that can be accessed by a stream.
218
218
219
- Implement a Custom BSON Reader and Writer
220
- -----------------------------------------
219
+ Read and Write Other Formats
220
+ ----------------------------
221
221
222
- The preceding examples show how to read and write BSON documents by using the
223
- ``BsonBinaryReader`` and ``BsonBinaryWriter`` classes. However, you can also implement a
224
- custom reader and writer by implementing the
225
- ``IBsonReader`` and ``IBsonWriter`` interfaces. This is useful when you want to define
226
- a custom serializer or if you want to directly read or write BSON or JSON data without
227
- interacting with a MongoDB deployment.
222
+ The preceding examples show how to read and write BSON data by using the
223
+ ``BsonBinaryReader`` and ``BsonBinaryWriter`` classes. These classes implement the
224
+ ``IBsonReader`` and ``IBsonWriter`` interfaces. To read and write data in other formats,
225
+ the {+driver-short+} provides the following alternative implementations of the ``IBsonReader``
226
+ and ``IBsonWriter`` interfaces:
228
227
229
- The following code sample shows a custom reader that inherits from the
230
- ``IBsonReader`` interface:
228
+ - ``JsonReader`` and ``JsonWriter``: Read and write JSON data
229
+ - ``BsonDocumentReader`` and ``BsonDocumentWriter``: Read and write BSON data
230
+ contained in a ``BsonDocument`` object
231
231
232
- .. code-block:: csharp
233
-
234
- public class CustomReader : IBsonReader
235
- {
236
- private readonly BinaryReader _reader;
237
-
238
- public CustomReader(Stream stream)
239
- {
240
- _reader = new BinaryReader(stream);
241
- }
242
-
243
- public void ReadStartDocument()
244
- {
245
- // Implement logic to read the start of a BSON document here
246
- }
247
-
248
- // Implement other methods from the IBsonReader interface here
249
- }
250
-
251
- To learn more about serialization and deserialization in the {+driver-short+}, see the
252
- :ref:`csharp-serialization` guide.
232
+ Because these classes implement the same interfaces, you can call their methods in the same way
233
+ as the preceding ``BsonBinaryReader`` and ``BsonBinaryWriter`` examples.
253
234
254
235
.. _csharp-bson-api:
255
236
0 commit comments