/// <summary> /// Initializes a new instance of the <see cref="JsonContainerContract"/> class. /// </summary> /// <param name="underlyingType">The underlying type for the contract.</param> internal JsonContainerContract(Type underlyingType) : base(underlyingType) { JsonContainerAttribute jsonContainerAttribute = JsonTypeReflector.GetJsonContainerAttribute(underlyingType); if (jsonContainerAttribute != null) { if (jsonContainerAttribute.ItemConverterType != null) { ItemConverter = JsonConverterAttribute.CreateJsonConverterInstance(jsonContainerAttribute.ItemConverterType); } ItemIsReference = jsonContainerAttribute._itemIsReference; ItemReferenceLoopHandling = jsonContainerAttribute._itemReferenceLoopHandling; ItemTypeNameHandling = jsonContainerAttribute._itemTypeNameHandling; } }
private void InitializeContract(JsonContract contract) { JsonContainerAttribute containerAttribute = JsonTypeReflector.GetJsonContainerAttribute(contract.NonNullableUnderlyingType); if (containerAttribute != null) { contract.IsReference = containerAttribute._isReference; } #if !PocketPC && !NET20 else { DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType); // doesn't have a null value if (dataContractAttribute != null && dataContractAttribute.IsReference) { contract.IsReference = true; } } #endif contract.Converter = ResolveContractConverter(contract.NonNullableUnderlyingType); // then see whether object is compadible with any of the built in converters contract.InternalConverter = JsonSerializer.GetMatchingConverter(BuiltInConverters, contract.NonNullableUnderlyingType); if (ReflectionUtils.HasDefaultConstructor(contract.CreatedType, true) || contract.CreatedType.IsValueType()) { contract.DefaultCreator = GetDefaultCreator(contract.CreatedType); contract.DefaultCreatorNonPublic = (!contract.CreatedType.IsValueType() && ReflectionUtils.GetDefaultConstructor(contract.CreatedType) == null); } ResolveCallbackMethods(contract, contract.NonNullableUnderlyingType); }