diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs index 46f1aaf05e..db6dc4d88d 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.Models.PublishedContent /// cached preview (so, maybe unpublished) content. A better name would therefore be ICachedContent, as /// has been suggested. However, can't change now. Maybe in v7? /// - public interface IPublishedContent : IPropertySet + public interface IPublishedContent : IPublishedElement { #region Content diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs index 7eb8909878..350e5970eb 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs @@ -14,7 +14,7 @@ namespace Umbraco.Core.Models.PublishedContent /// The original property set. /// The strongly-typed model representing the property set, or the property set /// itself it the factory has no model for that content type. - IPropertySet CreateModel(IPropertySet set); + IPublishedElement CreateModel(IPublishedElement set); /// /// Gets the model type map. diff --git a/src/Umbraco.Core/Models/PublishedContent/IPropertySet.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs similarity index 93% rename from src/Umbraco.Core/Models/PublishedContent/IPropertySet.cs rename to src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs index c2cf806c0b..45dcbd7c78 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPropertySet.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; namespace Umbraco.Core.Models.PublishedContent { /// - /// Represents a facade property set. + /// Represents a published element. /// - public interface IPropertySet + public interface IPublishedElement { #region ContentType @@ -17,7 +17,7 @@ namespace Umbraco.Core.Models.PublishedContent #endregion - #region PropertySet + #region PublishedElement /// /// Gets the unique key of the facade item. diff --git a/src/Umbraco.Core/Models/PublishedContent/NoopPublishedContentModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/NoopPublishedContentModelFactory.cs index 16cd3a69d1..8264af9eb0 100644 --- a/src/Umbraco.Core/Models/PublishedContent/NoopPublishedContentModelFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/NoopPublishedContentModelFactory.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.Models.PublishedContent { public class NoopPublishedContentModelFactory : IPublishedContentModelFactory { - public IPropertySet CreateModel(IPropertySet set) + public IPublishedElement CreateModel(IPublishedElement set) => set; public Dictionary ModelTypeMap { get; } = new Dictionary(); diff --git a/src/Umbraco.Core/Models/PublishedContent/PropertySetModel.cs b/src/Umbraco.Core/Models/PublishedContent/PropertySetModel.cs deleted file mode 100644 index ee087128ff..0000000000 --- a/src/Umbraco.Core/Models/PublishedContent/PropertySetModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Umbraco.Core.Models.PublishedContent -{ - /// - /// Represents a strongly-typed property set. - /// - /// Every strongly-typed property set class should inherit from PropertySetModel - /// (or inherit from a class that inherits from... etc.) so they are picked by the factory. - public class PropertySetModel : PropertySetWrapped - { - /// - /// Initializes a new instance of the class with - /// an original instance. - /// - /// The original content. - protected PropertySetModel(IPropertySet content) - : base(content) - { } - } -} diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs index c04aa7116a..cc6ac093b4 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.Models.PublishedContent private class ModelInfo { public Type ParameterType { get; set; } - public Func Ctor { get; set; } + public Func Ctor { get; set; } public Type ModelType { get; set; } } @@ -37,7 +37,7 @@ namespace Umbraco.Core.Models.PublishedContent /// public PublishedContentModelFactory(IEnumerable types) { - var ctorArgTypes = new[] { typeof(IPropertySet) }; + var ctorArgTypes = new[] { typeof(IPublishedElement) }; var modelInfos = new Dictionary(StringComparer.InvariantCultureIgnoreCase); ModelTypeMap = new Dictionary(StringComparer.InvariantCultureIgnoreCase); @@ -50,17 +50,17 @@ namespace Umbraco.Core.Models.PublishedContent foreach (var ctor in type.GetConstructors()) { var parms = ctor.GetParameters(); - if (parms.Length == 1 && typeof (IPropertySet).IsAssignableFrom(parms[0].ParameterType)) + if (parms.Length == 1 && typeof (IPublishedElement).IsAssignableFrom(parms[0].ParameterType)) { if (constructor != null) - throw new InvalidOperationException($"Type {type.FullName} has more than one public constructor with one argument of type, or implementing, IPropertySet."); + throw new InvalidOperationException($"Type {type.FullName} has more than one public constructor with one argument of type, or implementing, IPublishedElement."); constructor = ctor; parameterType = parms[0].ParameterType; } } if (constructor == null) - throw new InvalidOperationException($"Type {type.FullName} is missing a public constructor with one argument of type, or implementing, IPropertySet."); + throw new InvalidOperationException($"Type {type.FullName} is missing a public constructor with one argument of type, or implementing, IPublishedElement."); var attribute = type.GetCustomAttribute(false); // fixme rename FacadeModelAttribute var typeName = attribute == null ? type.Name : attribute.ContentTypeAlias; @@ -75,12 +75,12 @@ namespace Umbraco.Core.Models.PublishedContent // much faster with a dynamic method but potential MediumTrust issues - which we don't support // here http://stackoverflow.com/questions/16363838/how-do-you-call-a-constructor-via-an-expression-tree-on-an-existing-object - var meth = new DynamicMethod(string.Empty, typeof(IPropertySet), ctorArgTypes, type.Module, true); + var meth = new DynamicMethod(string.Empty, typeof(IPublishedElement), ctorArgTypes, type.Module, true); var gen = meth.GetILGenerator(); gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Newobj, constructor); gen.Emit(OpCodes.Ret); - var func = (Func) meth.CreateDelegate(typeof (Func)); + var func = (Func) meth.CreateDelegate(typeof (Func)); // fast enough and works in MediumTrust - but we don't // read http://boxbinary.com/2011/10/how-to-run-a-unit-test-in-medium-trust-with-nunitpart-three-umbraco-framework-testing/ @@ -96,7 +96,7 @@ namespace Umbraco.Core.Models.PublishedContent _modelInfos = modelInfos.Count > 0 ? modelInfos : null; } - public IPropertySet CreateModel(IPropertySet set) + public IPublishedElement CreateModel(IPublishedElement set) { // fail fast if (_modelInfos == null) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedElementModel.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedElementModel.cs new file mode 100644 index 0000000000..e0514b38d7 --- /dev/null +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedElementModel.cs @@ -0,0 +1,21 @@ +namespace Umbraco.Core.Models.PublishedContent +{ + /// + /// + /// Represents a strongly-typed published element. + /// + /// Every strongly-typed property set class should inherit from PublishedElementModel + /// (or inherit from a class that inherits from... etc.) so they are picked by the factory. + public class PublishedElementModel : PublishedElementWrapped + { + /// + /// + /// Initializes a new instance of the class with + /// an original instance. + /// + /// The original content. + protected PublishedElementModel(IPublishedElement content) + : base(content) + { } + } +} diff --git a/src/Umbraco.Core/Models/PublishedContent/PropertySetWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs similarity index 62% rename from src/Umbraco.Core/Models/PublishedContent/PropertySetWrapped.cs rename to src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs index 4041d43c8c..1989ac2caf 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PropertySetWrapped.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs @@ -4,19 +4,19 @@ using System.Collections.Generic; namespace Umbraco.Core.Models.PublishedContent { /// - /// Provides an abstract base class for IPropertySet implementations that - /// wrap and extend another IPropertySet. + /// Provides an abstract base class for IPublishedElement implementations that + /// wrap and extend another IPublishedElement. /// - public abstract class PropertySetWrapped : IPropertySet + public abstract class PublishedElementWrapped : IPublishedElement { - private readonly IPropertySet _content; + private readonly IPublishedElement _content; /// - /// Initializes a new instance of the class - /// with an IPropertySet instance to wrap. + /// Initializes a new instance of the class + /// with an IPublishedElement instance to wrap. /// /// The content to wrap. - protected PropertySetWrapped(IPropertySet content) + protected PublishedElementWrapped(IPublishedElement content) { _content = content; } @@ -25,7 +25,7 @@ namespace Umbraco.Core.Models.PublishedContent /// Gets the wrapped content. /// /// The wrapped content, that was passed as an argument to the constructor. - public IPropertySet Unwrap() => _content; + public IPublishedElement Unwrap() => _content; /// public PublishedContentType ContentType => _content.ContentType; diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 35eda44551..6e64822594 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -217,7 +217,7 @@ namespace Umbraco.Core.Models.PublishedContent // uses converters, else falls back to dark (& performance-wise expensive) magic // source: the property source value // preview: whether we are previewing or not - public object ConvertSourceToInter(IPropertySet owner, object source, bool preview) + public object ConvertSourceToInter(IPublishedElement owner, object source, bool preview) { if (!_initialized) Initialize(); @@ -231,7 +231,7 @@ namespace Umbraco.Core.Models.PublishedContent // uses converters, else returns the inter value // inter: the property inter value // preview: whether we are previewing or not - public object ConvertInterToObject(IPropertySet owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (!_initialized) Initialize(); @@ -246,7 +246,7 @@ namespace Umbraco.Core.Models.PublishedContent // if successful, returns either a string or an XPathNavigator // inter: the property inter value // preview: whether we are previewing or not - public object ConvertInterToXPath(IPropertySet owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToXPath(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (!_initialized) Initialize(); diff --git a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs index a28fd7abef..28ac22a567 100644 --- a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs @@ -51,7 +51,7 @@ namespace Umbraco.Core.PropertyEditors /// strings, and xml-whitespace strings appropriately, ie it should know whether to preserve /// whitespaces. /// - object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview); + object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview); /// /// Converts a property intermediate value to an Object value. @@ -70,7 +70,7 @@ namespace Umbraco.Core.PropertyEditors /// passed to eg a PublishedFragment constructor. It is used by the fragment and the properties to manage /// the cache levels of property values. It is not meant to be used by the converter. /// - object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview); + object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview); /// /// Converts a property intermediate value to an XPath value. @@ -94,6 +94,6 @@ namespace Umbraco.Core.PropertyEditors /// passed to eg a PublishedFragment constructor. It is used by the fragment and the properties to manage /// the cache levels of property values. It is not meant to be used by the converter. /// - object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview); + object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview); } } diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index 5a5e36e815..849886c66b 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -23,17 +23,17 @@ namespace Umbraco.Core.PropertyEditors return PropertyCacheLevel.Facade; } - public virtual object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public virtual object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { return source; } - public virtual object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public virtual object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { return inter; } - public virtual object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public virtual object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { return inter?.ToString() ?? string.Empty; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs index d61cbaec60..85fdf9bc0b 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { var sourceString = source?.ToString() ?? string.Empty; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs index 13e05aa01e..1f16c3e12a 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // make sure it's a string return source?.ToString() ?? string.Empty; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs index cf09be3008..100dbba575 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs @@ -23,7 +23,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return DateTime.MinValue; @@ -45,7 +45,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters // default ConvertSourceToObject just returns source ie a DateTime value - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a DateTime already return XmlConvert.ToString((DateTime) inter, XmlDateTimeSerializationMode.Unspecified); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs index 2e1c527caf..b8652c4d3c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return 0M; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs index e605b507f6..412d47ad96 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { var sourceString = (source ?? "").ToString(); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs index e2305cfa6b..e032674fb8 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return new int[] { }; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs index 007abd62e2..2f071935cd 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { return source?.ToString() ?? string.Empty; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs index 2c7747fa74..a70d600d37 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var intAttempt = source.TryConvertTo(); if (intAttempt.Success) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs index 7bc1e37c5c..0e646f4e1f 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { return source?.ToString() ?? string.Empty; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs index 5f60cfb317..3a403e3222 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs @@ -28,7 +28,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs index 15c580ab01..28686c0b4a 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs @@ -93,7 +93,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters } } - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs index c75fa5ad9d..51405f5132 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return 0; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs index f426ccbf0d..4645f8bf3d 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs @@ -34,7 +34,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs index 4f4523281f..b9990ae7cb 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs @@ -24,7 +24,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { return source?.ToString() ?? string.Empty; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index d5870ba104..b95840c2ae 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // in xml a string is: string // in the database a string is: string @@ -25,13 +25,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return source; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return new HtmlString(inter == null ? string.Empty : (string) inter); } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter?.ToString() ?? string.Empty; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs index 68727676b4..2d3aaa9d19 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { return source?.ToString() ?? string.Empty; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs index 6de2951a89..67a76462f2 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs @@ -18,7 +18,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // data is (both in database and xml): // @@ -56,7 +56,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters : values.ToArray(); } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { var d = new XmlDocument(); var e = d.CreateElement("values"); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs index d6da92d2f1..4a8b50e009 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs @@ -32,7 +32,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { return source?.ToString(); } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs index 15ad3f518c..dc38a4ed85 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var intAttempt = source.TryConvertTo(); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs index 0733d71154..61b3068dee 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs @@ -27,7 +27,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { if (source == null) return null; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs index 4d4994c954..ccc0713cf6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs @@ -28,7 +28,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // if Json storage type deserialzie and return as string array if (JsonStorageType(propertyType.DataTypeId)) @@ -45,7 +45,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return csvTags; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { return (string[]) source; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs index 1f556d03c4..cef7656421 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -22,7 +22,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // in xml a string is: string // in the database a string is: string @@ -30,13 +30,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return source; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter ?? string.Empty; } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs index ff788f91c4..ae4cb1a701 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // in xml a string is: string // in the database a string is: string @@ -28,13 +28,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return source; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return new HtmlString(inter == null ? string.Empty : (string)inter); } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs index 3014d7a60d..52176126ad 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs @@ -18,7 +18,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { return source?.ToString() ?? ""; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs index 153f209ccf..c3f2ca2290 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { // in xml a boolean is: string // in the database a boolean is: string "1" or "0" or empty @@ -45,7 +45,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters // default ConvertSourceToObject just returns source ie a boolean value - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a boolean already return (bool)inter ? "1" : "0"; diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 5615339fb3..ae251bea45 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -645,14 +645,14 @@ - + - - + + diff --git a/src/Umbraco.Tests/PublishedContent/ModelsAndConvertersTests.cs b/src/Umbraco.Tests/PublishedContent/ModelsAndConvertersTests.cs index 1b07082ab5..244d7f7e32 100644 --- a/src/Umbraco.Tests/PublishedContent/ModelsAndConvertersTests.cs +++ b/src/Umbraco.Tests/PublishedContent/ModelsAndConvertersTests.cs @@ -79,7 +79,7 @@ namespace Umbraco.Tests.PublishedContent new PublishedPropertyType("prop1", "editor1", converters), }); - var set1 = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); Assert.AreEqual(1234, set1.Value("prop1")); } @@ -95,13 +95,13 @@ namespace Umbraco.Tests.PublishedContent public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) => int.TryParse(source as string, out int i) ? i : 0; - public object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => (int) inter; - public object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); } @@ -131,7 +131,7 @@ namespace Umbraco.Tests.PublishedContent new PublishedPropertyType("prop1", "editor2", converters), }); - var set1 = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); var cntType1 = new PublishedContentType(1001, "cnt1", Array.Empty()); var cnt1 = new TestPublishedContent(cntType1, 1234, Guid.NewGuid(), new Dictionary(), false); @@ -164,13 +164,13 @@ namespace Umbraco.Tests.PublishedContent public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => _cacheLevel; - public object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) => int.TryParse(source as string, out int i) ? i : -1; - public object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => _facadeAccessor.Facade.ContentCache.GetById((int) inter); - public object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); } @@ -225,8 +225,8 @@ namespace Umbraco.Tests.PublishedContent new PublishedPropertyType("prop2", "editor2"), }); - var set1 = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); - var set2 = new PropertySet(setType2, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); + var set2 = new PublishedElement(setType2, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); var cnt1 = new TestPublishedContent(contentType1, 1003, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); var cnt2 = new TestPublishedContent(contentType2, 1004, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); @@ -292,13 +292,13 @@ namespace Umbraco.Tests.PublishedContent public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Snapshot; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var s = source as string; return s?.Split(',').Select(int.Parse).ToArray() ?? Array.Empty(); } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { return ((int[]) inter).Select(x => (TestContentModel1) _facadeAccessor.Facade.ContentCache.GetById(x)).ToArray(); } @@ -339,7 +339,7 @@ namespace Umbraco.Tests.PublishedContent // // for standalone property sets, it's only None or Content - var set1 = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); Assert.AreEqual(1234, set1.Value("prop1")); Assert.AreEqual(1, converter.SourceConverts); @@ -405,11 +405,11 @@ namespace Umbraco.Tests.PublishedContent var facadeServiceMock = new Mock(); facadeServiceMock - .Setup(x => x.CreateSetProperty(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns((propertyType, set, previewing, refCacheLevel, value) => + .Setup(x => x.CreateSetProperty(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((propertyType, set, previewing, refCacheLevel, value) => { // ReSharper disable AccessToModifiedClosure - return new TestPropertySetProperty(propertyType, set, previewing, refCacheLevel, value, () => snapshotCache, () => facadeCache); + return new TestPublishedElementProperty(propertyType, set, previewing, refCacheLevel, value, () => snapshotCache, () => facadeCache); // ReSharper restore AccessToModifiedClosure }); var facadeService = facadeServiceMock.Object; @@ -418,7 +418,7 @@ namespace Umbraco.Tests.PublishedContent // referenceCacheLevel is the cache level for this fictious property // converterCacheLevel is the cache level specified by the converter - var set1 = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false, facadeService, referenceCacheLevel); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false, facadeService, referenceCacheLevel); Assert.AreEqual(1234, set1.Value("prop1")); Assert.AreEqual(1, converter.SourceConverts); @@ -476,7 +476,7 @@ namespace Umbraco.Tests.PublishedContent Assert.Throws(() => { - var unused = new PropertySet(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); + var unused = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); }); } @@ -501,29 +501,29 @@ namespace Umbraco.Tests.PublishedContent public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => _cacheLevel; - public object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { SourceConverts++; return int.TryParse(source as string, out int i) ? i : 0; } - public object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { InterConverts++; return (int) inter; } - public object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); } - private class TestPropertySetProperty : PropertySetPropertyBase + private class TestPublishedElementProperty : PublishedElementPropertyBase { private readonly Func> _getSnapshotCache; private readonly Func> _getFacadeCache; private string _valuesCacheKey; - public TestPropertySetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue, + public TestPublishedElementProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue, Func> getSnapshotCache, Func> getFacadeCache) : base(propertyType, set, previewing, referenceCacheLevel, sourceValue) { @@ -557,9 +557,9 @@ namespace Umbraco.Tests.PublishedContent #region Model classes [PublishedContentModel("set1")] - public class TestSetModel1 : PropertySetModel + public class TestSetModel1 : PublishedElementModel { - public TestSetModel1(IPropertySet content) + public TestSetModel1(IPublishedElement content) : base(content) { } @@ -567,9 +567,9 @@ namespace Umbraco.Tests.PublishedContent } [PublishedContentModel("set2")] - public class TestSetModel2 : PropertySetModel + public class TestSetModel2 : PublishedElementModel { - public TestSetModel2(IPropertySet content) + public TestSetModel2(IPublishedElement content) : base(content) { } @@ -600,7 +600,7 @@ namespace Umbraco.Tests.PublishedContent #region Support classes - internal class TestPublishedContent : PropertySet, IPublishedContent + internal class TestPublishedContent : PublishedElement, IPublishedContent { public TestPublishedContent(PublishedContentType contentType, int id, Guid key, Dictionary values, bool previewing) : base(contentType, key, values, previewing) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index e5c767fa64..62de356714 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -556,7 +556,7 @@ namespace Umbraco.Tests.PublishedContent { var pt = new PublishedPropertyType("detached", Constants.PropertyEditors.IntegerAlias); var ct = new PublishedContentType(0, "alias", new[] { pt }); - var prop = new PropertySetProperty(pt, null, false, PropertyCacheLevel.None, 5548); + var prop = new PublishedElementProperty(pt, null, false, PropertyCacheLevel.None, 5548); Assert.IsInstanceOf(prop.Value); Assert.AreEqual(5548, prop.Value); } @@ -565,7 +565,7 @@ namespace Umbraco.Tests.PublishedContent { var type = ContentTypesCache.Get(PublishedItemType.Content, "detachedSomething"); var values = new Dictionary(); - var f = new PropertySet(type, Guid.NewGuid(), values, false); + var f = new PublishedElement(type, Guid.NewGuid(), values, false); } [Test] @@ -593,7 +593,7 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual(val3, c.Size); } - class ImageWithLegendModel : PropertySet + class ImageWithLegendModel : PublishedElement { public ImageWithLegendModel(PublishedContentType contentType, Guid fragmentKey, Dictionary values, bool previewing) : base(contentType, fragmentKey, values, previewing) diff --git a/src/Umbraco.Web/Models/DetachedPublishedProperty.cs b/src/Umbraco.Web/Models/DetachedPublishedProperty.cs index e3c2d44457..0a3d189afa 100644 --- a/src/Umbraco.Web/Models/DetachedPublishedProperty.cs +++ b/src/Umbraco.Web/Models/DetachedPublishedProperty.cs @@ -24,11 +24,11 @@ namespace Umbraco.Web.Models _sourceValue = value; - IPropertySet propertySet = null; // fixme!! nested content needs complete refactoring! + IPublishedElement publishedElement = null; // fixme!! nested content needs complete refactoring! - var interValue = new Lazy(() => _propertyType.ConvertSourceToInter(propertySet, _sourceValue, _isPreview)); - _objectValue = new Lazy(() => _propertyType.ConvertInterToObject(propertySet, PropertyCacheLevel.None, interValue.Value, _isPreview)); - _xpathValue = new Lazy(() => _propertyType.ConvertInterToXPath(propertySet, PropertyCacheLevel.None, interValue.Value, _isPreview)); + var interValue = new Lazy(() => _propertyType.ConvertSourceToInter(publishedElement, _sourceValue, _isPreview)); + _objectValue = new Lazy(() => _propertyType.ConvertInterToObject(publishedElement, PropertyCacheLevel.None, interValue.Value, _isPreview)); + _xpathValue = new Lazy(() => _propertyType.ConvertInterToXPath(publishedElement, PropertyCacheLevel.None, interValue.Value, _isPreview)); } public string PropertyTypeAlias => _propertyType.PropertyTypeAlias; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs index d8b7925b1a..5b10c6aa83 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs @@ -33,7 +33,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Snapshot; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; @@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return null; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (inter == null) return null; @@ -74,7 +74,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return inter; } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { return inter.ToString(); } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs index ca63535260..a82a06ca00 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (ImageCropDataSet); - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var baseVal = base.ConvertSourceToInter(owner, propertyType, source, preview); var json = baseVal as JObject; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs index d1bc5e157f..418511e7a0 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs @@ -64,7 +64,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } } - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index 46c6d6d07e..fd558e7c9b 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Facade; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); @@ -32,7 +32,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return sourceString; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // convert markup to html for frontend rendering. // source should come from ConvertSource and be a string (or null) already diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs index 7a6a5147d1..d521676eb7 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs @@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters ? typeof (IEnumerable) : typeof (IPublishedContent); - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (IsMultipleDataType(propertyType.DataTypeId, propertyType.PropertyEditorAlias)) { @@ -79,7 +79,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return null; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object source, bool preview) { if (source == null) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs index 26aab5e111..117aef1892 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs @@ -73,7 +73,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters }); } - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var nodeIds = source.ToString() .Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) @@ -82,7 +82,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return nodeIds; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { if (source == null) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs index 881ee164bb..0c699f8dfe 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IPublishedContent); - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { var attemptConvertInt = source.TryConvertTo(); if (attemptConvertInt.Success) @@ -40,7 +40,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return null; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { if (source == null) return null; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs index ceff0cc206..8c7e901abd 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs @@ -45,7 +45,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (propertyType.PropertyEditorAlias.Equals(Constants.PropertyEditors.MultiNodeTreePickerAlias)) { @@ -66,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return null; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { if (source == null) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs index 571776b3ab..3352816bdc 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { try { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs index 9ec96a2cb8..b75a3aa39f 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { try { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs index 86e124a4e4..b487ed6744 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); @@ -99,7 +99,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return sourceString; } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object source, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs index 5d4b5b0611..7429ae798b 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs @@ -49,7 +49,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Content; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); @@ -129,7 +129,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return link; } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (inter == null) return null; var sourceString = inter.ToString(); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs index 2041af92b9..8eb449b703 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs @@ -63,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } } - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs index c921930abd..4dcafac80b 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.Facade; - public override object ConvertSourceToInter(IPropertySet owner, PublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { if (source == null) return null; var sourceString = source.ToString(); @@ -37,13 +37,13 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return sourceString; } - public override object ConvertInterToObject(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter ?? string.Empty; } - public override object ConvertInterToXPath(IPropertySet owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) + public override object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { // source should come from ConvertSource and be a string (or null) already return inter; diff --git a/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs b/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs index 90d4fecced..48b1363187 100644 --- a/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs +++ b/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs @@ -25,16 +25,16 @@ namespace Umbraco.Web.PublishedCache public abstract bool EnsureEnvironment(out IEnumerable errors); - public virtual IPropertySet CreateSet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, PropertyCacheLevel referenceCacheLevel) + public virtual IPublishedElement CreateSet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, PropertyCacheLevel referenceCacheLevel) { - var set = new PropertySet(contentType, key, values, previewing, this, referenceCacheLevel); + var set = new PublishedElement(contentType, key, values, previewing, this, referenceCacheLevel); var model = Current.PublishedContentModelFactory.CreateModel(set); if (model == null) throw new Exception("Factory returned null."); return model; } - public abstract IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null); + public abstract IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null); public abstract string EnterPreview(IUser user, int contentId); public abstract void RefreshPreview(string previewToken, int contentId); diff --git a/src/Umbraco.Web/PublishedCache/IFacadeService.cs b/src/Umbraco.Web/PublishedCache/IFacadeService.cs index bb7acfa052..a82574e9bc 100644 --- a/src/Umbraco.Web/PublishedCache/IFacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/IFacadeService.cs @@ -163,7 +163,7 @@ namespace Umbraco.Web.PublishedCache /// A value indicating whether previewing. /// The reference cache level. /// A property set. - IPropertySet CreateSet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, PropertyCacheLevel referenceCacheLevel); + IPublishedElement CreateSet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, PropertyCacheLevel referenceCacheLevel); /// /// Creates a set property. @@ -174,7 +174,7 @@ namespace Umbraco.Web.PublishedCache /// The reference cache level. /// The source value. /// A set property. - IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null); + IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null); #endregion } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs b/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs index 3b2ecb5117..d8afd32968 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs @@ -1536,9 +1536,9 @@ AND cmsContentNu.nodeId IS NULL #region Property Set - public override IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) + public override IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) { - return new PropertySetProperty(FacadeAccessor, propertyType, set, previewing, referenceCacheLevel, sourceValue); + return new PublishedElementProperty(FacadeAccessor, propertyType, set, previewing, referenceCacheLevel, sourceValue); } #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PropertySetProperty.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedElementProperty.cs similarity index 87% rename from src/Umbraco.Web/PublishedCache/NuCache/PropertySetProperty.cs rename to src/Umbraco.Web/PublishedCache/NuCache/PublishedElementProperty.cs index 70be29721f..59b689b9e0 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PropertySetProperty.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedElementProperty.cs @@ -5,13 +5,13 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PublishedCache.NuCache { - internal class PropertySetProperty : PropertySetPropertyBase + internal class PublishedElementProperty : PublishedElementPropertyBase { private readonly IFacadeAccessor _facadeAccessor; private string _valuesCacheKey; // initializes a published item property - public PropertySetProperty(IFacadeAccessor facadeAccessor, PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) + public PublishedElementProperty(IFacadeAccessor facadeAccessor, PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) : base(propertyType, set, previewing, referenceCacheLevel, sourceValue) { _facadeAccessor = facadeAccessor; diff --git a/src/Umbraco.Web/PublishedCache/PropertySet.cs b/src/Umbraco.Web/PublishedCache/PublishedElement.cs similarity index 84% rename from src/Umbraco.Web/PublishedCache/PropertySet.cs rename to src/Umbraco.Web/PublishedCache/PublishedElement.cs index ae93c55a32..d39513a7c7 100644 --- a/src/Umbraco.Web/PublishedCache/PropertySet.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElement.cs @@ -14,11 +14,11 @@ namespace Umbraco.Web.PublishedCache // an entirely new models factory + not even sure it makes sense at all since // sets are created manually // - internal class PropertySet : IPropertySet + internal class PublishedElement : IPublishedElement { - // initializes a new instance of the PropertySet class + // initializes a new instance of the PublishedElement class // within the context of a facade service (eg a published content property value) - public PropertySet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, + public PublishedElement(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, IFacadeService facadeService, PropertyCacheLevel referenceCacheLevel) { ContentType = contentType; @@ -36,9 +36,9 @@ namespace Umbraco.Web.PublishedCache .ToArray(); } - // initializes a new instance of the PropertySet class + // initializes a new instance of the PublishedElement class // without any context, so it's purely 'standalone' and should NOT interfere with the facade service - public PropertySet(PublishedContentType contentType, Guid key, Dictionary values, bool previewing) + public PublishedElement(PublishedContentType contentType, Guid key, Dictionary values, bool previewing) { ContentType = contentType; Key = key; @@ -55,7 +55,7 @@ namespace Umbraco.Web.PublishedCache .Select(propertyType => { values.TryGetValue(propertyType.PropertyTypeAlias, out object value); - return (IPublishedProperty) new PropertySetProperty(propertyType, this, previewing, cacheLevel, value); + return (IPublishedProperty) new PublishedElementProperty(propertyType, this, previewing, cacheLevel, value); }) .ToArray(); } @@ -74,7 +74,7 @@ namespace Umbraco.Web.PublishedCache #endregion - #region PropertySet + #region PublishedElement public Guid Key { get; } diff --git a/src/Umbraco.Web/PublishedCache/PropertySetProperty.cs b/src/Umbraco.Web/PublishedCache/PublishedElementProperty.cs similarity index 66% rename from src/Umbraco.Web/PublishedCache/PropertySetProperty.cs rename to src/Umbraco.Web/PublishedCache/PublishedElementProperty.cs index 3bf0e29c10..adb7ababbc 100644 --- a/src/Umbraco.Web/PublishedCache/PropertySetProperty.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElementProperty.cs @@ -4,9 +4,9 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PublishedCache { - internal class PropertySetProperty : PropertySetPropertyBase + internal class PublishedElementProperty : PublishedElementPropertyBase { - public PropertySetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel cacheLevel, object sourceValue = null) + public PublishedElementProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel cacheLevel, object sourceValue = null) : base(propertyType, set, previewing, cacheLevel, sourceValue) { } diff --git a/src/Umbraco.Web/PublishedCache/PropertySetPropertyBase.cs b/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs similarity index 94% rename from src/Umbraco.Web/PublishedCache/PropertySetPropertyBase.cs rename to src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs index 2036671efb..a95d367ba4 100644 --- a/src/Umbraco.Web/PublishedCache/PropertySetPropertyBase.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs @@ -4,12 +4,12 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PublishedCache { - internal abstract class PropertySetPropertyBase : PublishedPropertyBase + internal abstract class PublishedElementPropertyBase : PublishedPropertyBase { private readonly object _locko = new object(); private readonly object _sourceValue; - protected readonly IPropertySet Set; + protected readonly IPublishedElement Set; protected readonly bool IsPreviewing; protected readonly bool IsMember; @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache private CacheValues _cacheValues; // initializes a published item property - protected PropertySetPropertyBase(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) + protected PublishedElementPropertyBase(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) : base(propertyType, referenceCacheLevel) { _sourceValue = sourceValue; diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs index 719a49bd1e..26747d6ef2 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs @@ -240,7 +240,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache #region Property Set - public override IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPropertySet set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) + public override IPublishedProperty CreateSetProperty(PublishedPropertyType propertyType, IPublishedElement set, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null) { // fixme - ouch? throw new NotImplementedException(); diff --git a/src/Umbraco.Web/PropertySetExtensions.cs b/src/Umbraco.Web/PublishedElementExtensions.cs similarity index 90% rename from src/Umbraco.Web/PropertySetExtensions.cs rename to src/Umbraco.Web/PublishedElementExtensions.cs index cceb3fba55..7a21a7e1c3 100644 --- a/src/Umbraco.Web/PropertySetExtensions.cs +++ b/src/Umbraco.Web/PublishedElementExtensions.cs @@ -7,9 +7,9 @@ using Umbraco.Core.Models.PublishedContent; namespace Umbraco.Web { /// - /// Provides extension methods for IPublishedItem. + /// Provides extension methods for IPublishedElement. /// - public static class PropertySetExtensions + public static class PublishedElementExtensions { #region IsComposedOf @@ -19,7 +19,7 @@ namespace Umbraco.Web /// The content. /// The content type alias. /// A value indicating whether the content is of a content type composed of a content type identified by the alias. - public static bool IsComposedOf(this IPropertySet content, string alias) + public static bool IsComposedOf(this IPublishedElement content, string alias) { return content.ContentType.CompositionAliases.Contains(alias); } @@ -35,7 +35,7 @@ namespace Umbraco.Web /// The property alias. /// A value indicating whether the content has the property identified by the alias. /// The content may have a property, and that property may not have a value. - public static bool HasProperty(this IPropertySet content, string alias) + public static bool HasProperty(this IPublishedElement content, string alias) { return content.ContentType.GetPropertyType(alias) != null; } @@ -51,7 +51,7 @@ namespace Umbraco.Web /// The property alias. /// A value indicating whether the content has a value for the property identified by the alias. /// Returns true if GetProperty(alias) is not null and GetProperty(alias).HasValue is true. - public static bool HasValue(this IPropertySet content, string alias) + public static bool HasValue(this IPublishedElement content, string alias) { var prop = content.GetProperty(alias); return prop != null && prop.HasValue; @@ -66,7 +66,7 @@ namespace Umbraco.Web /// The value to return if the content has no value for the property. /// Either or depending on whether the content /// has a value for the property identified by the alias. - public static IHtmlString HasValue(this IPropertySet content, string alias, + public static IHtmlString HasValue(this IPublishedElement content, string alias, string valueIfTrue, string valueIfFalse = null) { return content.HasValue(alias) @@ -90,7 +90,7 @@ namespace Umbraco.Web /// If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter. /// The alias is case-insensitive. /// - public static object Value(this IPropertySet content, string alias) + public static object Value(this IPublishedElement content, string alias) { var property = content.GetProperty(alias); return property?.Value; @@ -109,7 +109,7 @@ namespace Umbraco.Web /// If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter. /// The alias is case-insensitive. /// - public static object Value(this IPropertySet content, string alias, string defaultValue) // fixme - kill + public static object Value(this IPublishedElement content, string alias, string defaultValue) // fixme - kill { var property = content.GetProperty(alias); return property == null || property.HasValue == false ? defaultValue : property.Value; @@ -128,7 +128,7 @@ namespace Umbraco.Web /// If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter. /// The alias is case-insensitive. /// - public static object Value(this IPropertySet content, string alias, object defaultValue) + public static object Value(this IPublishedElement content, string alias, object defaultValue) { var property = content.GetProperty(alias); return property == null || property.HasValue == false ? defaultValue : property.Value; @@ -151,7 +151,7 @@ namespace Umbraco.Web /// If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter. /// The alias is case-insensitive. /// - public static T Value(this IPropertySet content, string alias) + public static T Value(this IPublishedElement content, string alias) { return content.Value(alias, false, default(T)); } @@ -170,12 +170,12 @@ namespace Umbraco.Web /// If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter. /// The alias is case-insensitive. /// - public static T Value(this IPropertySet content, string alias, T defaultValue) + public static T Value(this IPublishedElement content, string alias, T defaultValue) { return content.Value(alias, true, defaultValue); } - internal static T Value(this IPropertySet content, string alias, bool withDefaultValue, T defaultValue) // fixme uh? + internal static T Value(this IPublishedElement content, string alias, bool withDefaultValue, T defaultValue) // fixme uh? { var property = content.GetProperty(alias); if (property == null) return defaultValue; @@ -205,7 +205,7 @@ namespace Umbraco.Web // TODO: strongly typed properties howto? // there is no strongly typed recurse, etc => needs to be in ModelsBuilder? - public static IHtmlString Value(this IPropertySet content, string aliases, Func format, string alt = "") + public static IHtmlString Value(this IPublishedElement content, string aliases, Func format, string alt = "") { if (format == null) format = x => x.ToString(); @@ -239,7 +239,7 @@ namespace Umbraco.Web #region ToIndexedArray public static IndexedArrayItem[] ToIndexedArray(this IEnumerable source) - where TContent : class, IPropertySet + where TContent : class, IPublishedElement { var set = source.Select((content, index) => new IndexedArrayItem(content, index)).ToArray(); foreach (var setItem in set) setItem.TotalCount = set.Length; @@ -253,7 +253,7 @@ namespace Umbraco.Web // the .OfType() filter is nice when there's only one type // this is to support filtering with multiple types public static IEnumerable OfTypes(this IEnumerable contents, params string[] types) - where T : IPropertySet + where T : IPublishedElement { types = types.Select(x => x.ToLowerInvariant()).ToArray(); return contents.Where(x => types.Contains(x.ContentType.Alias.ToLowerInvariant())); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4330b6d8ce..4467495397 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -258,10 +258,10 @@ - - - - + + + + @@ -306,7 +306,7 @@ - +