[CSHARP-813] Add TryParse method to WriteConcern class Created: 03/Sep/13 Updated: 20/Mar/14 Resolved: 20/Mar/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.8.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Rasitha Wijesinghe | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
windows/.net |
||
| Description |
|
Can you add a TryParse method to WriteConcern class so a string can be converted to a matching WriteConcern value? (Similar to Enum.TryParse) This will help when db settings are stored elsewhere and we have to convert in code (ex. values coming from a xml file). |
| Comments |
| Comment by Craig Wilson [ 20/Mar/14 ] | ||||
|
Hi Rasitha, Parse is a somewhat overloaded term here and we feel that opening this up could lead to us needing to parse many different variations of the same thing. We understand your concern, but don't believe this belongs in the driver. If you feel strongly, feel free to re-open the ticket and we'd be happy to continue the discussion. Thanks, | ||||
| Comment by Rasitha Wijesinghe [ 03/Sep/13 ] | ||||
|
Acknowledged So in code I could do something like this:
Today I have to have a switch statement and if you add another W value, I'll have to change my code too. If you are implementing TryParse, you could also implement Parse that would throw if not a valid value. | ||||
| Comment by Craig Wilson [ 03/Sep/13 ] | ||||
|
Rasitha, |