Refactor DomainHelper

This commit is contained in:
Stephan
2018-04-26 16:03:08 +02:00
parent 9407f75522
commit dbf1b1e0d4
28 changed files with 493 additions and 375 deletions

View File

@@ -4,33 +4,33 @@ using System.Linq;
using Umbraco.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Core.Models;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
{
internal class DomainCache : IDomainCache
{
private readonly IDomainService _domainService;
private readonly ILocalizationService _localizationService;
public DomainCache(IDomainService domainService, ILocalizationService localizationService)
{
_domainService = domainService;
_localizationService = localizationService;
DefaultCulture = localizationService.GetDefaultLanguageIsoCode(); // capture - fast
}
public IEnumerable<Domain> GetAll(bool includeWildcards)
{
return _domainService.GetAll(includeWildcards)
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard, x.IsDefaultDomain(_localizationService)));
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard));
}
public IEnumerable<Domain> GetAssigned(int contentId, bool includeWildcards)
{
return _domainService.GetAssignedDomains(contentId, includeWildcards)
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard, x.IsDefaultDomain(_localizationService)));
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard));
}
public string DefaultCulture { get; }
}
}