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

Allow overriding of default serializers for built-in types

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.7
    • Component/s: Feature Request
    • None

      In the last version I was using (1.4), I was able to register a serializer that could assign any value to a field of type Object by calling the appropriate deserializer based on the BSON type and then assigning the result to the field. For example, given the following class definition:

      public class Stuff
      {
      public string Id

      { get; set; }
      public object TheStuff { get; set; }

      }

      I could persist anything as TheStuff and my custom serializer would deserialize and assign the value appropriately.

      However, it doesn't seem possible to override the default serializers in the latest version, try though I might to find such a mechanism in the documentation and the source code. In the LookupSerializer method, the method returns as soon as it has found a mapped serializer, and as far as I can tell, the default serializers are getting registered before I have an opportunity to register my own. Registering a custom provider doesn't help either, as the driver only does a custom provider look-up if it hasn't found a serializer in the default dictionary.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            dhgoldman Daniel Goldman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: