Files
Umbraco-CMS/src/Umbraco.Web/PublishedCache/NuCache/DomainCache.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2016-05-27 14:26:28 +02:00
using System.Collections.Generic;
using System.Linq;
using Umbraco.Web.Routing;
namespace Umbraco.Web.PublishedCache.NuCache
{
2017-07-12 14:09:31 +02:00
internal class DomainCache : IDomainCache
2016-05-27 14:26:28 +02:00
{
private readonly SnapDictionary<int, Domain>.Snapshot _snapshot;
public DomainCache(SnapDictionary<int, Domain>.Snapshot snapshot)
{
_snapshot = snapshot;
}
public IEnumerable<Domain> GetAll(bool includeWildcards)
{
var list = _snapshot.GetAll();
if (includeWildcards == false) list = list.Where(x => x.IsWildcard == false);
return list;
}
public IEnumerable<Domain> GetAssigned(int contentId, bool includeWildcards)
{
// probably this could be optimized with an index
// but then we'd need a custom DomainStore of some sort
var list = _snapshot.GetAll();
list = list.Where(x => x.ContentId == contentId);
if (includeWildcards == false) list = list.Where(x => x.IsWildcard == false);
return list;
}
}
}