using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Routing;
namespace Umbraco.Cms.Infrastructure.PublishedCache;
///
/// Implements for NuCache.
///
public class DomainCache : IDomainCache
{
private readonly SnapDictionary.Snapshot _snapshot;
///
/// Initializes a new instance of the class.
///
public DomainCache(SnapDictionary.Snapshot snapshot, string defaultCulture)
{
_snapshot = snapshot;
DefaultCulture = defaultCulture;
}
///
public string DefaultCulture { get; }
///
public IEnumerable GetAll(bool includeWildcards)
{
IEnumerable list = _snapshot.GetAll();
if (includeWildcards == false)
{
list = list.Where(x => x.IsWildcard == false);
}
return list.OrderBy(x => x.SortOrder);
}
///
public IEnumerable GetAssigned(int documentId, bool includeWildcards = false)
{
// probably this could be optimized with an index
// but then we'd need a custom DomainStore of some sort
IEnumerable list = _snapshot.GetAll();
list = list.Where(x => x.ContentId == documentId);
if (includeWildcards == false)
{
list = list.Where(x => x.IsWildcard == false);
}
return list.OrderBy(x => x.SortOrder);
}
///
public bool HasAssigned(int documentId, bool includeWildcards = false)
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
}