[CSHARP-129] Static BsonTypeMapper function to cast from BsonValue to native types Created: 07/Dec/10 Updated: 02/Apr/15 Resolved: 20/Jan/11 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Feature Request |
| Affects Version/s: | 0.9 |
| Fix Version/s: | 0.11 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | J W Lee | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Description |
|
Is it possible to incorporate a static function to map BsonValues back to .NET types? The current conversion is one way only. I have attached an implementation in the BsonTypeMapper class I have been testing with my code. The implementation uses the type mapping declared in the private dictionaries. |
| Comments |
| Comment by Robert Stam [ 20/Jan/11 ] |
|
BsonValue now implements IConvertible. |
| Comment by Craig Wilson [ 28/Dec/10 ] |
|
Could BsonValue (or it's implementors) simply implement IConvertible? That way it is synonymous with the core types, int, long, bool, etc... |
| Comment by J W Lee [ 07/Dec/10 ] |
|
I have added another static function to determine if a type has a Conversion mapping to a Bson type. |