rename routing 'resolvers' to 'lookups'

This commit is contained in:
sgay
2012-07-26 12:56:41 -02:00
parent a08c698c77
commit fec2e0eb6e
6 changed files with 36 additions and 36 deletions

View File

@@ -13,7 +13,7 @@ namespace Umbraco.Web
public static class PluginResolverExtensions
{
private static volatile IEnumerable<IRequestDocumentResolver> _lookups;
private static volatile IEnumerable<IDocumentLookup> _lookups;
private static readonly object Locker = new object();
/// <summary>
@@ -21,7 +21,7 @@ namespace Umbraco.Web
/// </summary>
/// <param name="plugins"></param>
/// <returns></returns>
internal static IEnumerable<IRequestDocumentResolver> ResolveLookups(this PluginResolver plugins)
internal static IEnumerable<IDocumentLookup> ResolveLookups(this PluginResolver plugins)
{
if (_lookups == null)
{
@@ -29,13 +29,13 @@ namespace Umbraco.Web
{
if (_lookups == null)
{
var lookupTypes = TypeFinder.FindClassesOfType<IRequestDocumentResolver>();
var lookups = new List<IRequestDocumentResolver>();
var lookupTypes = TypeFinder.FindClassesOfType<IDocumentLookup>();
var lookups = new List<IDocumentLookup>();
foreach (var l in lookupTypes)
{
try
{
var typeInstance = Activator.CreateInstance(l) as IRequestDocumentResolver;
var typeInstance = Activator.CreateInstance(l) as IDocumentLookup;
lookups.Add(typeInstance);
}
catch (Exception ex)

View File

@@ -140,15 +140,15 @@ namespace Umbraco.Web.Routing
#endregion
#region Resolve
#region Lookup
/// <summary>
/// Determines the site root (if any) matching the http request.
/// </summary>
/// <returns>A value indicating whether a domain was found.</returns>
public bool ResolveDomain()
public bool LookupDomain()
{
const string tracePrefix = "ResolveDomain: ";
const string tracePrefix = "LookupDomain: ";
// note - we are not handling schemes nor ports here.
@@ -193,17 +193,17 @@ namespace Umbraco.Web.Routing
/// Determines the Umbraco document (if any) matching the http request.
/// </summary>
/// <returns>A value indicating whether a document and template nave been found.</returns>
public bool ResolveDocument()
public bool LookupDocument()
{
const string tracePrefix = "ResolveDocument: ";
const string tracePrefix = "LookupDocument: ";
Trace.TraceInformation("{0}Path=\"{1}\"", tracePrefix, this.Uri.AbsolutePath);
// look for the document
// the first successful resolver, if any, will set this.Node, and may also set this.Template
// some lookups may implement caching
Trace.TraceInformation("{0}Begin resolvers", tracePrefix);
var resolvers = RoutingContext.RequestDocumentResolversResolver.RequestDocumentResolvers;
resolvers.Any(resolver => resolver.TrySetDocument(this));
var lookups = RoutingContext.DocumentLookupsResolver.DocumentLookups;
lookups.Any(lookup => lookup.TrySetDocument(this));
Trace.TraceInformation("{0}End resolvers, {1}", tracePrefix, (this.HasNode ? "a document was found" : "no document was found"));
// fixme - not handling umbracoRedirect
@@ -211,7 +211,7 @@ namespace Umbraco.Web.Routing
// so after ResolveDocument2() => docreq.IsRedirect => handled by the module!
// handle not-found, redirects, access, template
ResolveDocument2();
LookupDocument2();
// handle umbracoRedirect (moved from umbraco.page)
FollowRedirect();
@@ -224,9 +224,9 @@ namespace Umbraco.Web.Routing
/// Performs the document resolution second pass.
/// </summary>
/// <remarks>The second pass consists in handling "not found", internal redirects, access validation, and template.</remarks>
void ResolveDocument2()
void LookupDocument2()
{
const string tracePrefix = "ResolveDocument2: ";
const string tracePrefix = "LookupDocument2: ";
// handle "not found", follow internal redirects, validate access, template
// because these might loop, we have to have some sort of infinite loop detection
@@ -240,10 +240,10 @@ namespace Umbraco.Web.Routing
if (!this.HasNode)
{
this.Is404 = true;
Trace.TraceInformation("{0}No document, try notFound lookup", tracePrefix);
Trace.TraceInformation("{0}No document, try last chance lookup", tracePrefix);
// if it fails then give up, there isn't much more that we can do
var lastChance = RoutingContext.RequestDocumentResolversResolver.RequestDocumentLastChanceResolver;
var lastChance = RoutingContext.DocumentLookupsResolver.DocumentLastChanceLookup;
if (lastChance == null || !lastChance.TrySetDocument(this))
{
Trace.TraceInformation("{0}Failed to find a document, give up", tracePrefix);
@@ -267,7 +267,7 @@ namespace Umbraco.Web.Routing
// resolve template
if (this.HasNode)
ResolveTemplate();
LookupTemplate();
// loop while we don't have page, ie the redirect or access
// got us to nowhere and now we need to run the notFoundLookup again
@@ -384,9 +384,9 @@ namespace Umbraco.Web.Routing
/// <summary>
/// Resolves a template for the current node.
/// </summary>
void ResolveTemplate()
void LookupTemplate()
{
const string tracePrefix = "ResolveTemplate: ";
const string tracePrefix = "LookupTemplate: ";
if (this.Node == null)
throw new InvalidOperationException("There is no node.");

View File

@@ -12,18 +12,18 @@ namespace Umbraco.Web.Routing
{
public RoutingContext(
UmbracoContext umbracoContext,
RequestDocumentResolversResolver requestDocumentResolversResolver,
DocumentLookupsResolver documentLookupsResolver,
ContentStore contentStore,
NiceUrlProvider niceUrlResolver)
{
this.UmbracoContext = umbracoContext;
this.RequestDocumentResolversResolver = requestDocumentResolversResolver;
this.DocumentLookupsResolver = documentLookupsResolver;
this.ContentStore = contentStore;
this.NiceUrlProvider = niceUrlResolver;
}
public UmbracoContext UmbracoContext { get; private set; }
public RequestDocumentResolversResolver RequestDocumentResolversResolver { get; private set; }
public DocumentLookupsResolver DocumentLookupsResolver { get; private set; }
public ContentStore ContentStore { get; private set; }
public NiceUrlProvider NiceUrlProvider { get; private set; }
}

View File

@@ -243,17 +243,17 @@
<Compile Include="Routing\NiceUrlProvider.cs" />
<Compile Include="PluginResolverExtensions.cs" />
<Compile Include="Routing\Domains.cs" />
<Compile Include="Routing\RequestDocumentResolversResolver.cs" />
<Compile Include="Routing\DocumentLookupsResolver.cs" />
<Compile Include="Routing\DocumentRequest.cs" />
<Compile Include="Routing\IRequestDocumentResolver.cs" />
<Compile Include="Routing\IRequestDocumentLastChanceResolver.cs" />
<Compile Include="Routing\IDocumentLookup.cs" />
<Compile Include="Routing\IDocumentLastChanceLookup.cs" />
<Compile Include="Routing\IRoutesCache.cs" />
<Compile Include="Routing\ResolveByAlias.cs" />
<Compile Include="Routing\ResolveById.cs" />
<Compile Include="Routing\ResolveByNiceUrl.cs" />
<Compile Include="Routing\ResolveByNiceUrlAndTemplate.cs" />
<Compile Include="Routing\ResolveByProfile.cs" />
<Compile Include="Routing\ResolveLastChance.cs" />
<Compile Include="Routing\LookupByAlias.cs" />
<Compile Include="Routing\LookupById.cs" />
<Compile Include="Routing\LookupByNiceUrl.cs" />
<Compile Include="Routing\LookupByNiceUrlAndTemplate.cs" />
<Compile Include="Routing\LookupByProfile.cs" />
<Compile Include="Routing\DefaultLastChanceLookup.cs" />
<Compile Include="Routing\DefaultRoutesCache.cs" />
<Compile Include="Routing\RoutesCacheResolver.cs" />
<Compile Include="Routing\RoutingContext.cs" />

View File

@@ -36,7 +36,7 @@ namespace Umbraco.Web
};
// create the resolvers
RequestDocumentResolversResolver.Current = new RequestDocumentResolversResolver(ApplicationContext.Current.Plugins.ResolveLookups(), new ResolveLastChance());
DocumentLookupsResolver.Current = new DocumentLookupsResolver(ApplicationContext.Current.Plugins.ResolveLookups(), new DefaultLastChanceLookup());
RoutesCacheResolver.Current = new RoutesCacheResolver(new DefaultRoutesCache());
Umbraco.Core.Resolving.Resolution.Freeze();

View File

@@ -58,7 +58,7 @@ namespace Umbraco.Web
//create the RoutingContext (one per http request)
var routingContext = new RoutingContext(
umbracoContext,
RequestDocumentResolversResolver.Current,
DocumentLookupsResolver.Current,
contentStore,
niceUrls);
// NOT HERE BUT SEE **THERE** BELOW
@@ -106,11 +106,11 @@ namespace Umbraco.Web
//**THERE** we should create the doc request
// before, we're not sure we handling a doc request
docreq.ResolveDomain();
docreq.LookupDomain();
if (docreq.IsRedirect)
httpContext.Response.Redirect(docreq.RedirectUrl, true);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = docreq.Culture;
docreq.ResolveDocument();
docreq.LookupDocument();
if (docreq.IsRedirect)
httpContext.Response.Redirect(docreq.RedirectUrl, true);