2016-05-26 17:12:04 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Umbraco.Web.Routing;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
|
|
|
|
|
{
|
2018-04-24 13:07:18 +10:00
|
|
|
|
internal class DomainCache : IDomainCache
|
2016-05-26 17:12:04 +02:00
|
|
|
|
{
|
|
|
|
|
|
private readonly IDomainService _domainService;
|
|
|
|
|
|
|
2018-04-30 21:29:49 +02:00
|
|
|
|
public DomainCache(IDomainService domainService, IDefaultCultureAccessor defaultCultureAccessor)
|
2016-05-26 17:12:04 +02:00
|
|
|
|
{
|
|
|
|
|
|
_domainService = domainService;
|
2018-04-30 21:29:49 +02:00
|
|
|
|
DefaultCulture = defaultCultureAccessor.DefaultCulture;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-10 23:07:33 +10:00
|
|
|
|
/// <inheritdoc />
|
2016-05-26 17:12:04 +02:00
|
|
|
|
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));
|
2016-05-26 17:12:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-10 23:07:33 +10:00
|
|
|
|
/// <inheritdoc />
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public IEnumerable<Domain> GetAssigned(int contentId, bool includeWildcards)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _domainService.GetAssignedDomains(contentId, 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));
|
2016-05-26 17:12:04 +02:00
|
|
|
|
}
|
2018-04-26 16:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
public string DefaultCulture { get; }
|
2016-05-26 17:12:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|