From f9cae9c4d8d999715440ec6a2c813f1f308bcbcf Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 19 Sep 2013 12:06:37 +0200 Subject: [PATCH] PublishedContent - align with v7, refactor IPropertyValueConverter --- .../PublishedContent/PublishedContentType.cs | 4 +- .../PublishedContent/PublishedPropertyBase.cs | 2 +- .../PublishedContent/PublishedPropertyType.cs | 99 ++++++++++--------- .../DatePickerValueConverter.cs | 12 +-- .../IPropertyValueConverter.cs | 32 +----- .../PropertyValueConverterBase.cs | 12 +-- .../PropertyEditors/TinyMceValueConverter.cs | 12 +-- .../PropertyEditors/YesNoValueConverter.cs | 12 +-- .../CodeFirst/StronglyTypedMapperTest.cs | 12 +-- src/Umbraco.Tests/LibraryTests.cs | 2 +- .../DynamicDocumentTestsBase.cs | 16 +-- .../PublishedContentMoreTests.cs | 2 +- .../PublishedContentTestBase.cs | 2 +- .../PublishedContentTestElements.cs | 2 +- .../PublishedContent/PublishedContentTests.cs | 10 +- .../XmlPublishedCache/XmlPublishedContent.cs | 2 +- 16 files changed, 86 insertions(+), 147 deletions(-) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index ad803ec09c..bfc1c456ca 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -48,8 +48,8 @@ namespace Umbraco.Core.Models.PublishedContent for (var i = 0; i < _propertyTypes.Length; i++) { var propertyType = _propertyTypes[i]; - _indexes[propertyType.Alias] = i; - _indexes[propertyType.Alias.ToLowerInvariant()] = i; + _indexes[propertyType.PropertyTypeAlias] = i; + _indexes[propertyType.PropertyTypeAlias.ToLowerInvariant()] = i; } } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs index 872efb0d46..ff8de68ff0 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.Models.PublishedContent public string Alias { - get { return PropertyType.Alias; } + get { return PropertyType.PropertyTypeAlias; } } // these have to be provided by the actual implementation diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index b3e884bf44..2ee0fd2b2d 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -18,13 +18,10 @@ namespace Umbraco.Core.Models.PublishedContent { public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType) { - // one control identified by its DataTypeGuid - // can be used to create several datatypes, identified by their DataTypeDefinitionId and supporting prevalues - // which can be used to create several property types, identified by their Id + // PropertyEditor [1:n] DataTypeDefinition [1:n] PropertyType ContentType = contentType; - Id = propertyType.Id; - Alias = propertyType.Alias; + PropertyTypeAlias = propertyType.Alias; DataTypeId = propertyType.DataTypeDefinitionId; PropertyEditorGuid = propertyType.DataTypeId; @@ -33,11 +30,10 @@ namespace Umbraco.Core.Models.PublishedContent } // for unit tests - internal PublishedPropertyType(string alias, Guid propertyEditorGuid, int propertyTypeId, int dataTypeDefinitionId) + internal PublishedPropertyType(string propertyTypeAlias, int dataTypeDefinitionId, Guid propertyEditorGuid) { // ContentType to be set by PublishedContentType when creating it - Id = propertyTypeId; - Alias = alias; + PropertyTypeAlias = propertyTypeAlias; DataTypeId = dataTypeDefinitionId; PropertyEditorGuid = propertyEditorGuid; @@ -47,27 +43,40 @@ namespace Umbraco.Core.Models.PublishedContent #region Property type - // gets the content type + /// + /// Gets or sets the published content type containing the property type. + /// // internally set by PublishedContentType constructor public PublishedContentType ContentType { get; internal set; } - // gets the property type id - public int Id { get; private set; } - - // gets the property alias - public string Alias { get; private set; } + /// + /// Gets or sets the alias uniquely identifying the property type. + /// + public string PropertyTypeAlias { get; private set; } + /// + /// Gets or sets the identifier uniquely identifying the data type supporting the property type. + /// public int DataTypeId { get; private set; } + // note: in v6 a property editor is uniquely identified by a guid, whereas in v7 + // it is uniquely identified by a string alias // fixme - compat? + + /// + /// Gets or sets the guid uniquely identifying the property editor for the property type. + /// public Guid PropertyEditorGuid { get; private set; } + /// + /// Gets or sets the alias uniquely identifying the property editor for the property type. + /// + public string PropertyEditorAlias { get; private set; } + #endregion #region Converters - private IPropertyValueConverter _sourceConverter; - private IPropertyValueConverter _objectConverter; - private IPropertyValueConverter _xpathConverter; + private IPropertyValueConverter _converter; private PropertyCacheLevel _sourceCacheLevel; private PropertyCacheLevel _objectCacheLevel; @@ -78,30 +87,26 @@ namespace Umbraco.Core.Models.PublishedContent var converters = PropertyValueConvertersResolver.Current.Converters.ToArray(); // fixme - get rid of the IPropertyValueEditorConverter support eventually - _sourceConverter = GetSingleConverterOrDefault(converters.Union(GetCompatConverters()), x => x.IsDataToSourceConverter(this), "data-to-source"); - _sourceCacheLevel = GetCacheLevel(_sourceConverter, PropertyCacheValue.Source); - - _objectConverter = GetSingleConverterOrDefault(converters, x => x.IsSourceToObjectConverter(this), "source-to-object"); - _objectCacheLevel = GetCacheLevel(_objectConverter, PropertyCacheValue.Object); - if (_objectCacheLevel < _sourceCacheLevel) - _objectCacheLevel = _sourceCacheLevel; // quietely fix the inconsistency, no need to throw - - _xpathConverter = GetSingleConverterOrDefault(converters, x => x.IsSourceToXPathConverter(this), "source-to-xpath"); - _objectCacheLevel = GetCacheLevel(_objectConverter, PropertyCacheValue.XPath); - if (_xpathCacheLevel < _sourceCacheLevel) - _xpathCacheLevel = _sourceCacheLevel; // quietely fix the inconsistency, no need to throw - } - - static IPropertyValueConverter GetSingleConverterOrDefault(IEnumerable converters, - Func predicate, string name) - { - IPropertyValueConverter result = null; - foreach (var converter in converters.Where(predicate)) + _converter = null; + foreach (var converter in converters.Union(GetCompatConverters()).Where(x => x.IsConverter(this))) { - if (result == null) result = converter; - else throw new InvalidOperationException("More than one " + name + " converter."); + if (_converter == null) + { + _converter = converter; + } + else + { + throw new InvalidOperationException(string.Format("More than one converter for property type {0}.{1}", + ContentType.Alias, PropertyTypeAlias)); + } } - return result; + + // get the cache levels, quietely fixing the inconsistencies (no need to throw, really) + _sourceCacheLevel = GetCacheLevel(_converter, PropertyCacheValue.Source); + _objectCacheLevel = GetCacheLevel(_converter, PropertyCacheValue.Object); + _objectCacheLevel = GetCacheLevel(_converter, PropertyCacheValue.XPath); + if (_objectCacheLevel < _sourceCacheLevel) _objectCacheLevel = _sourceCacheLevel; + if (_xpathCacheLevel < _sourceCacheLevel) _xpathCacheLevel = _sourceCacheLevel; } static PropertyCacheLevel GetCacheLevel(IPropertyValueConverter converter, PropertyCacheValue value) @@ -122,8 +127,8 @@ namespace Umbraco.Core.Models.PublishedContent public object ConvertDataToSource(object source, bool preview) { // use the converter else use dark (& performance-wise expensive) magic - return _sourceConverter != null - ? _sourceConverter.ConvertDataToSource(this, source, preview) + return _converter != null + ? _converter.ConvertDataToSource(this, source, preview) : ConvertUsingDarkMagic(source); } @@ -138,8 +143,8 @@ namespace Umbraco.Core.Models.PublishedContent { // use the converter if any // else just return the source value - return _objectConverter != null - ? _objectConverter.ConvertSourceToObject(this, source, preview) + return _converter != null + ? _converter.ConvertSourceToObject(this, source, preview) : source; } @@ -154,8 +159,8 @@ namespace Umbraco.Core.Models.PublishedContent public object ConvertSourceToXPath(object source, bool preview) { // use the converter if any - if (_xpathConverter != null) - return _xpathConverter.ConvertSourceToXPath(this, source, preview); + if (_converter != null) + return _converter.ConvertSourceToXPath(this, source, preview); // else just return the source value as a string or an XPathNavigator if (source == null) return null; @@ -207,7 +212,7 @@ namespace Umbraco.Core.Models.PublishedContent { return PropertyEditorValueConvertersResolver.HasCurrent ? PropertyEditorValueConvertersResolver.Current.Converters - .Where(x => x.IsConverterFor(PropertyEditorGuid, ContentType.Alias, Alias)) + .Where(x => x.IsConverterFor(PropertyEditorGuid, ContentType.Alias, PropertyTypeAlias)) .Select(x => new CompatConverter(x)) : Enumerable.Empty(); } @@ -221,7 +226,7 @@ namespace Umbraco.Core.Models.PublishedContent _converter = converter; } - public override bool IsDataToSourceConverter(PublishedPropertyType propertyType) + public override bool IsConverter(PublishedPropertyType propertyType) { return true; } diff --git a/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs index 155137ce21..4bd29c7658 100644 --- a/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors Guid.Parse(Constants.PropertyEditors.Date) }; - public override bool IsDataToSourceConverter(PublishedPropertyType propertyType) + public override bool IsConverter(PublishedPropertyType propertyType) { return DataTypeGuids.Contains(propertyType.PropertyEditorGuid); } @@ -42,18 +42,8 @@ namespace Umbraco.Core.PropertyEditors : DateTime.MinValue; } - public override bool IsSourceToObjectConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - // default ConvertSourceToObject just returns source ie a DateTime value - public override bool IsSourceToXPathConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - public override object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) { // source should come from ConvertSource and be a DateTime already diff --git a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs index 991ca86322..41d7dc7f7e 100644 --- a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs @@ -7,14 +7,12 @@ namespace Umbraco.Core.PropertyEditors /// public interface IPropertyValueConverter { - #region Data to Source - /// - /// Gets a value indicating whether the converter can convert from Data value to Source value. + /// Gets a value indicating whether the converter supports a property type. /// /// The property type. - /// A value indicating whether the converter can convert from Data value to Source value. - bool IsDataToSourceConverter(PublishedPropertyType propertyType); + /// A value indicating whether the converter supports a property type. + bool IsConverter(PublishedPropertyType propertyType); /// /// Converts a property Data value to a Source value. @@ -36,17 +34,6 @@ namespace Umbraco.Core.PropertyEditors /// object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview); - #endregion - - #region Source to Object - - /// - /// Gets a value indicating whether the converter can convert from Source value to Object value. - /// - /// The property type. - /// A value indicating whether the converter can convert from Source value to Object value. - bool IsSourceToObjectConverter(PublishedPropertyType propertyType); - /// /// Converts a property Source value to an Object value. /// @@ -59,17 +46,6 @@ namespace Umbraco.Core.PropertyEditors /// what to return in that case: either null, or the default value... object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview); - #endregion - - #region Source to XPath - - /// - /// Gets a value indicating whether the converter can convert from Source value to XPath value. - /// - /// The property type. - /// A value indicating whether the converter can convert from Source value to XPath value. - bool IsSourceToXPathConverter(PublishedPropertyType propertyType); - /// /// Converts a property Source value to an XPath value. /// @@ -88,7 +64,5 @@ namespace Umbraco.Core.PropertyEditors /// but should pay attention not to create infinite loops that would kill XPath and XSLT. /// object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview); - - #endregion } } diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index 5fd91168c0..3673c61197 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors /// class PropertyValueConverterBase : IPropertyValueConverter { - public virtual bool IsDataToSourceConverter(PublishedPropertyType propertyType) + public virtual bool IsConverter(PublishedPropertyType propertyType) { return false; } @@ -17,21 +17,11 @@ namespace Umbraco.Core.PropertyEditors return PublishedPropertyType.ConvertUsingDarkMagic(source); } - public virtual bool IsSourceToObjectConverter(PublishedPropertyType propertyType) - { - return false; - } - public virtual object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview) { return source; } - public virtual bool IsSourceToXPathConverter(PublishedPropertyType propertyType) - { - return false; - } - public virtual object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) { return source.ToString(); diff --git a/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs index ae48c60093..25e59eeea2 100644 --- a/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs @@ -12,7 +12,7 @@ namespace Umbraco.Core.PropertyEditors [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] internal class TinyMceValueConverter : PropertyValueConverterBase { - public override bool IsDataToSourceConverter(PublishedPropertyType propertyType) + public override bool IsConverter(PublishedPropertyType propertyType) { return Guid.Parse(Constants.PropertyEditors.TinyMCEv3).Equals(propertyType.PropertyEditorGuid); } @@ -25,22 +25,12 @@ namespace Umbraco.Core.PropertyEditors return source; } - public override bool IsSourceToObjectConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview) { // source should come from ConvertSource and be a string (or null) already return new HtmlString(source == null ? string.Empty : (string)source); } - public override bool IsSourceToXPathConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - public override object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) { // source should come from ConvertSource and be a string (or null) already diff --git a/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs index 7fc2a96873..5ee2db1961 100644 --- a/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] class YesNoValueConverter : PropertyValueConverterBase { - public override bool IsDataToSourceConverter(PublishedPropertyType propertyType) + public override bool IsConverter(PublishedPropertyType propertyType) { return Guid.Parse(Constants.PropertyEditors.TrueFalse).Equals(propertyType.PropertyEditorGuid); } @@ -24,18 +24,8 @@ namespace Umbraco.Core.PropertyEditors return sourceString == "1"; } - public override bool IsSourceToObjectConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - // default ConvertSourceToObject just returns source ie a boolean value - public override bool IsSourceToXPathConverter(PublishedPropertyType propertyType) - { - return IsDataToSourceConverter(propertyType); - } - public override object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) { // source should come from ConvertSource and be a boolean already diff --git a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs index 37a3d7c500..3913dabe52 100644 --- a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs +++ b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs @@ -77,12 +77,12 @@ namespace Umbraco.Tests.CodeFirst var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("siteDescription", Guid.Empty, 0, 0), - new PublishedPropertyType("siteName", Guid.Empty, 0, 0), - new PublishedPropertyType("articleContent", Guid.Empty, 0, 0), - new PublishedPropertyType("articleAuthor", Guid.Empty, 0, 0), - new PublishedPropertyType("articleDate", Guid.Empty, 0, 0), - new PublishedPropertyType("pageTitle", Guid.Empty, 0, 0), + new PublishedPropertyType("siteDescription", 0, Guid.Empty), + new PublishedPropertyType("siteName", 0, Guid.Empty), + new PublishedPropertyType("articleContent", 0, Guid.Empty), + new PublishedPropertyType("articleAuthor", 0, Guid.Empty), + new PublishedPropertyType("articleDate", 0, Guid.Empty), + new PublishedPropertyType("pageTitle", 0, Guid.Empty), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/LibraryTests.cs b/src/Umbraco.Tests/LibraryTests.cs index a61d39049e..4469a4f3ad 100644 --- a/src/Umbraco.Tests/LibraryTests.cs +++ b/src/Umbraco.Tests/LibraryTests.cs @@ -38,7 +38,7 @@ namespace Umbraco.Tests var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("content", Guid.Empty, 0, 0), + new PublishedPropertyType("content", 0, Guid.Empty), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index 2b8f6dd958..4f497a1613 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -35,14 +35,14 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("umbracoNaviHide", Guid.Empty, 0, 0), - new PublishedPropertyType("selectedNodes", Guid.Empty, 0, 0), - new PublishedPropertyType("umbracoUrlAlias", Guid.Empty, 0, 0), - new PublishedPropertyType("content", Guid.Parse(Constants.PropertyEditors.TinyMCEv3), 0, 0), - new PublishedPropertyType("testRecursive", Guid.Empty, 0, 0), - new PublishedPropertyType("siteTitle", Guid.Empty, 0, 0), - new PublishedPropertyType("creatorName", Guid.Empty, 0, 0), - new PublishedPropertyType("blah", Guid.Empty, 0, 0), // ugly error when that one is missing... + new PublishedPropertyType("umbracoNaviHide", 0, Guid.Empty), + new PublishedPropertyType("selectedNodes", 0, Guid.Empty), + new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty), + new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), + new PublishedPropertyType("testRecursive", 0, Guid.Empty), + new PublishedPropertyType("siteTitle", 0, Guid.Empty), + new PublishedPropertyType("creatorName", 0, Guid.Empty), + new PublishedPropertyType("blah", 0, Guid.Empty), // ugly error when that one is missing... }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index bc7a1b4ab8..3d7d12a45d 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -204,7 +204,7 @@ namespace Umbraco.Tests.PublishedContent var props = new[] { - new PublishedPropertyType("prop1", System.Guid.Empty, 1, 1), + new PublishedPropertyType("prop1", 1, System.Guid.Empty), }; var contentType1 = new PublishedContentType(1, "ContentType1", props); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index de887c8fd7..c888682113 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -26,7 +26,7 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("content", Guid.Parse(Constants.PropertyEditors.TinyMCEv3), 0, 0), + new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs index 0bd31838d2..437f5c003e 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs @@ -286,7 +286,7 @@ namespace Umbraco.Tests.PublishedContent class AutoPublishedContentType : PublishedContentType { - private static readonly PublishedPropertyType Default = new PublishedPropertyType("*", Guid.Empty, 0, 0); + private static readonly PublishedPropertyType Default = new PublishedPropertyType("*", 0, Guid.Empty); public AutoPublishedContentType(int id, string alias, IEnumerable propertyTypes) : base(id, alias, propertyTypes) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index e199e4df8b..ada63f7a80 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -50,11 +50,11 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("umbracoNaviHide", Guid.Parse(Constants.PropertyEditors.TrueFalse), 0, 0), - new PublishedPropertyType("selectedNodes", Guid.Empty, 0, 0), - new PublishedPropertyType("umbracoUrlAlias", Guid.Empty, 0, 0), - new PublishedPropertyType("content", Guid.Parse(Constants.PropertyEditors.TinyMCEv3), 0, 0), - new PublishedPropertyType("testRecursive", Guid.Empty, 0, 0), + new PublishedPropertyType("umbracoNaviHide", 0, Guid.Parse(Constants.PropertyEditors.TrueFalse)), + new PublishedPropertyType("selectedNodes", 0, Guid.Empty), + new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty), + new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), + new PublishedPropertyType("testRecursive", 0, Guid.Empty), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs index 16bb5be85c..c010f48d32 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs @@ -419,7 +419,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache _properties = _contentType.PropertyTypes.Select(p => { XmlNode n; - return propertyNodes.TryGetValue(p.Alias.ToLowerInvariant(), out n) + return propertyNodes.TryGetValue(p.PropertyTypeAlias.ToLowerInvariant(), out n) ? new XmlPublishedProperty(p, _isPreviewing, n) : new XmlPublishedProperty(p, _isPreviewing); }).Cast().ToArray();