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

Allow overriding of default serializers for built-in types



    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Component/s: Feature Request
    • Labels:


      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.




            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: