From 89c5d5d61360f6fee47018326a14d53ebff871d3 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 28 Oct 2013 01:00:51 +0100 Subject: [PATCH 1/2] PublishedContent - get published properties to report the CLR type of the value --- .../Models/PublishedContent/PublishedPropertyType.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 554b6bcfa8..1f7c6ef0ce 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -82,6 +82,8 @@ namespace Umbraco.Core.Models.PublishedContent private PropertyCacheLevel _objectCacheLevel; private PropertyCacheLevel _xpathCacheLevel; + private Type _clrType = typeof (object); + private void InitializeConverters() { var converters = PropertyValueConvertersResolver.Current.Converters.ToArray(); @@ -107,6 +109,13 @@ namespace Umbraco.Core.Models.PublishedContent _objectCacheLevel = GetCacheLevel(_converter, PropertyCacheValue.XPath); if (_objectCacheLevel < _sourceCacheLevel) _objectCacheLevel = _sourceCacheLevel; if (_xpathCacheLevel < _sourceCacheLevel) _xpathCacheLevel = _sourceCacheLevel; + + if (_converter != null) + { + var attr = _converter.GetType().GetCustomAttribute(false); + if (attr != null) + _clrType = attr.Type; + } } static PropertyCacheLevel GetCacheLevel(IPropertyValueConverter converter, PropertyCacheValue value) @@ -202,6 +211,9 @@ namespace Umbraco.Core.Models.PublishedContent return source; } + // gets the property CLR type + public Type ClrType { get { return _clrType; } } + #endregion #region Compat From 767719357e2055f4820c5678754d2b1080133f9e Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 31 Oct 2013 18:28:02 +0100 Subject: [PATCH 2/2] U4-3279 - better exception message when failing to find a content type --- .../Models/PublishedContent/PublishedContentType.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index 773da45ccf..91532fdaad 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -145,6 +145,10 @@ namespace Umbraco.Core.Models.PublishedContent ? (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias) : (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias); + if (contentType == null) + throw new Exception(string.Format("ContentTypeService failed to find a {0} type with alias \"{1}\".", + itemType.ToString().ToLower(), alias)); + return new PublishedContentType(contentType); }