From a56f3b23d13de1370eb201e04028757831f083cd Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 22 Apr 2019 11:58:51 +0200 Subject: [PATCH] Cleanup PublishedMember --- src/Umbraco.Web/Models/PublishedProperty.cs | 58 ------------------- .../PublishedCache/PublishedMember.cs | 5 +- src/Umbraco.Web/Umbraco.Web.csproj | 1 - 3 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 src/Umbraco.Web/Models/PublishedProperty.cs diff --git a/src/Umbraco.Web/Models/PublishedProperty.cs b/src/Umbraco.Web/Models/PublishedProperty.cs deleted file mode 100644 index f715df7450..0000000000 --- a/src/Umbraco.Web/Models/PublishedProperty.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Umbraco.Core.Models; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Web.Composing; - -namespace Umbraco.Web.Models -{ - public static class PublishedProperty - { - /// - /// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType. - /// - /// The published property types. - /// The properties. - /// A mapping function. - /// A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType - /// and taking values from the collection of Property. - /// Ensures that all conversions took place correctly. - internal static IEnumerable MapProperties( - IEnumerable propertyTypes, IEnumerable properties, - Func map) - { - var propertyEditors = Current.PropertyEditors; - var dataTypeService = Current.Services.DataTypeService; - - // TODO: not dealing with variants - // but the entire thing should die anyways - - return propertyTypes.Select(x => - { - var p = properties.SingleOrDefault(xx => xx.Alias == x.Alias); - var v = p == null || p.GetValue() == null ? null : p.GetValue(); - if (v != null) - { - var e = propertyEditors[x.EditorAlias]; - - // We are converting to string, even for database values which are integer or - // DateTime, which is not optimum. Doing differently would require that we have a way to tell - // whether the conversion to XML string changes something or not... which we don't, and we - // don't want to implement it as PropertyValueEditor.ConvertDbToXml/String should die anyway. - - // Don't think about improving the situation here: this is a corner case and the real - // thing to do is to get rig of PropertyValueEditor.ConvertDbToXml/String. - - // Use ConvertDbToString to keep it simple, although everywhere we use ConvertDbToXml and - // nothing ensures that the two methods are consistent. - - if (e != null) - v = e.GetValueEditor().ConvertDbToString(p.PropertyType, v, dataTypeService); - } - - return map(x, v); - }); - } - } -} diff --git a/src/Umbraco.Web/PublishedCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/PublishedMember.cs index eec973c182..08e00c1f17 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedMember.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedMember.cs @@ -35,16 +35,13 @@ namespace Umbraco.Web.PublishedCache // if they are not part of the member type properties - in which case they are created as // simple raw properties - which are completely invariant - var _properties = PublishedProperty.MapProperties(_publishedMemberType.PropertyTypes, _member.Properties, - (t, v) => new RawValueProperty(t, this, v ?? string.Empty)); - var properties = new List(); foreach (var propertyType in _publishedMemberType.PropertyTypes) { var property = _member.Properties[propertyType.Alias]; if (property == null) continue; - //properties.Add(new FooProperty(propertyType, this, property.Values)); + properties.Add(new RawValueProperty(propertyType, this, property.GetValue())); } EnsureMemberProperties(properties); _properties = properties.ToArray(); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 28337e6d2c..a190d6711c 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -775,7 +775,6 @@ -