V10: fix build warnings nucache (#12500)
* Run code cleanup * Finish dotnet format and manual cleanup * Fix according to review Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -1,51 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.PublishedCache
|
||||
namespace Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
|
||||
/// <summary>
|
||||
/// Implements <see cref="IDomainCache" /> for NuCache.
|
||||
/// </summary>
|
||||
public class DomainCache : IDomainCache
|
||||
{
|
||||
private readonly SnapDictionary<int, Domain>.Snapshot _snapshot;
|
||||
|
||||
/// <summary>
|
||||
/// Implements <see cref="IDomainCache"/> for NuCache.
|
||||
/// Initializes a new instance of the <see cref="DomainCache" /> class.
|
||||
/// </summary>
|
||||
public class DomainCache : IDomainCache
|
||||
public DomainCache(SnapDictionary<int, Domain>.Snapshot snapshot, string defaultCulture)
|
||||
{
|
||||
private readonly SnapDictionary<int, Domain>.Snapshot _snapshot;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DomainCache"/> class.
|
||||
/// </summary>
|
||||
public DomainCache(SnapDictionary<int, Domain>.Snapshot snapshot, string defaultCulture)
|
||||
{
|
||||
_snapshot = snapshot;
|
||||
DefaultCulture = defaultCulture;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<Domain> GetAll(bool includeWildcards)
|
||||
{
|
||||
var list = _snapshot.GetAll();
|
||||
if (includeWildcards == false) list = list.Where(x => x.IsWildcard == false);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<Domain> 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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasAssigned(int documentId, bool includeWildcards = false)
|
||||
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DefaultCulture { get; }
|
||||
_snapshot = snapshot;
|
||||
DefaultCulture = defaultCulture;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DefaultCulture { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<Domain> GetAll(bool includeWildcards)
|
||||
{
|
||||
IEnumerable<Domain> list = _snapshot.GetAll();
|
||||
if (includeWildcards == false)
|
||||
{
|
||||
list = list.Where(x => x.IsWildcard == false);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<Domain> 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<Domain> list = _snapshot.GetAll();
|
||||
list = list.Where(x => x.ContentId == documentId);
|
||||
if (includeWildcards == false)
|
||||
{
|
||||
list = list.Where(x => x.IsWildcard == false);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasAssigned(int documentId, bool includeWildcards = false)
|
||||
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user