[CSHARP-1119] Introduce a Bson static class with a few BSON related helper methods Created: 20/Nov/14  Updated: 09/Nov/22  Resolved: 09/Nov/22

Status: Closed
Project: C# Driver
Component/s: Serialization
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Robert Stam Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-1118 Introduce a Json static class with a ... Closed

 Description   

Introduce a small static class to contain a few BSON related useful helper methods:

public static class Bson
{
    public T Deserialize<T>(BsonDocument document);
    public T Deserialize<T>(BsonDocument document, IBsonSerializer<T> serializer);
    public T Deserialize<T>(byte[] bson);
    public T Deserialize<T>(byte[] bson, IBsonSerializer<T> serializer);
    public byte[] ToBson<T>(T value);
    public byte[] ToBson<T>(T value, IBsonSerializer<T> serializer);
    public byte[] ToBsonDocument<T>(T value);
    public byte[] ToBsonDocument<T>(T value, IBsonSerializer<T> serializer);
    // and probably more, but this gives the idea
}

This would also be a step along the way to removing the ToBson and ToBsonDocument extension methods defined on object, which ended up polluting the global namespace.


Generated at Wed Feb 07 21:38:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.