Files
Umbraco-CMS/src/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs

45 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
internal class DomainCache : IDomainCache
{
private readonly IDomainService _domainService;
2018-04-30 21:29:49 +02:00
public DomainCache(IDomainService domainService, IDefaultCultureAccessor defaultCultureAccessor)
{
_domainService = domainService;
2018-04-30 21:29:49 +02:00
DefaultCulture = defaultCultureAccessor.DefaultCulture;
}
/// <inheritdoc />
public IEnumerable<Domain> GetAll(bool includeWildcards)
{
return _domainService.GetAll(includeWildcards)
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
2018-04-26 16:03:08 +02:00
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard));
}
/// <inheritdoc />
public IEnumerable<Domain> GetAssigned(int documentId, bool includeWildcards = false)
{
return _domainService.GetAssignedDomains(documentId, includeWildcards)
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
2018-04-26 16:03:08 +02:00
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard));
}
2018-04-26 16:03:08 +02:00
/// <inheritdoc />
public bool HasAssigned(int documentId, bool includeWildcards = false)
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
/// <inheritdoc />
2018-04-26 16:03:08 +02:00
public string DefaultCulture { get; }
}
}