/// <summary> /// Converts the intermediate value into the object value. /// </summary> /// <param name="owner">The published element owning the property.</param> /// <param name="referenceCacheLevel">The reference cache level.</param> /// <param name="inter">The intermediate value.</param> /// <param name="preview">A value indicating whether content should be considered draft.</param> /// <returns>The object value.</returns> public object ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (!_initialized) { Initialize(); } // use the converter if any, else just return the inter value return(_converter != null ? _converter.ConvertIntermediateToObject(owner, this, referenceCacheLevel, inter, preview) : inter); }
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { var value = _baseValueConverter.ConvertIntermediateToObject(owner, propertyType, referenceCacheLevel, inter, preview); var clrType = propertyType.ClrType; bool allowsMultiple = clrType.IsIEnumerable(); var modelType = allowsMultiple == true?clrType.GetInnerType() : clrType; var castItems = CastSourceToList(value, modelType); return(allowsMultiple == true ? castItems : castItems.FirstOrNull()); }