[CSHARP-1625] Add TryParse() support to BsonDocument Created: 09/Apr/16  Updated: 19/Oct/16  Resolved: 17/Oct/16

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.2.3
Fix Version/s: 2.4

Type: Improvement Priority: Trivial - P5
Reporter: Lloyd Kinsella Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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
}



 Comments   
Comment by Githook User [ 17/Oct/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1625: Added TryParse to BsonDocument.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/2ecfe930b6bf77f5134cffa6c0668443c0909916

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