MongoDB.Bson.Serialization.Serializers.InterfaceSerializer.Deserialize C# (CSharp) Method

Deserialize() public method

Deserializes a document from a BsonReader.
public Deserialize ( MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options ) : object
bsonReader MongoDB.Bson.IO.BsonReader The BsonReader.
nominalType System.Type The nominal type of the document.
actualType System.Type The actual type of the document..
options IBsonSerializationOptions The serialization options.
return object
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            if (!nominalType.IsInterface)
            {
                var message = string.Format("Nominal type must be an interface, not {0}.", nominalType.FullName);
                throw new ArgumentException(message, "nominalType");
            }

            if (actualType == nominalType)
            {
                var message = string.Format("Unable to determine actual type of object to deserialize. NominalType is the interface {0}.", nominalType);
                throw new Exception(message);
            }

            var serializer = BsonSerializer.LookupSerializer(actualType);
            return serializer.Deserialize(bsonReader, nominalType, actualType, options);
        }

Same methods

InterfaceSerializer::Deserialize ( MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options ) : object