コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StringSerializerBackedJsonConverter"/> class.
        /// </summary>
        /// <param name="registeredType">The type that the converter is registered for.</param>
        /// <param name="backingSerializer">The backing serializer.</param>
        /// <param name="canConvertTypeMatchStrategy">OPTIONAL strategy to use to match the incoming type-to-consider with <paramref name="registeredType"/>.  DEFAULT is match when the types are equal.</param>
        public StringSerializerBackedJsonConverter(
            Type registeredType,
            IStringSerializeAndDeserialize backingSerializer,
            CanConvertTypeMatchStrategy canConvertTypeMatchStrategy = CanConvertTypeMatchStrategy.TypeToConsiderEqualsRegisteredType)
        {
            if (registeredType == null)
            {
                throw new ArgumentNullException(nameof(registeredType));
            }

            if (backingSerializer == null)
            {
                throw new ArgumentNullException(nameof(backingSerializer));
            }

            this.RegisteredType              = registeredType;
            this.BackingSerializer           = backingSerializer;
            this.CanConvertTypeMatchStrategy = canConvertTypeMatchStrategy;
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StringSerializerBackedJsonConverter{T}"/> class.
 /// </summary>
 /// <param name="backingSerializer">The backing serializer.</param>
 /// <param name="canConvertTypeMatchStrategy">OPTIONAL strategy to use to match the incoming type-to-consider with <typeparamref name="T"/>.  DEFAULT is match when the types are equal.</param>
 public StringSerializerBackedJsonConverter(
     IStringSerializeAndDeserialize backingSerializer,
     CanConvertTypeMatchStrategy canConvertTypeMatchStrategy = CanConvertTypeMatchStrategy.TypeToConsiderEqualsRegisteredType)
     : base(typeof(T), backingSerializer, canConvertTypeMatchStrategy)
 {
 }