Cleanup IPublishedCache.GetByContentType

This commit is contained in:
Stephan
2019-02-14 08:54:00 +01:00
parent 01b82ee4e8
commit fe9b964ffe
6 changed files with 16 additions and 23 deletions

View File

@@ -546,13 +546,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
return _contentTypeCache.Get(PublishedItemType.Content, alias);
}
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
{
return GetAtRoot()
.SelectMany(x => x.DescendantsOrSelf())
.Where(x => x.ContentType == contentType);
}
#endregion
}
}

View File

@@ -620,7 +620,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
#endregion

View File

@@ -208,7 +208,12 @@ namespace Umbraco.Web.PublishedCache
/// <returns>The content type, or null.</returns>
/// <remarks>The alias is case-insensitive.</remarks>
PublishedContentType GetContentType(string alias);
/// <summary>
/// Gets contents of a given content type.
/// </summary>
/// <param name="contentType">The content type.</param>
/// <returns>The contents.</returns>
IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType);
}
}

View File

@@ -386,13 +386,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
return _snapshot.GetContentType(alias);
}
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
{
return GetAtRoot()
.SelectMany(x => x.DescendantsOrSelf())
.Where(x => x.ContentType == contentType);
}
#endregion
#region IDisposable

View File

@@ -166,11 +166,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
return _snapshot.GetContentType(alias);
}
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
{
throw new NotImplementedException();
}
#endregion
#region IDisposable

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.XPath;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Xml;
using Umbraco.Core.Models;
namespace Umbraco.Web.PublishedCache
{
@@ -92,6 +92,13 @@ namespace Umbraco.Web.PublishedCache
public abstract PublishedContentType GetContentType(string alias);
public abstract IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType);
public virtual IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
{
// this is probably not super-efficient, but works
// some cache implementation may want to override it, though
return GetAtRoot()
.SelectMany(x => x.DescendantsOrSelf())
.Where(x => x.ContentType.Id == contentType.Id);
}
}
}