4 Commits (950b293fcd524b24102860272fe45d8501bab587)

Author SHA1 Message Date
saleemjavid 950b293fcd The changes for ShouldSerializeXXX implementation 14 years ago
rstam 1a730b60c7 Fixed CSHARP-198. Save now works with composite Id (including polymorphic Ids). GetDocumentId now has an additional out parameter for idNominalType. 15 years ago
rstam 3a5077fdf4 Fixed CSHARP-182. Correctly deserialize an object array. 15 years ago
rstam 6f9e959f54 Second round of namespace refactoring. Removed the MongoDB.Bson.DefaultSerializer namespace and moved everything from it into the MongoDB.Bson.Serialization namespace or one of its child namespaces (Attributes, Conventions or Options). The goal here is to unify serialization under the MongoDB.Bson.Serialization namespace and that the most common uses of serialization require only a single using statement for the top level namespace. A secondary goal is to organize the namespace hierarchy a little better as presented in the help file. 15 years ago
rstam e6ee37289d Added doc comments for BsonClassMapSerializer, BsonDefaultSerializer and BsonMemberMap. 15 years ago
rstam 2569f6bb41 Added doc comments to all the implementations of the IBsonSerializer methods. 15 years ago
rstam 368990e892 When a BsonMemberMap has an explicit serializer it will be used no matter what the actualType is. 15 years ago
rstam c4dd46d35d Added BsonExtraElementsAttribute and ExtraElementsMemberConvention classes. Added ExtraElementMemberMap property and several ExtraElements related methods to BsonClassMap. Modified BsonClassMapSerializer to handle extra elements. 15 years ago
rstam b552f5e394 Updated copyright notices. 15 years ago
rstam 8d1d29365e Renamed many Singleton properties to Instance. This is more in line with typical .NET names, and many of these classes didn't need to be singletons anyway, we just want a handy precreated instance available for sharing. 15 years ago
rstam 5e6174bdc7 Fixed CSHARP-140. We now never serialize a discriminator for anonymous classes or wrapped objects (with the exception of Update.Replace). 15 years ago
rstam 94c2a55df1 Fixed CSHARP-133. [BsonDefaultValue(null, SerializeDefaultValue = false)] works just like [BsonIgnoreIfNull]. 15 years ago
rstam eb87b92c72 Moved serialization options from a field of the serializers to a parameter of Serialize and Deserialize. Replaced serializeIdFirst with DocumentSerializationOptions (serializeIdFirst can be though of as a serialization option that applies to documents). This change cuts down on the number of serializers that have to be created and registered. While a relatively small change conceptually it affected a huge number of lines of code. 15 years ago
rstam c71e88a564 Implemented GetLastErrorResult. Moved implementation of IdGenerators from DefaultSerializer to Serializer because they have to work with BsonDocument even if the DefaultSerializer is never invoked. Shortened BsonIdGenerator to IdGenerator. Added ZeroIdChecker<T> where T : struct to check that struct Ids are not all zeros. LookupIdGenerator now defaults to NullIdChecker for reference types and ZeroIdChecker for value types. 15 years ago
rstam 222235e593 Oops. Need to call RegisterDiscriminator from RegisterClassMap (Freeze is too late). 15 years ago
rstam 404bea2a74 Fixed CSHARP-101. Save now works correctly with or without an IdGenerator. Replaced DocumentHasIdMember/DocumentHasIdValue with GetDocumentId and GenerateDocumentId with SetDocumentId. The whole logic around using IdGenerators should be easier to follow and be more robust now. 15 years ago
rstam 054de614b4 Added an overload of Deserialize that takes two type parameters (nominalType and actualType). The presence of the actualType parameter implies that the discriminator convention has already looked at the input and determined the actual type. In some situations this allows us to not call GetActualType twice, thus improving performance. 15 years ago
rstam 9b187785dc Modified CurrentBsonType in BsonBinaryReader to return BsonType.Document when ReadState is Initial, Done or ScopeDocument. Modified Deserialize for Int64 to succeed when actual value is an Int32. 15 years ago
rstam 67b80eac29 When Serialize calls LookupDiscriminatorConvention it should look up the convention for the nominalType not the actualType. 15 years ago
rstam 957f91ded8 Added DeserializeMember method to refactor some code out into this method. 15 years ago
rstam c047dde798 Added MagicDiscriminatorConvention sample. It shows how to use a discriminator convention to figure out the actual type by looking at the names of the elements present (so no _t element is needed). 15 years ago
rstam 8e7a944581 This commit is about simplifying serialization and improving performance at the same time. At the lowest level, the API for BsonReader and BsonWriter has changed to support the higher level changes. The DeserializeDocument/DeserializeElement and SerializeDocument/SerializeElement paired methods have been simplified to just Deserialize and Serialize. Similarly, the GetActualDocumentType/GetActualElementType paired methods in IDiscriminatorConvention have been simplified to a single GetActualType method. The HasElement methods in BsonReader have been removed because using them resulted in BsonTypes and Names being read twice. The support for bookmarks in BsonReader has been decoupled from the context stack. BsonWriter now allows the Name to be written before the BsonType is known (in the BSON binary form the BsonType comes before the Name) and delays physically writing the name to the BSON output stream until the value is written at which point the BsonType is known. 15 years ago
rstam 2dec3ca8f9 Fixed CSHARP-92. If there is no IIdGenerator for a particular type the driver will just leave the Id value alone (so it's up to the client code to generate unique Ids). 15 years ago
rstam 0444845fe4 Changes to get serialization of structs to work. Some tests are still failing in deserialization (resolution pending). 15 years ago
rstam 2cebee144e Finished implementing HierarchicalDiscriminatorConvention. Added IsRootClass and HasRootClass to BsonClassMap and added RootClass to BsonDiscriminatorAttribute. Changed DeserializeDocument in ObjectSerializer to look at the discriminator and delegate the deserialization to the serializer for the actual type. Changed the BsonKnownTypeAttribute to plural to allow specifying multiple known types in one attribute. 15 years ago
rstam c45d4d052d Relax the restriction that a class must have a public default constructor in order to be deserialized (now a default constructor, public or private, will be used if it exists, otherwise FormatterServices.GetUninitializedObject will be used to create a zero filled instance). 15 years ago
rstam 748dfb3468 Added DiscriminatorConventions to allow more flexibility in how discriminators are used. Includes partial support for hierarchical discriminators (but a little more work is required to know when hierarchical discriminators should be used and where the hierarchy should be rooted). 15 years ago
rstam 97aa952f5b Added support for Guid primitive type to EnumerableSerializer. Changed EnumerableSerializerTests to test properties of type ArrayList, ICollection and IEnumerable as well as IList. 15 years ago
rstam d13dda9efb Implemented EnumerableSerializer (serializes ArrayList, IEnumerable, ICollection and IList). Factored out GetActualDocumentType and GetActualElementType as static methods that can be called as needed from anywhere. Use BsonType as implied discriminator for primitive types. Fixed references to deprecated BsonConstants. 15 years ago
rstam 9c250395d0 Replaced UseCompactRepresentation with a more general mechanism based on serialization options. Added BsonRepresentationAttribute. Serializers are now registered using a combined type/options key because the serialization options are stored in the serializer instance. 15 years ago
Testo 7f61ec789c - performance improvement 15 years ago
craiggwilson d21bd9f8e2 completed changes to accomodate fields as well as properties. 15 years ago
craiggwilson 2bbf0bdeb8 changed all implementations to use MemberInfo instead of PropertyInfo. 15 years ago
rstam ef50bbefa1 Fixed CSHARP-78. Default UseCompactRepresentation to true for primitive properties. Added PushBookmark and PopBookmark to BsonReader to support reading ahead. Fixed handling of discriminators in BsonClassMapSerializer. FindString in BsonReader now actually moves the position (use bookmarks now to read ahead). 15 years ago
rstam 5024e87639 Changed BsonIdAttribute to take optional IdGenerator parameter. Changed PropertyMap to allow customizing the Id generator for a property. 15 years ago
rstam 0999243603 Fixed CSHARP-77 by improving Id detection algorithm but also by fixing how documents without an Id property are handled. Added DocumentHasIdProperty, DocumentHasIdValue and GenerateDocumentId to IBsonSerializer and IBsonSerializable. Added new IBsonIdGenerator interface and registration/lookup methods for Id generators to BsonSerializer. Implemented Id generators for ObjectId and Guid. Moved lots of common code to BuilderBase. Fixed Insert and Save methods to properly detect and/or assign Ids to documents. 15 years ago
rstam 3900d3f0db Renamed MongoDB.BsonLibrary namespace to MongoDB.Bson and MongoDB.CSharpDriver to MongoDB.Driver (Library was redundant and VB users might not want to see CSharp in the namespace). Renamed Bson static class BsonConstants (because it a class can't have the same name as the namespace it is in). 15 years ago
rstam f7a8b726a6 Added BsonBaseSerializer to cut down on amount of duplicated code. Added AssignId to IBsonSerializer and IBsonSerializable. Used new AssignId method in MongoCollection InsertBatch and Save methods (so now they can assign an Id to any class not just BsonDocument). 15 years ago
rstam a9e03720f6 Implemented serialization of arrays. Renamed BsonDefaultSerializer to BsonClassMapSerializer because it only works with class maps and is not the default in all situations. 15 years ago
rstam 923bdf58d8 Major overhaul of serialization machinery to support plugging in a new serialization provider. The default serialization support has been restructured as a plugin. See IBsonSerializationProvider and IBsonSerializer (as well as the BsonSerializer static class that handles registration and routing of serializers). 15 years ago