GetValue - *always* check the PropertyValueConverters

Even if we want a string and the value is already a string, we should still hit the PropertyValueConverters for situations like the RTE's PVC, which performs parsing on the content.
This commit is contained in:
Tom Fulton
2014-04-28 23:39:32 -06:00
parent 4ad88a04e5
commit 7a71afda0e
@@ -28,9 +28,6 @@ namespace Archetype.Umbraco.Models
public T GetValue<T>()
{
// If the value is of type T, just return it
if (Value is T)
return (T)Value;
// Try Umbraco's PropertyValueConverters
var converters = UmbracoContext.Current != null ? PropertyValueConvertersResolver.Current.Converters : Enumerable.Empty<IPropertyValueConverter>();
@@ -41,6 +38,10 @@ namespace Archetype.Umbraco.Models
return convertedAttempt.Result;
}
// If the value is of type T, just return it
if (Value is T)
return (T)Value;
// No PropertyValueConverters matched, so try a regular type conversion
var convertAttempt2 = Value.TryConvertTo<T>();
if (convertAttempt2.Success)