简体   繁体   English

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

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

I have a class that implement IBsonSerializer: 我有一个实现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 ? 是否可以使用WCF序列化器实现序列化和反序列化方法?

You don't have to implement IBsonSerializer. 您不必实现IBsonSerializer。 MongoDB mapper can serialize your object. MongoDB映射器可以序列化您的对象。 Take a look at http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial for more information and sample. 有关更多信息和示例, 请访问http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用最新的 MongoDB C# 驱动程序根据多个条件删除复杂数组对象的嵌套数组中的元素? - How can I use latest MongoDB C# Driver to delete an element within a nested array of complex array objects based on multiple conditions? 如何使用MongoDB C#序列化器序列化值类型? - How do you serialize value types with MongoDB C# serializer? MongoDB C#驱动程序:如何将对象列表序列化为对象ID列表? - MongoDB c# driver: How to serialize a list of objects as a list of object ids? C#xml序列化程序 - 序列化派生对象 - C# xml serializer - serialize derived objects 我可以使用pongos与mongodb c#driver - can i use pocos with mongodb c# driver 使用C#MongoDB驱动程序,如何序列化对象引用的集合? - Using C# MongoDB Driver, how to serialize a collection of object referements? MongoDB C#驱动程序-序列化集合到接口 - MongoDB C# driver - Serialize collection to interface 如何在UWP应用中使用MongoDB C#驱动程序? - How do I use the MongoDB C# driver with a UWP app? 如何将MongoDB驱动程序与C#ASP.NET核心API框架一起使用? - How can I use the MongoDB Driver with C# ASP.NET Core API framework? 如何使用BsonClassMap更改MongoDB C#Driver类反序列化的方式? - How can I use BsonClassMap to change the way a MongoDB C# Driver class is deserialized?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM