如何在mongodb c#驱动程序中使用wcf序列化程序来序列化对象?

时间:2011-12-14 05:09:10

标签: c# mongodb serializer

我有一个实现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();
        }

    }

是否可以使用 WCF Serializer 实现Serialize和Deserialize方法?

1 个答案:

答案 0 :(得分:0)

您不必实施IBsonSerializer。 MongoDB映射器可以序列化您的对象。请查看http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial以获取更多信息和样本。