Exemplo n.º 1
0
        /// <summary>
        /// Gets the <see cref="BsonSerializationConfigurationType"/> corresponding to the specified configuration type.
        /// </summary>
        /// <param name="bsonSerializationConfigurationType">The type of the BSON serialization configuration.</param>
        /// <returns>
        /// The <see cref="BsonSerializationConfigurationType"/> corresponding to the specified configuration type.
        /// </returns>
        public static BsonSerializationConfigurationType ToBsonSerializationConfigurationType(
            this Type bsonSerializationConfigurationType)
        {
            var result = new BsonSerializationConfigurationType(bsonSerializationConfigurationType);

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ObcBsonSerializer"/> class.
        /// </summary>
        /// <param name="bsonSerializationConfigurationType">Optional <see cref="BsonSerializationConfigurationBase"/> implementation to use; default is <see cref="NullBsonSerializationConfiguration"/>.</param>
        public ObcBsonSerializer(
            BsonSerializationConfigurationType bsonSerializationConfigurationType = null)
            : base(bsonSerializationConfigurationType ?? typeof(NullBsonSerializationConfiguration).ToBsonSerializationConfigurationType())
        {
            this.bsonSerializationConfiguration = (BsonSerializationConfigurationBase)this.SerializationConfiguration;

            this.SerializerRepresentation = new SerializerRepresentation(SerializationKind.Bson, bsonSerializationConfigurationType?.ConcreteSerializationConfigurationDerivativeType.ToRepresentation());
        }
        /// <inheritdoc />
        public bool Equals(BsonSerializationConfigurationType <T> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            var result = this.ConcreteSerializationConfigurationDerivativeType == other.ConcreteSerializationConfigurationDerivativeType;

            return(result);
        }