using System; using DPumpHydr.WinFrmUI.WenSkin.Json.Utilities; namespace DPumpHydr.WinFrmUI.WenSkin.Json.Serialization { /// /// Contract details for a used by the . /// public class JsonContainerContract : JsonContract { private JsonContract _itemContract; private JsonContract _finalItemContract; internal JsonContract ItemContract { get { return _itemContract; } set { _itemContract = value; if (_itemContract != null) { _finalItemContract = (_itemContract.UnderlyingType.IsSealed() ? _itemContract : null); } else { _finalItemContract = null; } } } internal JsonContract FinalItemContract => _finalItemContract; /// /// Gets or sets the default collection items . /// /// The converter. public JsonConverter ItemConverter { get; set; } /// /// Gets or sets a value indicating whether the collection items preserve object references. /// /// true if collection items preserve object references; otherwise, false. public bool? ItemIsReference { get; set; } /// /// Gets or sets the collection item reference loop handling. /// /// The reference loop handling. public ReferenceLoopHandling? ItemReferenceLoopHandling { get; set; } /// /// Gets or sets the collection item type name handling. /// /// The type name handling. public TypeNameHandling? ItemTypeNameHandling { get; set; } /// /// Initializes a new instance of the class. /// /// The underlying type for the contract. internal JsonContainerContract(Type underlyingType) : base(underlyingType) { JsonContainerAttribute cachedAttribute = JsonTypeReflector.GetCachedAttribute(underlyingType); if (cachedAttribute != null) { if (cachedAttribute.ItemConverterType != null) { ItemConverter = JsonTypeReflector.CreateJsonConverterInstance(cachedAttribute.ItemConverterType, cachedAttribute.ItemConverterParameters); } ItemIsReference = cachedAttribute._itemIsReference; ItemReferenceLoopHandling = cachedAttribute._itemReferenceLoopHandling; ItemTypeNameHandling = cachedAttribute._itemTypeNameHandling; } } } }