ToJson() serialization of Abstract classes (CSHARP-120)

[CSHARP-122] JSON/BSON Serialization of child objects with properties that hide the their parents properties fails Created: 03/Dec/10  Updated: 02/Apr/15  Resolved: 03/Dec/10

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 0.9
Fix Version/s: 0.9

Type: Sub-task Priority: Major - P3
Reporter: Justin Dearing Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Same as CSHARP-120, but for non abstract methods. Use any combination of virtual/new keywords or lack thereof.



 Comments   
Comment by Robert Stam [ 03/Dec/10 ]

Allow BsonClassMap to have more than one member of the same name (possible if a member in a subclass hides a base class member) as long as the element names are different. Changed MapMember to check for an existing map and return it before creating a new one.

NOTE: this solution requires you to specify an element name for at least one of the two members with the same name (for one, BSON doesn't allow duplicate element names, and even if it did during deserialization we wouldn't be able to tell which was which).

See CSharp122Tests.cs for sample code.

Generated at Wed Feb 07 21:35:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.