Resvolution - ContentFinderResolver
This commit is contained in:
@@ -129,6 +129,9 @@ namespace Umbraco.Web
|
||||
public static MigrationCollectionBuilder MigrationCollectionBuilder
|
||||
=> Container.GetInstance<MigrationCollectionBuilder>();
|
||||
|
||||
public static ContentFinderCollection ContentFinders
|
||||
=> Container.GetInstance<ContentFinderCollection>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Core Getters
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Web.Routing
|
||||
//TODO: The ContentFinderResolver instance should be injected in ctor with DI instead of using singleton!
|
||||
|
||||
// finder
|
||||
if (ContentFinderResolver.Current.ContainsType<ContentFinderByUrlAlias>())
|
||||
if (Current.ContentFinders.Any(x => x is ContentFinderByUrlAlias))
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
12
src/Umbraco.Web/Routing/ContentFinderCollection.cs
Normal file
12
src/Umbraco.Web/Routing/ContentFinderCollection.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.DependencyInjection;
|
||||
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
public class ContentFinderCollection : BuilderCollectionBase<IContentFinder>
|
||||
{
|
||||
public ContentFinderCollection(IEnumerable<IContentFinder> items)
|
||||
: base(items)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
14
src/Umbraco.Web/Routing/ContentFinderCollectionBuilder.cs
Normal file
14
src/Umbraco.Web/Routing/ContentFinderCollectionBuilder.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using LightInject;
|
||||
using Umbraco.Core.DependencyInjection;
|
||||
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
public class ContentFinderCollectionBuilder : OrderedCollectionBuilderBase<ContentFinderCollectionBuilder, ContentFinderCollection, IContentFinder>
|
||||
{
|
||||
public ContentFinderCollectionBuilder(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
protected override ContentFinderCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves IPublishedContentFinder objects.
|
||||
/// </summary>
|
||||
public sealed class ContentFinderResolver : ContainerManyObjectsResolver<ContentFinderResolver, IContentFinder>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentFinderResolver"/> class with an initial list of finder types.
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="finders">The list of finder types</param>
|
||||
/// <remarks>The resolver is created by the <c>WebBootManager</c> and thus the constructor remains internal.</remarks>
|
||||
internal ContentFinderResolver(IServiceContainer container, ILogger logger, IEnumerable<Type> finders)
|
||||
: base(container, logger, finders)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentFinderResolver"/> class with an initial list of finder types.
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="finders">The list of finder types</param>
|
||||
/// <param name="container"></param>
|
||||
/// <remarks>The resolver is created by the <c>WebBootManager</c> and thus the constructor remains internal.</remarks>
|
||||
internal ContentFinderResolver(IServiceContainer container, ILogger logger, params Type[] finders)
|
||||
: base(container, logger, finders)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the finders.
|
||||
/// </summary>
|
||||
public IEnumerable<IContentFinder> Finders
|
||||
{
|
||||
get { return Values; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,6 +262,8 @@
|
||||
<Compile Include="PublishedCache\XmlPublishedCache\XmlStore.cs" />
|
||||
<Compile Include="PublishedCache\XmlPublishedCache\XmlStoreFilePersister.cs" />
|
||||
<Compile Include="PublishedFragmentExtensions.cs" />
|
||||
<Compile Include="Routing\ContentFinderCollection.cs" />
|
||||
<Compile Include="Routing\ContentFinderCollectionBuilder.cs" />
|
||||
<Compile Include="Routing\Domain.cs" />
|
||||
<Compile Include="Routing\IContentLastChanceFinder.cs" />
|
||||
<Compile Include="Routing\UrlProviderCollection.cs" />
|
||||
@@ -1099,7 +1101,6 @@
|
||||
<Compile Include="Routing\ContentFinderByProfile.cs" />
|
||||
<Compile Include="PluginManagerExtensions.cs" />
|
||||
<Compile Include="Routing\DomainHelper.cs" />
|
||||
<Compile Include="Routing\ContentFinderResolver.cs" />
|
||||
<Compile Include="Routing\PublishedContentRequest.cs" />
|
||||
<Compile Include="Routing\IContentFinder.cs" />
|
||||
<Compile Include="Routing\RoutingContext.cs" />
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Web
|
||||
umbracoContext,
|
||||
|
||||
//TODO: Until the new cache is done we can't really expose these to override/mock
|
||||
new Lazy<IEnumerable<IContentFinder>>(() => ContentFinderResolver.Current.Finders),
|
||||
new Lazy<IEnumerable<IContentFinder>>(() => Web.Current.ContentFinders),
|
||||
new Lazy<IContentFinder>(() => ContentLastChanceFinderResolver.Current.Finder),
|
||||
|
||||
// create the nice urls provider
|
||||
|
||||
@@ -517,18 +517,16 @@ namespace Umbraco.Web
|
||||
ContentLastChanceFinderResolver.Current = new ContentLastChanceFinderResolver(Container);
|
||||
Container.Register<IContentLastChanceFinder, ContentFinderByLegacy404>();
|
||||
|
||||
ContentFinderResolver.Current = new ContentFinderResolver(
|
||||
Container, ProfilingLogger.Logger,
|
||||
// all built-in finders in the correct order, devs can then modify this list
|
||||
// on application startup, via an application event handler.
|
||||
typeof(ContentFinderByPageIdQuery),
|
||||
typeof(ContentFinderByNiceUrl),
|
||||
typeof(ContentFinderByIdPath),
|
||||
typeof(ContentFinderByNiceUrlAndTemplate),
|
||||
typeof(ContentFinderByProfile),
|
||||
typeof(ContentFinderByUrlAlias),
|
||||
typeof(ContentFinderByRedirectUrl)
|
||||
);
|
||||
ContentFinderCollectionBuilder.Register(Container)
|
||||
// all built-in finders in the correct order,
|
||||
// devs can then modify this list on application startup
|
||||
.Append<ContentFinderByPageIdQuery>()
|
||||
.Append<ContentFinderByNiceUrl>()
|
||||
.Append<ContentFinderByIdPath>()
|
||||
.Append<ContentFinderByNiceUrlAndTemplate>()
|
||||
.Append<ContentFinderByProfile>()
|
||||
.Append<ContentFinderByUrlAlias>()
|
||||
.Append<ContentFinderByRedirectUrl>();
|
||||
|
||||
SiteDomainHelperResolver.Current = new SiteDomainHelperResolver(Container);
|
||||
Container.Register<ISiteDomainHelper, SiteDomainHelper>();
|
||||
|
||||
Reference in New Issue
Block a user