简体   繁体   中英

How can I use wcf serializer for serialize objects within mongodb c# driver?

I have a class that implement IBsonSerializer:

public class PersistentObject : IBsonSerializer
    {
        public object Id { get; set; }

        public object Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options)
        {
            throw new NotImplementedException();
        }

        public object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            throw new NotImplementedException();
        }

        public bool GetDocumentId(object document, out object id, out Type idNominalType, out IIdGenerator idGenerator)
        {
            throw new NotImplementedException();
        }

        public void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
        {
            throw new NotImplementedException();
        }

        public void SetDocumentId(object document, object id)
        {
            throw new NotImplementedException();
        }

    }

Is it possible to implement Serialize and Deserialize methods using WCF Serializer ?

You don't have to implement IBsonSerializer. MongoDB mapper can serialize your object. Take a look at http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial for more information and sample.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM