From 34ad8dfb8d726d6d9bb2b3e2791dcfdb231357b4 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 15 Apr 2019 13:04:14 +0200 Subject: [PATCH] Introduce IPublishedContentType --- .../ContentVariationExtensions.cs | 8 +-- .../PublishedContent/IPublishedContentType.cs | 63 +++++++++++++++++++ .../IPublishedContentTypeFactory.cs | 6 +- .../PublishedContent/IPublishedElement.cs | 2 +- .../PublishedContent/PublishedContentType.cs | 45 ++++--------- .../PublishedContentTypeFactory.cs | 10 +-- .../PublishedContentWrapped.cs | 2 +- .../PublishedElementWrapped.cs | 2 +- .../PublishedContent/PublishedPropertyType.cs | 6 +- src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../DictionaryPublishedContent.cs | 4 +- .../PublishedContentCache.cs | 4 +- .../PublishedMediaCache.cs | 6 +- .../PublishedMemberCache.cs | 4 +- .../XmlPublishedContent.cs | 8 +-- .../Published/NestedContentTests.cs | 6 +- .../PublishedContentDataTableTests.cs | 2 +- .../PublishedContent/PublishedContentTests.cs | 2 +- .../SolidPublishedSnapshot.cs | 10 +-- .../TestHelpers/Stubs/TestPublishedContent.cs | 2 +- .../PublishedContentHashtableConverter.cs | 2 +- .../Models/PublishedContentBase.cs | 2 +- .../PublishedCache/IPublishedCache.cs | 6 +- .../PublishedCache/IPublishedMemberCache.cs | 4 +- .../PublishedCache/NuCache/ContentCache.cs | 4 +- .../PublishedCache/NuCache/ContentNode.cs | 10 +-- .../PublishedCache/NuCache/ContentNodeKit.cs | 2 +- .../PublishedCache/NuCache/ContentStore.cs | 30 ++++----- .../PublishedCache/NuCache/MediaCache.cs | 4 +- .../PublishedCache/NuCache/MemberCache.cs | 4 +- .../NuCache/Navigable/NavigableContentType.cs | 8 +-- .../NuCache/PublishedContent.cs | 2 +- .../PublishedCache/NuCache/PublishedMember.cs | 6 +- .../NuCache/PublishedSnapshotService.cs | 6 +- .../PublishedCache/PublishedCacheBase.cs | 6 +- .../PublishedContentTypeCache.cs | 22 +++---- .../PublishedCache/PublishedElement.cs | 6 +- .../PublishedCache/PublishedMember.cs | 6 +- 38 files changed, 183 insertions(+), 140 deletions(-) create mode 100644 src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs diff --git a/src/Umbraco.Core/ContentVariationExtensions.cs b/src/Umbraco.Core/ContentVariationExtensions.cs index d25997b5f0..c5e4a67fe2 100644 --- a/src/Umbraco.Core/ContentVariationExtensions.cs +++ b/src/Umbraco.Core/ContentVariationExtensions.cs @@ -66,24 +66,24 @@ namespace Umbraco.Core /// /// Determines whether the content type is invariant. /// - public static bool VariesByNothing(this PublishedContentType contentType) => contentType.Variations.VariesByNothing(); + public static bool VariesByNothing(this IPublishedContentType contentType) => contentType.Variations.VariesByNothing(); /// /// Determines whether the content type varies by culture. /// /// And then it could also vary by segment. - public static bool VariesByCulture(this PublishedContentType contentType) => contentType.Variations.VariesByCulture(); + public static bool VariesByCulture(this IPublishedContentType contentType) => contentType.Variations.VariesByCulture(); /// /// Determines whether the content type varies by segment. /// /// And then it could also vary by culture. - public static bool VariesBySegment(this PublishedContentType contentType) => contentType.Variations.VariesBySegment(); + public static bool VariesBySegment(this IPublishedContentType contentType) => contentType.Variations.VariesBySegment(); /// /// Determines whether the content type varies by culture and segment. /// - public static bool VariesByCultureAndSegment(this PublishedContentType contentType) => contentType.Variations.VariesByCultureAndSegment(); + public static bool VariesByCultureAndSegment(this IPublishedContentType contentType) => contentType.Variations.VariesByCultureAndSegment(); /// /// Determines whether the property type is invariant. diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs new file mode 100644 index 0000000000..3c28ca1508 --- /dev/null +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; + +namespace Umbraco.Core.Models.PublishedContent +{ + /// + /// Represents an type. + /// + /// Instances implementing the interface should be + /// immutable, ie if the content type changes, then a new instance needs to be created. + public interface IPublishedContentType + { + /// + /// Gets the content type identifier. + /// + int Id { get; } + + /// + /// Gets the content type alias. + /// + string Alias { get; } + + /// + /// Gets the content item type. + /// + PublishedItemType ItemType { get; } + + /// + /// Gets the aliases of the content types participating in the composition. + /// + HashSet CompositionAliases { get; } + + /// + /// Gets the content variations of the content type. + /// + ContentVariation Variations { get; } + + /// + /// Gets a value indicating whether this content type is for an element. + /// + bool IsElement { get; } + + /// + /// Gets the content type properties. + /// + IEnumerable PropertyTypes { get; } + + /// + /// Gets a property type index. + /// + /// The alias is case-insensitive. This is the only place where alias strings are compared. + int GetPropertyIndex(string alias); + + /// + /// Gets a property type. + /// + PublishedPropertyType GetPropertyType(string alias); + + /// + /// Gets a property type. + /// + PublishedPropertyType GetPropertyType(int index); + } +} diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs index e75e8a4eb9..a43f572a74 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs @@ -10,7 +10,7 @@ /// /// An content type. /// A published content type corresponding to the item type and content type. - PublishedContentType CreateContentType(IContentTypeComposition contentType); + IPublishedContentType CreateContentType(IContentTypeComposition contentType); /// /// Creates a published property type. @@ -18,7 +18,7 @@ /// The published content type owning the property. /// A property type. /// Is used by constructor to create property types. - PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType); + PublishedPropertyType CreatePropertyType(IPublishedContentType contentType, PropertyType propertyType); /// /// Creates a published property type. @@ -28,7 +28,7 @@ /// The datatype identifier. /// The variations. /// Is used by constructor to create special property types. - PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations); + PublishedPropertyType CreatePropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations); /// /// Gets a published datatype. diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs index 4b579d824b..4c72dc914a 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.Models.PublishedContent /// /// Gets the content type. /// - PublishedContentType ContentType { get; } + IPublishedContentType ContentType { get; } #endregion diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index 0798e9a4e0..c6639b4109 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -5,11 +5,11 @@ using System.Linq; namespace Umbraco.Core.Models.PublishedContent { /// - /// Represents an type. + /// Represents an type. /// /// Instances of the class are immutable, ie /// if the content type changes, then a new class needs to be created. - public class PublishedContentType + public class PublishedContentType : IPublishedContentType { private readonly PublishedPropertyType[] _propertyTypes; @@ -103,44 +103,29 @@ namespace Umbraco.Core.Models.PublishedContent #region Content type - /// - /// Gets the content type identifier. - /// + /// public int Id { get; } - /// - /// Gets the content type alias. - /// + /// public string Alias { get; } - /// - /// Gets the content item type. - /// + /// public PublishedItemType ItemType { get; } - /// - /// Gets the aliases of the content types participating in the composition. - /// + /// public HashSet CompositionAliases { get; } - /// - /// Gets the content variations of the content type. - /// + /// public ContentVariation Variations { get; } #endregion #region Properties - /// - /// Gets the content type properties. - /// + /// public IEnumerable PropertyTypes => _propertyTypes; - /// - /// Gets a property type index. - /// - /// The alias is case-insensitive. This is the only place where alias strings are compared. + /// public int GetPropertyIndex(string alias) { if (_indexes.TryGetValue(alias, out var index)) return index; // fastest @@ -150,9 +135,7 @@ namespace Umbraco.Core.Models.PublishedContent // virtual for unit tests // TODO: explain why - /// - /// Gets a property type. - /// + /// public virtual PublishedPropertyType GetPropertyType(string alias) { var index = GetPropertyIndex(alias); @@ -161,17 +144,13 @@ namespace Umbraco.Core.Models.PublishedContent // virtual for unit tests // TODO: explain why - /// - /// Gets a property type. - /// + /// public virtual PublishedPropertyType GetPropertyType(int index) { return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null; } - /// - /// Gets a value indicating whether this content type is for an element. - /// + /// public bool IsElement { get; } #endregion diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs index 2ca3593b55..01f01743de 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs @@ -26,31 +26,31 @@ namespace Umbraco.Core.Models.PublishedContent } /// - public PublishedContentType CreateContentType(IContentTypeComposition contentType) + public IPublishedContentType CreateContentType(IContentTypeComposition contentType) { return new PublishedContentType(contentType, this); } // for tests - internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false) + internal IPublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false) { return new PublishedContentType(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, variations, isElement); } // for tests - internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false) + internal IPublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false) { return new PublishedContentType(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, variations, isElement); } /// - public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType) + public PublishedPropertyType CreatePropertyType(IPublishedContentType contentType, PropertyType propertyType) { return new PublishedPropertyType(contentType, propertyType, _propertyValueConverters, _publishedModelFactory, this); } /// - public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations = ContentVariation.Nothing) + public PublishedPropertyType CreatePropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations = ContentVariation.Nothing) { return new PublishedPropertyType(contentType, propertyTypeAlias, dataTypeId, true, variations, _propertyValueConverters, _publishedModelFactory, this); } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs index 8bf8cec244..7f3f38f629 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs @@ -41,7 +41,7 @@ namespace Umbraco.Core.Models.PublishedContent #region ContentType /// - public virtual PublishedContentType ContentType => _content.ContentType; + public virtual IPublishedContentType ContentType => _content.ContentType; #endregion diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs index 1989ac2caf..481b9bd5d2 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs @@ -28,7 +28,7 @@ namespace Umbraco.Core.Models.PublishedContent public IPublishedElement Unwrap() => _content; /// - public PublishedContentType ContentType => _content.ContentType; + public IPublishedContentType ContentType => _content.ContentType; /// public Guid Key => _content.Key; diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 68892fd79a..8dd5003582 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -32,7 +32,7 @@ namespace Umbraco.Core.Models.PublishedContent /// /// The new published property type belongs to the published content type. /// - public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) + public PublishedPropertyType(IPublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) : this(propertyType.Alias, propertyType.DataTypeId, true, propertyType.Variations, propertyValueConverters, publishedModelFactory, factory) { ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType)); @@ -45,7 +45,7 @@ namespace Umbraco.Core.Models.PublishedContent /// Values are assumed to be consisted and are not checked. /// The new published property type belongs to the published content type. /// - public PublishedPropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) + public PublishedPropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) : this(propertyTypeAlias, dataTypeId, isUserProperty, variations, propertyValueConverters, publishedModelFactory, factory) { ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType)); @@ -78,7 +78,7 @@ namespace Umbraco.Core.Models.PublishedContent /// /// Gets the published content type containing the property type. /// - public PublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor + public IPublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor /// /// Gets the data type. diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 68091fb3a9..d6d0a1d9e5 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -221,6 +221,7 @@ + diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs index d3cbf1f183..e472de85dd 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs @@ -194,7 +194,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache return _getProperty(this, alias); } - public override PublishedContentType ContentType => _contentType; + public override IPublishedContentType ContentType => _contentType; private readonly List _keysAdded = new List(); private int _id; @@ -215,7 +215,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache //private Guid _version; private int _level; private readonly ICollection _properties; - private readonly PublishedContentType _contentType; + private readonly IPublishedContentType _contentType; private void ValidateAndSetProperty(IReadOnlyDictionary valueDictionary, Action setProperty, params string[] potentialKeys) { diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs index 5fc0d628c9..d69799dfdf 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs @@ -536,12 +536,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache #region Content types - public override PublishedContentType GetContentType(int id) + public override IPublishedContentType GetContentType(int id) { return _contentTypeCache.Get(PublishedItemType.Content, id); } - public override PublishedContentType GetContentType(string alias) + public override IPublishedContentType GetContentType(string alias) { return _contentTypeCache.Get(PublishedItemType.Content, alias); } diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs index 71490465d0..8cdab6b2ae 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs @@ -609,17 +609,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache #region Content types - public override PublishedContentType GetContentType(int id) + public override IPublishedContentType GetContentType(int id) { return _contentTypeCache.Get(PublishedItemType.Media, id); } - public override PublishedContentType GetContentType(string alias) + public override IPublishedContentType GetContentType(string alias) { return _contentTypeCache.Get(PublishedItemType.Media, alias); } - public override IEnumerable GetByContentType(PublishedContentType contentType) + public override IEnumerable GetByContentType(IPublishedContentType contentType) { throw new NotSupportedException(); } diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs index c882488f20..c28575f83d 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs @@ -138,12 +138,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache #region Content types - public PublishedContentType GetContentType(int id) + public IPublishedContentType GetContentType(int id) { return _contentTypeCache.Get(PublishedItemType.Member, id); } - public PublishedContentType GetContentType(string alias) + public IPublishedContentType GetContentType(string alias) { return _contentTypeCache.Get(PublishedItemType.Member, alias); } diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs index e1819bf0be..43c47ec569 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs @@ -53,7 +53,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private IEnumerable _children = Enumerable.Empty(); private IPublishedContent _parent; - private PublishedContentType _contentType; + private IPublishedContentType _contentType; private Dictionary _properties; private int _id; @@ -254,7 +254,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache } } - public override PublishedContentType ContentType + public override IPublishedContentType ContentType { get { @@ -308,8 +308,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName, out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path, out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft, - out PublishedContentType contentType, out Dictionary properties, - Func getPublishedContentType) + out IPublishedContentType contentType, out Dictionary properties, + Func getPublishedContentType) { //initialize the out params with defaults: writerName = null; diff --git a/src/Umbraco.Tests/Published/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs index 8f3b9a1df9..35be4b0bf2 100644 --- a/src/Umbraco.Tests/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests/Published/NestedContentTests.cs @@ -23,7 +23,7 @@ namespace Umbraco.Tests.Published [TestFixture] public class NestedContentTests { - private (PublishedContentType, PublishedContentType) CreateContentTypes() + private (IPublishedContentType, IPublishedContentType) CreateContentTypes() { Current.Reset(); @@ -250,7 +250,7 @@ namespace Umbraco.Tests.Published class TestPublishedContent : PublishedContentBase { - public TestPublishedContent(PublishedContentType contentType, Guid key, IEnumerable properties, IUmbracoContextAccessor umbracoContextAccessor): base(umbracoContextAccessor) + public TestPublishedContent(IPublishedContentType contentType, Guid key, IEnumerable properties, IUmbracoContextAccessor umbracoContextAccessor): base(umbracoContextAccessor) { ContentType = contentType; Key = key; @@ -266,7 +266,7 @@ namespace Umbraco.Tests.Published public override bool IsPublished(string culture = null) => true; public override IPublishedContent Parent { get; } public override IEnumerable Children { get; } - public override PublishedContentType ContentType { get; } + public override IPublishedContentType ContentType { get; } // ReSharper restore UnassignedGetOnlyAutoProperty // ReSharper disable UnassignedGetOnlyAutoProperty diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index 283ed1edd9..74b9619845 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -243,7 +243,7 @@ namespace Umbraco.Tests.PublishedContent return property; } - public PublishedContentType ContentType { get; set; } + public IPublishedContentType ContentType { get; set; } } } } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index de641a99a2..605fae7a1b 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -930,7 +930,7 @@ namespace Umbraco.Tests.PublishedContent class ImageWithLegendModel : PublishedElement { - public ImageWithLegendModel(PublishedContentType contentType, Guid fragmentKey, Dictionary values, bool previewing) + public ImageWithLegendModel(IPublishedContentType contentType, Guid fragmentKey, Dictionary values, bool previewing) : base(contentType, fragmentKey, values, previewing) { } diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index 86017be820..c14a8c1740 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -137,17 +137,17 @@ namespace Umbraco.Tests.PublishedContent return _content.Count > 0; } - public override PublishedContentType GetContentType(int id) + public override IPublishedContentType GetContentType(int id) { throw new NotImplementedException(); } - public override PublishedContentType GetContentType(string alias) + public override IPublishedContentType GetContentType(string alias) { throw new NotImplementedException(); } - public override IEnumerable GetByContentType(PublishedContentType contentType) + public override IEnumerable GetByContentType(IPublishedContentType contentType) { throw new NotImplementedException(); } @@ -157,7 +157,7 @@ namespace Umbraco.Tests.PublishedContent { #region Constructor - public SolidPublishedContent(PublishedContentType contentType) + public SolidPublishedContent(IPublishedContentType contentType) { // initialize boring stuff TemplateId = 0; @@ -211,7 +211,7 @@ namespace Umbraco.Tests.PublishedContent #region ContentType - public PublishedContentType ContentType { get; private set; } + public IPublishedContentType ContentType { get; private set; } #endregion diff --git a/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs index a9abe96232..206660b904 100644 --- a/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs +++ b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs @@ -7,7 +7,7 @@ namespace Umbraco.Tests.TestHelpers.Stubs { internal class TestPublishedContent : PublishedElement, IPublishedContent { - public TestPublishedContent(PublishedContentType contentType, int id, Guid key, Dictionary values, bool previewing, Dictionary cultures = null) + public TestPublishedContent(IPublishedContentType contentType, int id, Guid key, Dictionary values, bool previewing, Dictionary cultures = null) : base(contentType, key, values, previewing) { Id = id; diff --git a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs index 9b3bc62cbf..0ff2a41867 100644 --- a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs +++ b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs @@ -218,7 +218,7 @@ namespace Umbraco.Web.Macros Parent = new PagePublishedContent(_inner.ParentId); } - public PublishedContentType ContentType { get; } + public IPublishedContentType ContentType { get; } public int Id { get; } diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index 39933b49be..d62b8c6665 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Models #region ContentType - public abstract PublishedContentType ContentType { get; } + public abstract IPublishedContentType ContentType { get; } #endregion diff --git a/src/Umbraco.Web/PublishedCache/IPublishedCache.cs b/src/Umbraco.Web/PublishedCache/IPublishedCache.cs index ff459a2d9b..0a597a7138 100644 --- a/src/Umbraco.Web/PublishedCache/IPublishedCache.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedCache.cs @@ -199,7 +199,7 @@ namespace Umbraco.Web.PublishedCache /// /// The content type unique identifier. /// The content type, or null. - PublishedContentType GetContentType(int id); + IPublishedContentType GetContentType(int id); /// /// Gets a content type identified by its alias. @@ -207,13 +207,13 @@ namespace Umbraco.Web.PublishedCache /// The content type alias. /// The content type, or null. /// The alias is case-insensitive. - PublishedContentType GetContentType(string alias); + IPublishedContentType GetContentType(string alias); /// /// Gets contents of a given content type. /// /// The content type. /// The contents. - IEnumerable GetByContentType(PublishedContentType contentType); + IEnumerable GetByContentType(IPublishedContentType contentType); } } diff --git a/src/Umbraco.Web/PublishedCache/IPublishedMemberCache.cs b/src/Umbraco.Web/PublishedCache/IPublishedMemberCache.cs index 53d37a8d31..0ea812db83 100644 --- a/src/Umbraco.Web/PublishedCache/IPublishedMemberCache.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedMemberCache.cs @@ -22,7 +22,7 @@ namespace Umbraco.Web.PublishedCache /// /// The content type unique identifier. /// The content type, or null. - PublishedContentType GetContentType(int id); + IPublishedContentType GetContentType(int id); /// /// Gets a content type identified by its alias. @@ -30,6 +30,6 @@ namespace Umbraco.Web.PublishedCache /// The content type alias. /// The content type, or null. /// The alias is case-insensitive. - PublishedContentType GetContentType(string alias); + IPublishedContentType GetContentType(string alias); } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs index 0e74ea919f..d070b959ed 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs @@ -376,12 +376,12 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content types - public override PublishedContentType GetContentType(int id) + public override IPublishedContentType GetContentType(int id) { return _snapshot.GetContentType(id); } - public override PublishedContentType GetContentType(string alias) + public override IPublishedContentType GetContentType(string alias) { return _snapshot.GetContentType(alias); } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs index db7aa0d5d1..f7eb2ca19e 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs @@ -10,7 +10,7 @@ namespace Umbraco.Web.PublishedCache.NuCache internal class ContentNode { // special ctor with no content data - for members - public ContentNode(int id, Guid uid, PublishedContentType contentType, + public ContentNode(int id, Guid uid, IPublishedContentType contentType, int level, string path, int sortOrder, int parentContentId, DateTime createDate, int creatorId) @@ -28,7 +28,7 @@ namespace Umbraco.Web.PublishedCache.NuCache ChildContentIds = new List(); } - public ContentNode(int id, Guid uid, PublishedContentType contentType, + public ContentNode(int id, Guid uid, IPublishedContentType contentType, int level, string path, int sortOrder, int parentContentId, DateTime createDate, int creatorId, @@ -60,7 +60,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } // two-phase ctor, phase 2 - public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor) + public void SetContentTypeAndData(IPublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor) { ContentType = contentType; @@ -109,7 +109,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } // clone with new content type - public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor) + public ContentNode(ContentNode origin, IPublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor) { Id = origin.Id; Uid = origin.Uid; @@ -136,7 +136,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // keep this as small as possible public readonly int Id; public readonly Guid Uid; - public PublishedContentType ContentType; + public IPublishedContentType ContentType; public readonly int Level; public readonly string Path; public readonly int SortOrder; diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs index 753ba5cc94..08557fe3db 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 }; public void Build( - PublishedContentType contentType, + IPublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, bool canBePublished, diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs index 48c68ab9bf..5693bd3204 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs @@ -24,8 +24,8 @@ namespace Umbraco.Web.PublishedCache.NuCache private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly ConcurrentDictionary> _contentNodes; private readonly ConcurrentDictionary> _contentRootNodes; - private readonly ConcurrentDictionary> _contentTypesById; - private readonly ConcurrentDictionary> _contentTypesByAlias; + private readonly ConcurrentDictionary> _contentTypesById; + private readonly ConcurrentDictionary> _contentTypesByAlias; private readonly ConcurrentDictionary _xmap; private readonly ILogger _logger; @@ -61,8 +61,8 @@ namespace Umbraco.Web.PublishedCache.NuCache _contentNodes = new ConcurrentDictionary>(); _contentRootNodes = new ConcurrentDictionary>(); - _contentTypesById = new ConcurrentDictionary>(); - _contentTypesByAlias = new ConcurrentDictionary>(StringComparer.InvariantCultureIgnoreCase); + _contentTypesById = new ConcurrentDictionary>(); + _contentTypesByAlias = new ConcurrentDictionary>(StringComparer.InvariantCultureIgnoreCase); _xmap = new ConcurrentDictionary(); _genObjs = new ConcurrentQueue(); @@ -249,7 +249,7 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content types - public void NewContentTypes(IEnumerable types) + public void NewContentTypes(IEnumerable types) { var lockInfo = new WriteLockInfo(); try @@ -268,7 +268,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } } - public void UpdateContentTypes(IEnumerable types) + public void UpdateContentTypes(IEnumerable types) { var lockInfo = new WriteLockInfo(); try @@ -288,7 +288,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var node = link.Value; if (node == null) continue; var contentTypeId = node.ContentType.Id; - if (index.TryGetValue(contentTypeId, out PublishedContentType contentType) == false) continue; + if (index.TryGetValue(contentTypeId, out var contentType) == false) continue; SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor, _variationContextAccessor, _umbracoContextAccessor)); } } @@ -298,10 +298,10 @@ namespace Umbraco.Web.PublishedCache.NuCache } } - public void UpdateContentTypes(IEnumerable removedIds, IEnumerable refreshedTypes, IEnumerable kits) + public void UpdateContentTypes(IEnumerable removedIds, IEnumerable refreshedTypes, IEnumerable kits) { var removedIdsA = removedIds?.ToArray() ?? Array.Empty(); - var refreshedTypesA = refreshedTypes?.ToArray() ?? Array.Empty(); + var refreshedTypesA = refreshedTypes?.ToArray() ?? Array.Empty(); var refreshedIdsA = refreshedTypesA.Select(x => x.Id).ToArray(); kits = kits ?? Array.Empty(); @@ -377,7 +377,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } } - public void UpdateDataTypes(IEnumerable dataTypeIds, Func getContentType) + public void UpdateDataTypes(IEnumerable dataTypeIds, Func getContentType) { var lockInfo = new WriteLockInfo(); try @@ -434,7 +434,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return false; // unknown = bad - if (_contentTypesById.TryGetValue(kit.ContentTypeId, out LinkedNode link) == false || link.Value == null) + if (_contentTypesById.TryGetValue(kit.ContentTypeId, out var link) == false || link.Value == null) return false; // check whether parent is published @@ -830,12 +830,12 @@ namespace Umbraco.Web.PublishedCache.NuCache return has == false; } - public PublishedContentType GetContentType(int id, long gen) + public IPublishedContentType GetContentType(int id, long gen) { return GetValue(_contentTypesById, id, gen); } - public PublishedContentType GetContentType(string alias, long gen) + public IPublishedContentType GetContentType(string alias, long gen) { return GetValue(_contentTypesByAlias, alias, gen); } @@ -1151,14 +1151,14 @@ namespace Umbraco.Web.PublishedCache.NuCache return _store.GetAll(_gen); } - public PublishedContentType GetContentType(int id) + public IPublishedContentType GetContentType(int id) { if (_gen < 0) throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/); return _store.GetContentType(id, _gen); } - public PublishedContentType GetContentType(string alias) + public IPublishedContentType GetContentType(string alias) { if (_gen < 0) throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs index f7bdb4400f..d63035b219 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs @@ -156,12 +156,12 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content types - public override PublishedContentType GetContentType(int id) + public override IPublishedContentType GetContentType(int id) { return _snapshot.GetContentType(id); } - public override PublishedContentType GetContentType(string alias) + public override IPublishedContentType GetContentType(string alias) { return _snapshot.GetContentType(alias); } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs index f7ffe73109..5164b2b3bf 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs @@ -151,12 +151,12 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content types - public PublishedContentType GetContentType(int id) + public IPublishedContentType GetContentType(int id) { return _contentTypeCache.Get(PublishedItemType.Member, id); } - public PublishedContentType GetContentType(string alias) + public IPublishedContentType GetContentType(string alias) { return _contentTypeCache.Get(PublishedItemType.Member, alias); } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs b/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs index 18bf3ead13..310dae9dd2 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs @@ -22,10 +22,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable // changes, but they are replaced by a new instance, so our map here will clean itself automatically and // we don't have to manage cache - ConditionalWeakTable does not prevent keys from being GCed - private static readonly ConditionalWeakTable TypesMap - = new ConditionalWeakTable(); + private static readonly ConditionalWeakTable TypesMap + = new ConditionalWeakTable(); - public static NavigableContentType GetContentType(PublishedContentType contentType) + public static NavigableContentType GetContentType(IPublishedContentType contentType) { return TypesMap.GetOrCreateValue(contentType).EnsureInitialized(contentType); } @@ -49,7 +49,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable }; } - private NavigableContentType EnsureInitialized(PublishedContentType contentType) + private NavigableContentType EnsureInitialized(IPublishedContentType contentType) { lock (_locko) { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs index 057823f29c..5712d55973 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs @@ -166,7 +166,7 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content Type /// - public override PublishedContentType ContentType => _contentNode.ContentType; + public override IPublishedContentType ContentType => _contentNode.ContentType; #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs index 11ca169300..4bfcbb2a3d 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public static IPublishedContent Create( IMember member, - PublishedContentType contentType, + IPublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, @@ -53,7 +53,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor).CreateModel(); } - private static Dictionary GetPropertyValues(PublishedContentType contentType, IMember member) + private static Dictionary GetPropertyValues(IPublishedContentType contentType, IMember member) { // see node in PublishedSnapshotService // we do not (want to) support ConvertDbToXml/String @@ -91,7 +91,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return properties; } - private static void AddIf(PublishedContentType contentType, IDictionary properties, string alias, object value) + private static void AddIf(IPublishedContentType contentType, IDictionary properties, string alias, object value) { var propertyType = contentType.GetPropertyType(alias); if (propertyType == null || propertyType.IsUserProperty) return; diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index bf16074040..3b683cdd4e 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -898,11 +898,11 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Content Types - private IEnumerable CreateContentTypes(PublishedItemType itemType, int[] ids) + private IEnumerable CreateContentTypes(PublishedItemType itemType, int[] ids) { // XxxTypeService.GetAll(empty) returns everything! if (ids.Length == 0) - return Enumerable.Empty(); + return Enumerable.Empty(); IEnumerable contentTypes; switch (itemType) @@ -925,7 +925,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return contentTypes.Select(x => _publishedContentTypeFactory.CreateContentType(x)); } - private PublishedContentType CreateContentType(PublishedItemType itemType, int id) + private IPublishedContentType CreateContentType(PublishedItemType itemType, int id) { IContentTypeComposition contentType; switch (itemType) diff --git a/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs b/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs index b0fe1a4240..44f0499a63 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs @@ -88,11 +88,11 @@ namespace Umbraco.Web.PublishedCache return HasContent(PreviewDefault); } - public abstract PublishedContentType GetContentType(int id); + public abstract IPublishedContentType GetContentType(int id); - public abstract PublishedContentType GetContentType(string alias); + public abstract IPublishedContentType GetContentType(string alias); - public virtual IEnumerable GetByContentType(PublishedContentType contentType) + public virtual IEnumerable GetByContentType(IPublishedContentType contentType) { // this is probably not super-efficient, but works // some cache implementation may want to override it, though diff --git a/src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs b/src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs index ca30370598..e453471bb8 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs @@ -15,8 +15,8 @@ namespace Umbraco.Web.PublishedCache /// This cache is not snapshotted, so it refreshes any time things change. public class PublishedContentTypeCache { - private readonly Dictionary _typesByAlias = new Dictionary(); - private readonly Dictionary _typesById = new Dictionary(); + private readonly Dictionary _typesByAlias = new Dictionary(); + private readonly Dictionary _typesById = new Dictionary(); private readonly IContentTypeService _contentTypeService; private readonly IMediaTypeService _mediaTypeService; private readonly IMemberTypeService _memberTypeService; @@ -136,7 +136,7 @@ namespace Umbraco.Web.PublishedCache /// An item type. /// An alias. /// The published content type corresponding to the item type and alias. - public PublishedContentType Get(PublishedItemType itemType, string alias) + public IPublishedContentType Get(PublishedItemType itemType, string alias) { var aliasKey = GetAliasKey(itemType, alias); @@ -174,7 +174,7 @@ namespace Umbraco.Web.PublishedCache /// An item type. /// An identifier. /// The published content type corresponding to the item type and identifier. - public PublishedContentType Get(PublishedItemType itemType, int id) + public IPublishedContentType Get(PublishedItemType itemType, int id) { try { @@ -204,7 +204,7 @@ namespace Umbraco.Web.PublishedCache } } - private PublishedContentType CreatePublishedContentType(PublishedItemType itemType, string alias) + private IPublishedContentType CreatePublishedContentType(PublishedItemType itemType, string alias) { if (GetPublishedContentTypeByAlias != null) return GetPublishedContentTypeByAlias(alias); @@ -231,7 +231,7 @@ namespace Umbraco.Web.PublishedCache return _publishedContentTypeFactory.CreateContentType(contentType); } - private PublishedContentType CreatePublishedContentType(PublishedItemType itemType, int id) + private IPublishedContentType CreatePublishedContentType(PublishedItemType itemType, int id) { if (GetPublishedContentTypeById != null) return GetPublishedContentTypeById(id); @@ -259,8 +259,8 @@ namespace Umbraco.Web.PublishedCache } // for unit tests - changing the callback must reset the cache obviously - private Func _getPublishedContentTypeByAlias; - internal Func GetPublishedContentTypeByAlias + private Func _getPublishedContentTypeByAlias; + internal Func GetPublishedContentTypeByAlias { get => _getPublishedContentTypeByAlias; set @@ -282,8 +282,8 @@ namespace Umbraco.Web.PublishedCache } // for unit tests - changing the callback must reset the cache obviously - private Func _getPublishedContentTypeById; - internal Func GetPublishedContentTypeById + private Func _getPublishedContentTypeById; + internal Func GetPublishedContentTypeById { get => _getPublishedContentTypeById; set @@ -326,7 +326,7 @@ namespace Umbraco.Web.PublishedCache return k + ":" + alias; } - private static string GetAliasKey(PublishedContentType contentType) + private static string GetAliasKey(IPublishedContentType contentType) { return GetAliasKey(contentType.ItemType, contentType.Alias); } diff --git a/src/Umbraco.Web/PublishedCache/PublishedElement.cs b/src/Umbraco.Web/PublishedCache/PublishedElement.cs index 41902e3e26..618c075b9b 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedElement.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElement.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache { // initializes a new instance of the PublishedElement class // within the context of a published snapshot service (eg a published content property value) - public PublishedElement(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, + public PublishedElement(IPublishedContentType contentType, Guid key, Dictionary values, bool previewing, PropertyCacheLevel referenceCacheLevel, IPublishedSnapshotAccessor publishedSnapshotAccessor) { if (key == Guid.Empty) throw new ArgumentException("Empty guid."); @@ -46,7 +46,7 @@ namespace Umbraco.Web.PublishedCache // + using an initial reference cache level of .None ensures that everything will be // cached at .Content level - and that reference cache level will propagate to all // properties - public PublishedElement(PublishedContentType contentType, Guid key, Dictionary values, bool previewing) + public PublishedElement(IPublishedContentType contentType, Guid key, Dictionary values, bool previewing) : this(contentType, key, values, previewing, PropertyCacheLevel.None, null) { } @@ -60,7 +60,7 @@ namespace Umbraco.Web.PublishedCache #region ContentType - public PublishedContentType ContentType { get; } + public IPublishedContentType ContentType { get; } #endregion diff --git a/src/Umbraco.Web/PublishedCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/PublishedMember.cs index 419c279d46..d954411f5e 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedMember.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedMember.cs @@ -17,11 +17,11 @@ namespace Umbraco.Web.PublishedCache private readonly IMember _member; private readonly IMembershipUser _membershipUser; private readonly IPublishedProperty[] _properties; - private readonly PublishedContentType _publishedMemberType; + private readonly IPublishedContentType _publishedMemberType; public PublishedMember( IMember member, - PublishedContentType publishedMemberType, + IPublishedContentType publishedMemberType, IUmbracoContextAccessor umbracoContextAccessor) :base(umbracoContextAccessor) { @@ -126,7 +126,7 @@ namespace Umbraco.Web.PublishedCache properties.Add(property); } - public override PublishedContentType ContentType => _publishedMemberType; + public override IPublishedContentType ContentType => _publishedMemberType; public override int Id => _member.Id;