Changed RoutingEnvironment to RoutingContet. Cleaned up how the context reference each other, now

this starts making a bunch of sense. Have empty ctor's on all ILookups since their methods get passed a
 DocumentRequest object which has access to all of the context's and properties that they will ever need.
This commit is contained in:
shannon@ShandemVaio
2012-07-21 00:20:50 +06:00
parent 8f278bcaa5
commit be51bfa67f
14 changed files with 129 additions and 169 deletions

View File

@@ -12,16 +12,14 @@ namespace Umbraco.Web
/// </summary>
internal class NiceUrlResolver
{
public NiceUrlResolver(ContentStore contentStore, UmbracoContext umbracoContext, IRoutesCache routesCache)
public NiceUrlResolver(ContentStore contentStore, UmbracoContext umbracoContext)
{
_umbracoContext = umbracoContext;
_contentStore = contentStore;
_routesCache = routesCache;
}
private readonly UmbracoContext _umbracoContext;
private readonly ContentStore _contentStore;
private readonly IRoutesCache _routesCache;
// note: this could be a parameter...
const string UrlNameProperty = "@urlName";
@@ -41,7 +39,7 @@ namespace Umbraco.Web
// will not read cache if previewing!
var route = !_umbracoContext.InPreviewMode
? _routesCache.GetRoute(nodeId)
? _umbracoContext.RoutesCache.GetRoute(nodeId)
: null;
if (route != null)
@@ -94,7 +92,7 @@ namespace Umbraco.Web
if (!_umbracoContext.InPreviewMode)
{
_routesCache.Store(nodeId, route); // will not write if previewing
_umbracoContext.RoutesCache.Store(nodeId, route); // will not write if previewing
}
return FormatUrl(domain, path);

View File

@@ -13,7 +13,7 @@ namespace Umbraco.Web
public static class PluginResolverExtensions
{
private static volatile IEnumerable<ILookup> _lookups;
private static volatile IEnumerable<Type> _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<ILookup> ResolveLookups(this PluginResolver plugins)
internal static IEnumerable<Type> ResolveLookups(this PluginResolver plugins)
{
if (_lookups == null)
{
@@ -29,22 +29,7 @@ namespace Umbraco.Web
{
if (_lookups == null)
{
var lookupTypes = TypeFinder.FindClassesOfType<ILookup>();
var lookups = new List<ILookup>();
foreach (var l in lookupTypes)
{
try
{
var typeInstance = Activator.CreateInstance(l) as ILookup;
lookups.Add(typeInstance);
}
catch (Exception ex)
{
Log.Add(LogTypes.Error, -1, "Error loading ILookup: " + ex.ToString());
}
}
//set the global
_lookups = lookups;
_lookups = TypeFinder.FindClassesOfType<ILookup>();
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Globalization;
using System.Diagnostics;
// legacy
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.template;
using umbraco.cms.businesslogic.member;
@@ -16,12 +17,9 @@ namespace Umbraco.Web.Routing
{
static readonly TraceSource Trace = new TraceSource("DocumentRequest");
public DocumentRequest(Uri uri, RoutingEnvironment lookups, UmbracoContext umbracoContext, NiceUrlResolver niceUrlResolver)
public DocumentRequest(Uri uri, RoutingContext routingContext)
{
// register lookups
_environment = lookups;
UmbracoContext = umbracoContext;
_niceUrlResolver = niceUrlResolver;
RoutingContext = routingContext;
// prepare the host
var host = uri.Host;
@@ -55,9 +53,6 @@ namespace Umbraco.Web.Routing
this.QueryString = uri.Query.TrimStart('?');
}
readonly RoutingEnvironment _environment;
private readonly NiceUrlResolver _niceUrlResolver;
/// <summary>
/// the id of the requested node, if any, else zero.
/// </summary>
@@ -71,9 +66,9 @@ namespace Umbraco.Web.Routing
#region Properties
/// <summary>
/// Returns the current UmbracoContext
/// Returns the current RoutingContext
/// </summary>
public UmbracoContext UmbracoContext { get; private set; }
public RoutingContext RoutingContext { get; private set; }
/// <summary>
/// Gets the request host name.
@@ -128,7 +123,7 @@ namespace Umbraco.Web.Routing
_node = value;
this.Template = null;
if (_node != null)
_nodeId = int.Parse(_environment.ContentStore.GetNodeProperty(_node, "@id"));
_nodeId = int.Parse(RoutingContext.ContentStore.GetNodeProperty(_node, "@id"));
else
_nodeId = 0;
}
@@ -251,8 +246,22 @@ namespace Umbraco.Web.Routing
// the first successful lookup, if any, will set this.Node, and may also set this.Template
// some lookups may implement caching
Trace.TraceInformation("{0}Begin lookup", tracePrefix);
var lookups = _environment.RouteLookups.GetLookups();
lookups.Any(lookup => lookup.LookupDocument(this));
var lookups = RoutingContext.RouteLookups.GetLookups();
lookups.Any(lookup =>
{
//create the instance
try
{
var instance = (ILookup)Activator.CreateInstance(lookup);
return instance.LookupDocument(this);
}
catch (Exception ex)
{
Log.Add(LogTypes.Error, -1, "Error loading ILookup: " + ex.ToString());
return false;
}
});
Trace.TraceInformation("{0}End lookup, {1}", tracePrefix, (this.HasNode ? "a document was found" : "no document was found"));
// fixme - not handling umbracoRedirect
@@ -292,7 +301,7 @@ namespace Umbraco.Web.Routing
Trace.TraceInformation("{0}No document, try notFound lookup", tracePrefix);
// if it fails then give up, there isn't much more that we can do
if (_environment.LookupNotFound == null || !_environment.LookupNotFound.LookupDocument(this))
if (RoutingContext.LookupNotFound == null || !RoutingContext.LookupNotFound.LookupDocument(this))
{
Trace.TraceInformation("{0}Failed to find a document, give up", tracePrefix);
break;
@@ -344,7 +353,7 @@ namespace Umbraco.Web.Routing
throw new InvalidOperationException("There is no node.");
bool redirect = false;
string internalRedirect = _environment.ContentStore.GetNodeProperty(this.Node, "umbracoInternalRedirectId");
string internalRedirect = RoutingContext.ContentStore.GetNodeProperty(this.Node, "umbracoInternalRedirectId");
if (!string.IsNullOrWhiteSpace(internalRedirect))
{
@@ -368,7 +377,7 @@ namespace Umbraco.Web.Routing
else
{
// redirect to another page
var node = _environment.ContentStore.GetNodeById(internalRedirectId);
var node = RoutingContext.ContentStore.GetNodeById(internalRedirectId);
this.Node = node;
if (node != null)
{
@@ -396,7 +405,7 @@ namespace Umbraco.Web.Routing
if (this.Node == null)
throw new InvalidOperationException("There is no node.");
var path = _environment.ContentStore.GetNodeProperty(this.Node, "@path");
var path = RoutingContext.ContentStore.GetNodeProperty(this.Node, "@path");
if (Access.IsProtected(this.NodeId, path))
{
@@ -409,14 +418,14 @@ namespace Umbraco.Web.Routing
Trace.TraceInformation("{0}Not logged in, redirect to login page", tracePrefix);
var loginPageId = Access.GetLoginPage(path);
if (loginPageId != this.NodeId)
this.Node = _environment.ContentStore.GetNodeById(loginPageId);
this.Node = RoutingContext.ContentStore.GetNodeById(loginPageId);
}
else if (!Access.HasAccces(this.NodeId, user.ProviderUserKey))
{
Trace.TraceInformation("{0}Current member has not access, redirect to error page", tracePrefix);
var errorPageId = Access.GetErrorPage(path);
if (errorPageId != this.NodeId)
this.Node = _environment.ContentStore.GetNodeById(errorPageId);
this.Node = RoutingContext.ContentStore.GetNodeById(errorPageId);
}
else
{
@@ -439,9 +448,9 @@ namespace Umbraco.Web.Routing
if (this.Node == null)
throw new InvalidOperationException("There is no node.");
var templateAlias = UmbracoContext.HttpContext.Request.QueryString["altTemplate"];
var templateAlias = RoutingContext.UmbracoContext.HttpContext.Request.QueryString["altTemplate"];
if (string.IsNullOrWhiteSpace(templateAlias))
templateAlias = UmbracoContext.HttpContext.Request.Form["altTemplate"];
templateAlias = RoutingContext.UmbracoContext.HttpContext.Request.Form["altTemplate"];
// fixme - we might want to support cookies?!? NO but provide a hook to change the template
@@ -449,7 +458,7 @@ namespace Umbraco.Web.Routing
{
if (string.IsNullOrWhiteSpace(templateAlias))
{
templateAlias = _environment.ContentStore.GetNodeProperty(this.Node, "@template");
templateAlias = RoutingContext.ContentStore.GetNodeProperty(this.Node, "@template");
Trace.TraceInformation("{0}Look for template id={1}", tracePrefix, templateAlias);
int templateId;
if (!int.TryParse(templateAlias, out templateId))
@@ -491,11 +500,11 @@ namespace Umbraco.Web.Routing
if (this.HasNode)
{
int redirectId;
if (!int.TryParse(_environment.ContentStore.GetNodeProperty(this.Node, "umbracoRedirect"), out redirectId))
if (!int.TryParse(RoutingContext.ContentStore.GetNodeProperty(this.Node, "umbracoRedirect"), out redirectId))
redirectId = -1;
string redirectUrl = "#";
if (redirectId > 0)
redirectUrl = _niceUrlResolver.GetNiceUrl(redirectId);
redirectUrl = RoutingContext.NiceUrlResolver.GetNiceUrl(redirectId);
if (redirectUrl != "#")
this.RedirectUrl = redirectUrl;
}

View File

@@ -13,14 +13,9 @@ namespace Umbraco.Web.Routing
[LookupWeight(50)]
internal class LookupByAlias : ILookup
{
public LookupByAlias(ContentStore contentStore)
{
_contentStore = contentStore;
}
static readonly TraceSource Trace = new TraceSource("LookupByAlias");
readonly ContentStore _contentStore;
public bool LookupDocument(DocumentRequest docreq)
{
@@ -28,7 +23,7 @@ namespace Umbraco.Web.Routing
if (docreq.Path != "/") // no alias if "/"
{
node = _contentStore.GetNodeByUrlAlias(docreq.HasDomain ? docreq.Domain.RootNodeId : 0, docreq.Path);
node = docreq.RoutingContext.ContentStore.GetNodeByUrlAlias(docreq.HasDomain ? docreq.Domain.RootNodeId : 0, docreq.Path);
if (node != null)
{
Trace.TraceInformation("Path \"{0}\" is an alias for id={1}", docreq.Path, docreq.NodeId);

View File

@@ -10,24 +10,9 @@ namespace Umbraco.Web.Routing
[LookupWeight(20)]
internal class LookupById : ILookup
{
public LookupById(ContentStore contentStore)
{
_contentStore = contentStore;
}
static readonly TraceSource Trace = new TraceSource("LookupById");
readonly ContentStore _contentStore;
////[Import]
//IContentStore ContentStoreImport
//{
// set { _contentStore = value; }
//}
//public LookupById()
//{ }
public bool LookupDocument(DocumentRequest docreq)
{
XmlNode node = null;
@@ -43,7 +28,7 @@ namespace Umbraco.Web.Routing
if (nodeId > 0)
{
Trace.TraceInformation("Id={0}", nodeId);
node = _contentStore.GetNodeById(nodeId);
node = docreq.RoutingContext.ContentStore.GetNodeById(nodeId);
if (node != null)
{
docreq.Node = node;

View File

@@ -9,17 +9,9 @@ namespace Umbraco.Web.Routing
[LookupWeight(10)]
internal class LookupByPath : ILookup
{
public LookupByPath(ContentStore contentStore, IRoutesCache routesCache)
{
ContentStore = contentStore;
RoutesCache = routesCache;
}
static readonly TraceSource Trace = new TraceSource("LookupByPath");
protected ContentStore ContentStore;
protected IRoutesCache RoutesCache;
public virtual bool LookupDocument(DocumentRequest docreq)
{
var route = docreq.HasDomain ? (docreq.Domain.RootNodeId.ToString() + docreq.Path) : docreq.Path;
@@ -32,15 +24,15 @@ namespace Umbraco.Web.Routing
Trace.TraceInformation("Test route \"{0}\"", route);
//return '0' if in preview mode!
var nodeId = !docreq.UmbracoContext.InPreviewMode
? RoutesCache.GetNodeId(route)
var nodeId = !docreq.RoutingContext.UmbracoContext.InPreviewMode
? docreq.RoutingContext.UmbracoContext.RoutesCache.GetNodeId(route)
: 0;
XmlNode node = null;
if (nodeId > 0)
{
node = ContentStore.GetNodeById(nodeId);
node = docreq.RoutingContext.ContentStore.GetNodeById(nodeId);
if (node != null)
{
docreq.Node = node;
@@ -48,22 +40,22 @@ namespace Umbraco.Web.Routing
}
else
{
RoutesCache.ClearNode(nodeId);
docreq.RoutingContext.UmbracoContext.RoutesCache.ClearNode(nodeId);
}
}
if (node == null)
{
Trace.TraceInformation("Cache miss, query");
node = ContentStore.GetNodeByRoute(route);
node = docreq.RoutingContext.ContentStore.GetNodeByRoute(route);
if (node != null)
{
docreq.Node = node;
Trace.TraceInformation("Query matches, id={0}", docreq.NodeId);
if (!docreq.UmbracoContext.InPreviewMode)
if (!docreq.RoutingContext.UmbracoContext.InPreviewMode)
{
RoutesCache.Store(docreq.NodeId, route); // will not write if previewing
docreq.RoutingContext.UmbracoContext.RoutesCache.Store(docreq.NodeId, route); // will not write if previewing
}
}

View File

@@ -11,12 +11,7 @@ namespace Umbraco.Web.Routing
[LookupWeight(30)]
internal class LookupByPathWithTemplate : LookupByPath, ILookup
{
static readonly TraceSource Trace = new TraceSource("LookupByPathWithTemplate");
public LookupByPathWithTemplate(ContentStore contentStore, IRoutesCache routesCache)
: base(contentStore, routesCache)
{
}
static readonly TraceSource Trace = new TraceSource("LookupByPathWithTemplate");
public override bool LookupDocument(DocumentRequest docreq)
{

View File

@@ -14,15 +14,7 @@ namespace Umbraco.Web.Routing
[LookupWeight(40)]
internal class LookupByProfile : LookupByPath, ILookup
{
private readonly UmbracoContext _umbracoContext;
static readonly TraceSource Trace = new TraceSource("LookupByProfile");
public LookupByProfile(ContentStore contentStore, IRoutesCache routesCache, UmbracoContext umbracoContext)
: base(contentStore, routesCache)
{
_umbracoContext = umbracoContext;
}
static readonly TraceSource Trace = new TraceSource("LookupByProfile");
public override bool LookupDocument(DocumentRequest docreq)
{
@@ -44,7 +36,10 @@ namespace Umbraco.Web.Routing
node = LookupDocumentNode(docreq, route);
if (node != null)
_umbracoContext.HttpContext.Items["umbMemberLogin"] = memberLogin;
{
//TODO: Should be handled by Context Items class manager (http://issues.umbraco.org/issue/U4-61)
docreq.RoutingContext.UmbracoContext.HttpContext.Items["umbMemberLogin"] = memberLogin;
}
else
Trace.TraceInformation("No document matching profile path?");
}

View File

@@ -11,18 +11,12 @@ namespace Umbraco.Web.Routing
{
internal class LookupFor404 : ILookupNotFound
{
public LookupFor404(ContentStore contentStore)
{
_contentStore = contentStore;
}
static TraceSource _trace = new TraceSource("LookupByAlias");
private readonly ContentStore _contentStore;
public bool LookupDocument(DocumentRequest docRequest)
{
docRequest.Node = HandlePageNotFound(docRequest.Path);
docRequest.Node = HandlePageNotFound(docRequest);
return docRequest.HasNode;
}
@@ -30,17 +24,17 @@ namespace Umbraco.Web.Routing
// copied from presentation/requestHandler
// temporary!!
XmlNode HandlePageNotFound(string url)
XmlNode HandlePageNotFound(DocumentRequest docRequest)
{
HttpContext.Current.Trace.Write("NotFoundHandler", string.Format("Running for url='{0}'.", url));
HttpContext.Current.Trace.Write("NotFoundHandler", string.Format("Running for url='{0}'.", docRequest.Path));
XmlNode currentPage = null;
foreach (var handler in GetNotFoundHandlers())
{
if (handler.Execute(url) && handler.redirectID > 0)
if (handler.Execute(docRequest.Path) && handler.redirectID > 0)
{
//currentPage = umbracoContent.GetElementById(handler.redirectID.ToString());
currentPage = _contentStore.GetNodeById(handler.redirectID);
currentPage = docRequest.RoutingContext.ContentStore.GetNodeById(handler.redirectID);
// FIXME - could it be null?

View File

@@ -7,11 +7,11 @@ using Umbraco.Core;
namespace Umbraco.Web.Routing
{
/// <summary>
/// Represents a collection of ILookups used for routing that are registered in the application
/// Represents a collection of ILookup types used for routing that are registered in the application
/// </summary>
internal class RouteLookups
{
private static readonly List<ILookup> Lookups = new List<ILookup>();
private static readonly List<Type> Lookups = new List<Type>();
private static readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim();
/// <summary>
@@ -19,7 +19,7 @@ namespace Umbraco.Web.Routing
/// </summary>
public static RouteLookups Current { get; internal set; }
internal RouteLookups(IEnumerable<ILookup> lookups)
internal RouteLookups(IEnumerable<Type> lookups)
{
Lookups.AddRange(SortByWeight(lookups));
}
@@ -28,7 +28,7 @@ namespace Umbraco.Web.Routing
/// Returns all of the lookups
/// </summary>
/// <returns></returns>
public IEnumerable<ILookup> GetLookups()
public IEnumerable<Type> GetLookups()
{
return Lookups;
}
@@ -46,14 +46,27 @@ namespace Umbraco.Web.Routing
}
}
/// <summary>
/// Adds a new lookup to the end of the list
/// </summary>
/// <typeparam name="T"></typeparam>
public void AddLookup<T>()
where T : ILookup
{
AddLookup(typeof (T));
}
/// <summary>
/// Adds a new lookup to the end of the list
/// </summary>
/// <param name="lookup"></param>
public void AddLookup(ILookup lookup)
{
public void AddLookup(Type lookup)
{
if (!typeof(ILookup).IsAssignableFrom(lookup))
throw new InvalidOperationException("The type specified is not of type " + typeof (ILookup));
if (CheckExists(lookup))
throw new InvalidOperationException("The lookup type " + lookup.GetType() + " already exists in the lookup collection");
throw new InvalidOperationException("The lookup type " + lookup + " already exists in the lookup collection");
using (new WriteLock(Lock))
{
@@ -66,10 +79,10 @@ namespace Umbraco.Web.Routing
/// </summary>
/// <param name="index"></param>
/// <param name="lookup"></param>
public void InsertLookup(int index, ILookup lookup)
public void InsertLookup(int index, Type lookup)
{
if (CheckExists(lookup))
throw new InvalidOperationException("The lookup type " + lookup.GetType() + " already exists in the lookup collection");
throw new InvalidOperationException("The lookup type " + lookup + " already exists in the lookup collection");
using (new WriteLock(Lock))
{
@@ -82,9 +95,9 @@ namespace Umbraco.Web.Routing
/// </summary>
/// <param name="lookup"></param>
/// <returns></returns>
private static bool CheckExists(ILookup lookup)
private static bool CheckExists(Type lookup)
{
return Lookups.Any(x => x.GetType() == lookup.GetType());
return Lookups.Any(x => x == lookup);
}
/// <summary>
@@ -92,11 +105,11 @@ namespace Umbraco.Web.Routing
/// </summary>
/// <param name="lookups"></param>
/// <returns></returns>
private static IEnumerable<ILookup> SortByWeight(IEnumerable<ILookup> lookups)
private static IEnumerable<Type> SortByWeight(IEnumerable<Type> lookups)
{
return lookups.OrderBy(x =>
{
var attribute = x.GetType().GetCustomAttributes(true).OfType<LookupWeightAttribute>().SingleOrDefault();
var attribute = x.GetCustomAttributes(true).OfType<LookupWeightAttribute>().SingleOrDefault();
return attribute == null ? LookupWeightAttribute.DefaultWeight : attribute.Weight;
}).ToList();
}

View File

@@ -8,23 +8,26 @@ namespace Umbraco.Web.Routing
/// represents a request for one specified Umbraco document to be rendered by one specified template,
/// using one particular culture.
/// </summary>
internal class RoutingEnvironment
internal class RoutingContext
{
public RoutingEnvironment(
public RoutingContext(
UmbracoContext umbracoContext,
RouteLookups lookups,
ILookupNotFound lookupNotFound,
ContentStore contentStore)
ContentStore contentStore,
NiceUrlResolver niceUrlResolver)
{
RouteLookups = lookups;
UmbracoContext = umbracoContext;
RouteLookups = lookups;
LookupNotFound = lookupNotFound;
ContentStore = contentStore;
NiceUrlResolver = niceUrlResolver;
}
public UmbracoContext UmbracoContext { get; private set; }
public RouteLookups RouteLookups { get; private set; }
public ILookupNotFound LookupNotFound { get; private set; }
public ContentStore ContentStore { get; private set; }
public NiceUrlResolver NiceUrlResolver { get; private set; }
}
}

View File

@@ -256,7 +256,7 @@
<Compile Include="Routing\LookupWeightAttribute.cs" />
<Compile Include="Routing\DefaultRoutesCache.cs" />
<Compile Include="Routing\RoutesCache.cs" />
<Compile Include="Routing\RoutingEnvironment.cs" />
<Compile Include="Routing\RoutingContext.cs" />
<Compile Include="umbraco.presentation\EnsureSystemPathsApplicationStartupHandler.cs" />
<Compile Include="umbraco.presentation\install\steps\database.ascx.cs">
<DependentUpon>database.ascx</DependentUpon>

View File

@@ -32,18 +32,23 @@ namespace Umbraco.Web
/// </summary>
private static UmbracoContext _umbracoContext;
/// <summary>
/// Creates a new Umbraco context.
/// </summary>
/// <param name="httpContext"></param>
/// <param name="applicationContext"> </param>
internal UmbracoContext(HttpContextBase httpContext, ApplicationContext applicationContext)
/// <summary>
/// Creates a new Umbraco context.
/// </summary>
/// <param name="httpContext"></param>
/// <param name="applicationContext"> </param>
/// <param name="routesCache"> </param>
internal UmbracoContext(
HttpContextBase httpContext,
ApplicationContext applicationContext,
IRoutesCache routesCache)
{
if (httpContext == null) throw new ArgumentNullException("httpContext");
if (applicationContext == null) throw new ArgumentNullException("applicationContext");
HttpContext = httpContext;
Application = applicationContext;
RoutesCache = routesCache;
}
/// <summary>
@@ -91,7 +96,9 @@ namespace Umbraco.Web
/// </summary>
public ApplicationContext Application { get; private set; }
/// <summary>
internal IRoutesCache RoutesCache { get; private set; }
/// <summary>
/// Gets/sets the original URL of the request
/// </summary>
internal Uri OriginalUrl { get; set; }
@@ -124,17 +131,7 @@ namespace Umbraco.Web
/// <summary>
/// Gets/sets the DocumentRequest object
/// </summary>
internal DocumentRequest DocumentRequest { get; set; }
/// <summary>
/// Gets/sets the NiceUrlResolver object
/// </summary>
internal NiceUrlResolver NiceUrlResolver { get; set; }
/// <summary>
/// Gets/sets the RoutingEnvironment object
/// </summary>
internal RoutingEnvironment RoutingEnvironment { get; set; }
internal DocumentRequest DocumentRequest { get; set; }
/// <summary>
/// Exposes the HttpContext for the current request

View File

@@ -33,29 +33,28 @@ namespace Umbraco.Web
httpContext.Response.AddHeader("X-Umbraco-Version", string.Format("{0}.{1}", GlobalSettings.VersionMajor, GlobalSettings.VersionMinor));
//create the UmbracoContext singleton, one per request!!
var umbracoContext = new UmbracoContext(new HttpContextWrapper(httpContext), ApplicationContext.Current);
var umbracoContext = new UmbracoContext(
new HttpContextWrapper(httpContext),
ApplicationContext.Current,
RoutesCache.Current.GetProvider());
UmbracoContext.Current = umbracoContext;
//create a content store
var contentStore = new ContentStore(umbracoContext);
//create the nice urls
var niceUrls = new NiceUrlResolver(contentStore, umbracoContext, RoutesCache.Current.GetProvider());
//create the RoutingEnvironment (one per http request as it relies on the umbraco context!)
var routingEnvironment = new RoutingEnvironment(
RouteLookups.Current,
new LookupFor404(contentStore),
contentStore);
var niceUrls = new NiceUrlResolver(contentStore, umbracoContext);
//create the RoutingContext (one per http request)
var routingContext = new RoutingContext(
umbracoContext,
RouteLookups.Current,
new LookupFor404(),
contentStore,
niceUrls);
// create the new document request which will cleanup the uri once and for all
var docreq = new DocumentRequest(uri, routingEnvironment, umbracoContext, niceUrls);
var docreq = new DocumentRequest(uri, routingContext);
//NOTE: we are putting these objects on the UmbracoContext because these might be handy for developers in the future to
// access if we make them public.
// initialize the DocumentRequest on the UmbracoContext (this is circular dependency!!!)
// initialize the DocumentRequest on the UmbracoContext (this is circular dependency but i think in this case is ok)
umbracoContext.DocumentRequest = docreq;
// initialize the RoutingEnvironment on the UmbracoContext (this is circular dependency!!!)
umbracoContext.RoutingEnvironment = routingEnvironment;
// initialize the RoutingEnvironment on the UmbracoContext (this is circular dependency!!!)
umbracoContext.NiceUrlResolver = niceUrls;
//create the LegacyRequestInitializer (one per http request as it relies on the umbraco context!)
var legacyRequestInitializer = new LegacyRequestInitializer(umbracoContext);