Esempio n. 1
0
        /// <summary>
        /// Gets the <see cref="JsonSerializationConfigurationType"/> corresponding to the specified configuration type.
        /// </summary>
        /// <param name="jsonSerializationConfigurationType">The type of the JSON serialization configuration.</param>
        /// <returns>
        /// The <see cref="JsonSerializationConfigurationType"/> corresponding to the specified configuration type.
        /// </returns>
        public static JsonSerializationConfigurationType ToJsonSerializationConfigurationType(
            this Type jsonSerializationConfigurationType)
        {
            var result = new JsonSerializationConfigurationType(jsonSerializationConfigurationType);

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ObcJsonSerializer"/> class.
        /// </summary>
        /// <param name="jsonSerializationConfigurationType">Optional type of configuration to use; DEFAULT is none.</param>
        public ObcJsonSerializer(
            JsonSerializationConfigurationType jsonSerializationConfigurationType = null)
            : base(jsonSerializationConfigurationType ?? typeof(NullJsonSerializationConfiguration).ToJsonSerializationConfigurationType())
        {
            this.jsonSerializationConfiguration = (JsonSerializationConfigurationBase)this.SerializationConfiguration;

            if (this.jsonSerializationConfiguration.JsonFormattingKind == JsonFormattingKind.Invalid)
            {
                throw new ArgumentOutOfRangeException(Invariant($"'{nameof(this.jsonSerializationConfiguration.JsonFormattingKind)}' == '{JsonFormattingKind.Invalid}'"), (Exception)null);
            }

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

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

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

            return(result);
        }