Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1625

Add TryParse() support to BsonDocument

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 2.4
    • Affects Version/s: 2.2.3
    • Component/s: BSON
    • None

      It would be nice to have TryParse support for BsonDocument instead of just the Parse method which throws an exception.

      For example, the current way to parse a string:

      BsonDocument document = BsonDocument.Parse("{}");
      

      If this fails it throws an exception. However most of the .NET framework now supports a less heavy check, for example:

      BsonDocument document;
      
      if (!document.TryParse("{}",out document))
      {
          // Handle failed parse
      }
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            lloydk Lloyd Kinsella
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: