Introduce IPublishedContentType
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<int>();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<ContentNode>> _contentNodes;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<object>> _contentRootNodes;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<PublishedContentType>> _contentTypesById;
|
||||
private readonly ConcurrentDictionary<string, LinkedNode<PublishedContentType>> _contentTypesByAlias;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<IPublishedContentType>> _contentTypesById;
|
||||
private readonly ConcurrentDictionary<string, LinkedNode<IPublishedContentType>> _contentTypesByAlias;
|
||||
private readonly ConcurrentDictionary<Guid, int> _xmap;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
@@ -61,8 +61,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
_contentNodes = new ConcurrentDictionary<int, LinkedNode<ContentNode>>();
|
||||
_contentRootNodes = new ConcurrentDictionary<int, LinkedNode<object>>();
|
||||
_contentTypesById = new ConcurrentDictionary<int, LinkedNode<PublishedContentType>>();
|
||||
_contentTypesByAlias = new ConcurrentDictionary<string, LinkedNode<PublishedContentType>>(StringComparer.InvariantCultureIgnoreCase);
|
||||
_contentTypesById = new ConcurrentDictionary<int, LinkedNode<IPublishedContentType>>();
|
||||
_contentTypesByAlias = new ConcurrentDictionary<string, LinkedNode<IPublishedContentType>>(StringComparer.InvariantCultureIgnoreCase);
|
||||
_xmap = new ConcurrentDictionary<Guid, int>();
|
||||
|
||||
_genObjs = new ConcurrentQueue<GenObj>();
|
||||
@@ -249,7 +249,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Content types
|
||||
|
||||
public void NewContentTypes(IEnumerable<PublishedContentType> types)
|
||||
public void NewContentTypes(IEnumerable<IPublishedContentType> types)
|
||||
{
|
||||
var lockInfo = new WriteLockInfo();
|
||||
try
|
||||
@@ -268,7 +268,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateContentTypes(IEnumerable<PublishedContentType> types)
|
||||
public void UpdateContentTypes(IEnumerable<IPublishedContentType> 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<int> removedIds, IEnumerable<PublishedContentType> refreshedTypes, IEnumerable<ContentNodeKit> kits)
|
||||
public void UpdateContentTypes(IEnumerable<int> removedIds, IEnumerable<IPublishedContentType> refreshedTypes, IEnumerable<ContentNodeKit> kits)
|
||||
{
|
||||
var removedIdsA = removedIds?.ToArray() ?? Array.Empty<int>();
|
||||
var refreshedTypesA = refreshedTypes?.ToArray() ?? Array.Empty<PublishedContentType>();
|
||||
var refreshedTypesA = refreshedTypes?.ToArray() ?? Array.Empty<IPublishedContentType>();
|
||||
var refreshedIdsA = refreshedTypesA.Select(x => x.Id).ToArray();
|
||||
kits = kits ?? Array.Empty<ContentNodeKit>();
|
||||
|
||||
@@ -377,7 +377,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDataTypes(IEnumerable<int> dataTypeIds, Func<int, PublishedContentType> getContentType)
|
||||
public void UpdateDataTypes(IEnumerable<int> dataTypeIds, Func<int, IPublishedContentType> 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<PublishedContentType> 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 + ")"*/);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<PublishedContentType, NavigableContentType> TypesMap
|
||||
= new ConditionalWeakTable<PublishedContentType,NavigableContentType>();
|
||||
private static readonly ConditionalWeakTable<IPublishedContentType, NavigableContentType> TypesMap
|
||||
= new ConditionalWeakTable<IPublishedContentType,NavigableContentType>();
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
#region Content Type
|
||||
|
||||
/// <inheritdoc />
|
||||
public override PublishedContentType ContentType => _contentNode.ContentType;
|
||||
public override IPublishedContentType ContentType => _contentNode.ContentType;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -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<string, PropertyData[]> GetPropertyValues(PublishedContentType contentType, IMember member)
|
||||
private static Dictionary<string, PropertyData[]> 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<string, PropertyData[]> properties, string alias, object value)
|
||||
private static void AddIf(IPublishedContentType contentType, IDictionary<string, PropertyData[]> properties, string alias, object value)
|
||||
{
|
||||
var propertyType = contentType.GetPropertyType(alias);
|
||||
if (propertyType == null || propertyType.IsUserProperty) return;
|
||||
|
||||
@@ -898,11 +898,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Content Types
|
||||
|
||||
private IEnumerable<PublishedContentType> CreateContentTypes(PublishedItemType itemType, int[] ids)
|
||||
private IEnumerable<IPublishedContentType> CreateContentTypes(PublishedItemType itemType, int[] ids)
|
||||
{
|
||||
// XxxTypeService.GetAll(empty) returns everything!
|
||||
if (ids.Length == 0)
|
||||
return Enumerable.Empty<PublishedContentType>();
|
||||
return Enumerable.Empty<IPublishedContentType>();
|
||||
|
||||
IEnumerable<IContentTypeComposition> 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)
|
||||
|
||||
Reference in New Issue
Block a user