using System.Collections.Generic; using System.Linq; using Umbraco.Web.Routing; namespace Umbraco.Web.PublishedCache.NuCache { /// /// Implements for NuCache. /// internal 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 IEnumerable GetAll(bool includeWildcards) { var list = _snapshot.GetAll(); if (includeWildcards == false) list = list.Where(x => x.IsWildcard == false); return list; } /// 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 var list = _snapshot.GetAll(); list = list.Where(x => x.ContentId == documentId); if (includeWildcards == false) list = list.Where(x => x.IsWildcard == false); return list; } /// public bool HasAssigned(int documentId, bool includeWildcards = false) => documentId > 0 && GetAssigned(documentId, includeWildcards).Any(); /// public string DefaultCulture { get; } } }