[CSHARP-435] Add a mechanism to add filters to (de)serialization. Created: 05/Apr/12 Updated: 20/Apr/20 Resolved: 06/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Feature Request |
| Affects Version/s: | 1.4 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Santiago M. Mola | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Description |
|
It would be useful to have a mechanism to customize the serialization of a field without implementing a custom serializer. For example, if I have an automapped class, I might want to add some value escaping/unescapping to some string properties. This might be specially useful when a string contains characters that are illegal in MongoDB, such as the dot in keys. |
| Comments |
| Comment by Robert Stam [ 06/Apr/12 ] |
|
Even though the patch is rather small I would rather not add a feature that would rarely be used. This is not actually needed for the suggested use case where dictionary keys contain dots because dictionaries already have serialization options that handle this. In the rare case that you really did want to transform the data on the way out and back in I would rather see this handled by a custom serializer. |
| Comment by Santiago M. Mola [ 05/Apr/12 ] |
|
Here's the patch I written to add this functionality. The name of methods is probably a bad choice, but I think it makes the point. |