public void ConverterList() { ConverterList <object> l1 = new ConverterList <object>(); l1.Add(new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc)); l1.Add(new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc)); string json = JsonConvert.SerializeObject(l1, Formatting.Indented); StringAssert.AreEqual(@"[ new Date( 976651800000 ), new Date( 434589000000 ) ]", json); ConverterList <object> l2 = JsonConvert.DeserializeObject <ConverterList <object> >(json); Assert.IsNotNull(l2); Assert.AreEqual(new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc), l2[0]); Assert.AreEqual(new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc), l2[1]); }
/// <summary> /// Copies the options from a <see cref="JsonSerializerOptions"/> instance to a new instance. /// </summary> /// <param name="options">The <see cref="JsonSerializerOptions"/> instance to copy options from.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="options"/> is <see langword="null"/>. /// </exception> public JsonSerializerOptions(JsonSerializerOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _memberAccessorStrategy = options._memberAccessorStrategy; _dictionaryKeyPolicy = options._dictionaryKeyPolicy; _jsonPropertyNamingPolicy = options._jsonPropertyNamingPolicy; _readCommentHandling = options._readCommentHandling; _referenceHandler = options._referenceHandler; _encoder = options._encoder; _defaultIgnoreCondition = options._defaultIgnoreCondition; _defaultBufferSize = options._defaultBufferSize; _maxDepth = options._maxDepth; _allowTrailingCommas = options._allowTrailingCommas; _ignoreNullValues = options._ignoreNullValues; _ignoreReadOnlyProperties = options._ignoreReadOnlyProperties; _ignoreReadonlyFields = options._ignoreReadonlyFields; _includeFields = options._includeFields; _propertyNameCaseInsensitive = options._propertyNameCaseInsensitive; _writeIndented = options._writeIndented; Converters = new ConverterList(this, (ConverterList)options.Converters); EffectiveMaxDepth = options.EffectiveMaxDepth; // _classes is not copied as sharing the JsonClassInfo and JsonPropertyInfo caches can result in // unnecessary references to type metadata, potentially hindering garbage collection on the source options. // _haveTypesBeenCreated is not copied; it's okay to make changes to this options instance as (de)serialization has not occurred. }
static bool CompareConverters(ConverterList left, ConverterList right) { int n; if ((n = left.Count) != right.Count) { return(false); } for (int i = 0; i < n; i++) { if (left[i] != right[i]) { return(false); } } return(true); }
public BinarySerializerOptions(BinarySerializerOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _memberAccessorStrategy = options._memberAccessorStrategy; _defaultIgnoreCondition = options._defaultIgnoreCondition; _defaultBufferSize = options._defaultBufferSize; _ignoreNullValues = options._ignoreNullValues; _ignoreReadOnlyProperties = options._ignoreReadOnlyProperties; _ignoreReadonlyFields = options._ignoreReadonlyFields; _includeFields = options._includeFields; _propertyNameCaseInsensitive = options._propertyNameCaseInsensitive; Converters = new ConverterList(this, (ConverterList)options.Converters); EffectiveMaxDepth = options.EffectiveMaxDepth; }
/// <summary> /// Constructs a new <see cref="JsonSerializerOptions"/> instance. /// </summary> public JsonSerializerOptions() { _converters = new ConverterList(this); TrackOptionsInstance(this); }
/// <summary> /// Constructs a new <see cref="JsonSerializerOptions"/> instance. /// </summary> public JsonSerializerOptions() { Converters = new ConverterList(this); }
public ConverterListEntity(ConverterList converterList, IEnumerable <ConverterEntity> converters) { Id = converterList.Id; DisplayName = converterList.DisplayName; Converters = converters.ToList(); }
public BinarySerializerOptions() { Converters = new ConverterList(this); }