Allow IPropertyValueConverter to determine if a property has value

This commit is contained in:
Stephan
2018-07-16 19:14:00 +02:00
parent 2051caaa01
commit 05317bb5e6
6 changed files with 40 additions and 25 deletions

View File

@@ -77,7 +77,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// <summary>
/// Gets the published content type containing the property type.
/// </summary>
/// </summary>
public PublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor
/// <summary>
@@ -193,6 +193,20 @@ namespace Umbraco.Core.Models.PublishedContent
_modelClrType = _converter == null ? typeof (object) : _converter.GetPropertyValueType(this);
}
/// <summary>
/// Determines whether a source value is an actual value, or not a value.
/// </summary>
/// <remarks>Used by property.HasValue and, for instance, in fallback scenarios.</remarks>
public bool IsValue(object value)
{
// if we have a converter, use the converter,
// otherwise use the old magic null & string comparisons
return _converter == null
? value != null && (!(value is string) || string.IsNullOrWhiteSpace((string) value) == false)
: _converter.IsValue(value);
}
/// <summary>
/// Gets the property cache level.
/// </summary>