implement noop published snapshot service, splits tests models for published content, fixes sqlce image mapper to not have circular ref.
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.PublishedCache.Internal
|
||||
{
|
||||
|
||||
public sealed class InternalPublishedContent : IPublishedContent
|
||||
{
|
||||
public InternalPublishedContent(IPublishedContentType contentType)
|
||||
{
|
||||
// initialize boring stuff
|
||||
TemplateId = 0;
|
||||
WriterId = CreatorId = 0;
|
||||
CreateDate = UpdateDate = DateTime.Now;
|
||||
Version = Guid.Empty;
|
||||
|
||||
ContentType = contentType;
|
||||
}
|
||||
|
||||
private Dictionary<string, PublishedCultureInfo> _cultures;
|
||||
|
||||
private Dictionary<string, PublishedCultureInfo> GetCultures() => new Dictionary<string, PublishedCultureInfo> { { string.Empty, new PublishedCultureInfo(string.Empty, Name, UrlSegment, UpdateDate) } };
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public Guid Key { get; set; }
|
||||
|
||||
public int? TemplateId { get; set; }
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public IReadOnlyDictionary<string, PublishedCultureInfo> Cultures => _cultures ??= GetCultures();
|
||||
|
||||
public string UrlSegment { get; set; }
|
||||
|
||||
public int WriterId { get; set; }
|
||||
|
||||
public int CreatorId { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public DateTime CreateDate { get; set; }
|
||||
|
||||
public DateTime UpdateDate { get; set; }
|
||||
|
||||
public Guid Version { get; set; }
|
||||
|
||||
public int Level { get; set; }
|
||||
|
||||
public PublishedItemType ItemType => PublishedItemType.Content;
|
||||
|
||||
public bool IsDraft(string culture = null) => false;
|
||||
|
||||
public bool IsPublished(string culture = null) => true;
|
||||
|
||||
public int ParentId { get; set; }
|
||||
|
||||
public IEnumerable<int> ChildIds { get; set; }
|
||||
|
||||
public IPublishedContent Parent { get; set; }
|
||||
|
||||
public IEnumerable<IPublishedContent> Children { get; set; }
|
||||
|
||||
public IEnumerable<IPublishedContent> ChildrenForAllCultures => Children;
|
||||
|
||||
public IPublishedContentType ContentType { get; set; }
|
||||
|
||||
public IEnumerable<IPublishedProperty> Properties { get; set; }
|
||||
|
||||
public IPublishedProperty GetProperty(string alias) => Properties.FirstOrDefault(p => p.Alias.InvariantEquals(alias));
|
||||
|
||||
public IPublishedProperty GetProperty(string alias, bool recurse)
|
||||
{
|
||||
IPublishedProperty property = GetProperty(alias);
|
||||
if (recurse == false)
|
||||
{
|
||||
return property;
|
||||
}
|
||||
|
||||
IPublishedContent content = this;
|
||||
while (content != null && (property == null || property.HasValue() == false))
|
||||
{
|
||||
content = content.Parent;
|
||||
property = content?.GetProperty(alias);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
public object this[string alias]
|
||||
{
|
||||
get
|
||||
{
|
||||
var property = GetProperty(alias);
|
||||
return property == null || property.HasValue() == false ? null : property.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Xml;
|
||||
|
||||
namespace Umbraco.Cms.Core.PublishedCache.Internal
|
||||
{
|
||||
public sealed class InternalPublishedContentCache : PublishedCacheBase, IPublishedContentCache, IPublishedMediaCache
|
||||
{
|
||||
private readonly Dictionary<int, IPublishedContent> _content = new Dictionary<int, IPublishedContent>();
|
||||
|
||||
public InternalPublishedContentCache()
|
||||
: base(false)
|
||||
{
|
||||
}
|
||||
|
||||
//public void Add(InternalPublishedContent content) => _content[content.Id] = content.CreateModel(Mock.Of<IPublishedModelFactory>());
|
||||
|
||||
public void Clear() => _content.Clear();
|
||||
|
||||
public IPublishedContent GetByRoute(bool preview, string route, bool? hideTopLevelNode = null, string culture = null) => throw new NotImplementedException();
|
||||
|
||||
public IPublishedContent GetByRoute(string route, bool? hideTopLevelNode = null, string culture = null) => throw new NotImplementedException();
|
||||
|
||||
public string GetRouteById(bool preview, int contentId, string culture = null) => throw new NotImplementedException();
|
||||
|
||||
public string GetRouteById(int contentId, string culture = null) => throw new NotImplementedException();
|
||||
|
||||
public override IPublishedContent GetById(bool preview, int contentId) => _content.ContainsKey(contentId) ? _content[contentId] : null;
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Guid contentId) => throw new NotImplementedException();
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Udi nodeId) => throw new NotSupportedException();
|
||||
|
||||
public override bool HasById(bool preview, int contentId) => _content.ContainsKey(contentId);
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview, string culture = null) => _content.Values.Where(x => x.Parent == null);
|
||||
|
||||
public override IPublishedContent GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars) => throw new NotImplementedException();
|
||||
|
||||
public override IPublishedContent GetSingleByXPath(bool preview, System.Xml.XPath.XPathExpression xpath, XPathVariable[] vars) => throw new NotImplementedException();
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, XPathVariable[] vars) => throw new NotImplementedException();
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, System.Xml.XPath.XPathExpression xpath, XPathVariable[] vars) => throw new NotImplementedException();
|
||||
|
||||
public override System.Xml.XPath.XPathNavigator CreateNavigator(bool preview) => throw new NotImplementedException();
|
||||
|
||||
public override System.Xml.XPath.XPathNavigator CreateNodeNavigator(int id, bool preview) => throw new NotImplementedException();
|
||||
|
||||
public override bool HasContent(bool preview) => _content.Count > 0;
|
||||
|
||||
public override IPublishedContentType GetContentType(int id) => throw new NotImplementedException();
|
||||
|
||||
public override IPublishedContentType GetContentType(string alias) => throw new NotImplementedException();
|
||||
|
||||
public override IPublishedContentType GetContentType(Guid key) => throw new NotImplementedException();
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetByContentType(IPublishedContentType contentType) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Cms.Core.PublishedCache.Internal
|
||||
{
|
||||
public class InternalPublishedProperty : IPublishedProperty
|
||||
{
|
||||
public IPublishedPropertyType PropertyType { get; set; }
|
||||
|
||||
public string Alias { get; set; }
|
||||
|
||||
public object SolidSourceValue { get; set; }
|
||||
|
||||
public object SolidValue { get; set; }
|
||||
|
||||
public bool SolidHasValue { get; set; }
|
||||
|
||||
public object SolidXPathValue { get; set; }
|
||||
|
||||
public virtual object GetSourceValue(string culture = null, string segment = null) => SolidSourceValue;
|
||||
|
||||
public virtual object GetValue(string culture = null, string segment = null) => SolidValue;
|
||||
|
||||
public virtual object GetXPathValue(string culture = null, string segment = null) => SolidXPathValue;
|
||||
|
||||
public virtual bool HasValue(string culture = null, string segment = null) => SolidHasValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
|
||||
namespace Umbraco.Cms.Core.PublishedCache.Internal
|
||||
{
|
||||
public sealed class InternalPublishedSnapshot : IPublishedSnapshot
|
||||
{
|
||||
public InternalPublishedContentCache InnerContentCache { get; } = new InternalPublishedContentCache();
|
||||
public InternalPublishedContentCache InnerMediaCache { get; } = new InternalPublishedContentCache();
|
||||
|
||||
public IPublishedContentCache Content => InnerContentCache;
|
||||
|
||||
public IPublishedMediaCache Media => InnerMediaCache;
|
||||
|
||||
public IPublishedMemberCache Members => null;
|
||||
|
||||
public IDomainCache Domains => null;
|
||||
|
||||
public IDisposable ForcedPreview(bool forcedPreview, Action<bool> callback = null) => throw new NotImplementedException();
|
||||
|
||||
public void Resync()
|
||||
{
|
||||
}
|
||||
|
||||
public IAppCache SnapshotCache => null;
|
||||
|
||||
public IAppCache ElementsCache => null;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.PublishedCache.Internal
|
||||
{
|
||||
public class InternalPublishedSnapshotService : IPublishedSnapshotService
|
||||
{
|
||||
private InternalPublishedSnapshot _snapshot;
|
||||
private InternalPublishedSnapshot _previewSnapshot;
|
||||
|
||||
public Task CollectAsync() => Task.CompletedTask;
|
||||
|
||||
public IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
|
||||
{
|
||||
if (previewToken.IsNullOrWhiteSpace())
|
||||
{
|
||||
return _snapshot ??= new InternalPublishedSnapshot();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _previewSnapshot ??= new InternalPublishedSnapshot();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_snapshot?.Dispose();
|
||||
_previewSnapshot?.Dispose();
|
||||
}
|
||||
|
||||
public void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
|
||||
{
|
||||
draftChanged = false;
|
||||
publishedChanged = false;
|
||||
}
|
||||
|
||||
public void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
|
||||
{
|
||||
anythingChanged = false;
|
||||
}
|
||||
|
||||
public void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
}
|
||||
|
||||
public void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
}
|
||||
|
||||
public void Notify(DomainCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
}
|
||||
|
||||
public void Rebuild(IReadOnlyCollection<int> contentTypeIds = null, IReadOnlyCollection<int> mediaTypeIds = null, IReadOnlyCollection<int> memberTypeIds = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user