Renamed the project to Umbraco.PublishedCache.NuCache - and move non NuCache related stuff to abstractions and infrastructure.
This commit is contained in:
50
src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs
Normal file
50
src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
// what's needed to actually build a content node
|
||||
public struct ContentNodeKit
|
||||
{
|
||||
public ContentNode Node;
|
||||
public int ContentTypeId;
|
||||
public ContentData DraftData;
|
||||
public ContentData PublishedData;
|
||||
|
||||
public bool IsEmpty => Node == null;
|
||||
|
||||
public bool IsNull => ContentTypeId < 0;
|
||||
|
||||
public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 };
|
||||
|
||||
public void Build(
|
||||
IPublishedContentType contentType,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IPublishedModelFactory publishedModelFactory,
|
||||
bool canBePublished)
|
||||
{
|
||||
var draftData = DraftData;
|
||||
|
||||
// no published data if it cannot be published (eg is masked)
|
||||
var publishedData = canBePublished ? PublishedData : null;
|
||||
|
||||
// we *must* have either published or draft data
|
||||
// if it cannot be published, published data is going to be null
|
||||
// therefore, ensure that draft data is not
|
||||
if (draftData == null && !canBePublished)
|
||||
draftData = PublishedData;
|
||||
|
||||
Node.SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor, publishedModelFactory);
|
||||
}
|
||||
|
||||
public ContentNodeKit Clone(IPublishedModelFactory publishedModelFactory)
|
||||
=> new ContentNodeKit
|
||||
{
|
||||
ContentTypeId = ContentTypeId,
|
||||
DraftData = DraftData,
|
||||
PublishedData = PublishedData,
|
||||
Node = new ContentNode(Node, publishedModelFactory)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user