Resvolution - CacheRefresherResolver
This commit is contained in:
17
src/Umbraco.Core/Cache/CacheRefresherCollection.cs
Normal file
17
src/Umbraco.Core/Cache/CacheRefresherCollection.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.DependencyInjection;
|
||||
|
||||
namespace Umbraco.Core.Cache
|
||||
{
|
||||
public class CacheRefresherCollection : BuilderCollectionBase<ICacheRefresher>
|
||||
{
|
||||
public CacheRefresherCollection(IEnumerable<ICacheRefresher> items)
|
||||
: base(items)
|
||||
{ }
|
||||
|
||||
public ICacheRefresher this[Guid id]
|
||||
=> this.FirstOrDefault(x => x.RefresherUniqueId == id);
|
||||
}
|
||||
}
|
||||
15
src/Umbraco.Core/Cache/CacheRefresherCollectionBuilder.cs
Normal file
15
src/Umbraco.Core/Cache/CacheRefresherCollectionBuilder.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using LightInject;
|
||||
using Umbraco.Core.DependencyInjection;
|
||||
|
||||
namespace Umbraco.Core.Cache
|
||||
{
|
||||
public class CacheRefresherCollectionBuilder : LazyCollectionBuilderBase<CacheRefresherCollectionBuilder, CacheRefresherCollection, ICacheRefresher>
|
||||
{
|
||||
public CacheRefresherCollectionBuilder(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
protected override CacheRefresherCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
|
||||
namespace Umbraco.Core.Cache
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A resolver to return all ICacheRefresher objects
|
||||
/// </summary>
|
||||
internal sealed class CacheRefreshersResolver : ContainerLazyManyObjectsResolver<CacheRefreshersResolver, ICacheRefresher>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="serviceContainer"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="refreshers"></param>
|
||||
internal CacheRefreshersResolver(IServiceContainer serviceContainer, ILogger logger, Func<IEnumerable<Type>> refreshers)
|
||||
: base(serviceContainer, logger, refreshers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ICacheRefresher"/> implementations.
|
||||
/// </summary>
|
||||
public IEnumerable<ICacheRefresher> CacheRefreshers => Values;
|
||||
|
||||
/// <summary>
|
||||
/// Returns an instance for the type identified by its unique type identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The type identifier.</param>
|
||||
/// <returns>The value of the type uniquely identified by <paramref name="id"/>.</returns>
|
||||
public ICacheRefresher GetById(Guid id)
|
||||
{
|
||||
return Values.FirstOrDefault(x => x.RefresherUniqueId == id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user