From 25b06a88ab89a55c4f81b24a6819414779edd415 Mon Sep 17 00:00:00 2001 From: "shannon@ShandemVaio" Date: Fri, 20 Jul 2012 01:04:35 +0600 Subject: [PATCH] Began integration of Stephen's new routing logic. The sln compiles and things have been refactored from the initial concept. The module is not active as it currently will not work because of contructor dependencies and classes marked as internal, will liase with Stephen regarding this. --- src/Umbraco.Core/ApplicationContext.cs | 94 ++++ src/Umbraco.Core/PluginResolver.cs | 23 + src/Umbraco.Core/Properties/AssemblyInfo.cs | 2 + src/Umbraco.Core/Umbraco.Core.csproj | 9 + src/Umbraco.Core/UriExtensions.cs | 22 + src/Umbraco.Web/ContentStore.cs | 148 ++++++ src/Umbraco.Web/LegacyRequestInitializer.cs | 31 ++ src/Umbraco.Web/Mvc/ControllerExtensions.cs | 28 + src/Umbraco.Web/NiceUrls.cs | 151 ++++++ src/Umbraco.Web/PluginResolverExtensions.cs | 55 ++ src/Umbraco.Web/Routing/DocumentRequest.cs | 499 ++++++++++++++++++ src/Umbraco.Web/Routing/ILookup.cs | 9 + src/Umbraco.Web/Routing/ILookupNotFound.cs | 7 + src/Umbraco.Web/Routing/LookupByAlias.cs | 45 ++ src/Umbraco.Web/Routing/LookupById.cs | 65 +++ src/Umbraco.Web/Routing/LookupByPath.cs | 69 +++ .../Routing/LookupByPathWithTemplate.cs | 55 ++ src/Umbraco.Web/Routing/LookupByProfile.cs | 59 +++ src/Umbraco.Web/Routing/LookupFor404.cs | 153 ++++++ .../Routing/LookupWeightAttribute.cs | 32 ++ src/Umbraco.Web/Routing/RoutesCache.cs | 81 +++ src/Umbraco.Web/Routing/RoutingEnvironment.cs | 42 ++ src/Umbraco.Web/Umbraco.Web.csproj | 24 + src/Umbraco.Web/UmbracoContext.cs | 221 ++++++++ src/Umbraco.Web/UmbracoModule.cs | 371 +++++++++++++ src/Umbraco.Web/UrlUtility.cs | 145 +++++ .../umbraco.presentation/UmbracoContext.cs | 3 +- .../umbraco.presentation/UmbracoRequest.cs | 1 + .../umbraco.presentation/UmbracoResponse.cs | 1 + .../UmbracoServerUtility.cs | 1 + 30 files changed, 2445 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Core/ApplicationContext.cs create mode 100644 src/Umbraco.Core/PluginResolver.cs create mode 100644 src/Umbraco.Core/UriExtensions.cs create mode 100644 src/Umbraco.Web/ContentStore.cs create mode 100644 src/Umbraco.Web/LegacyRequestInitializer.cs create mode 100644 src/Umbraco.Web/Mvc/ControllerExtensions.cs create mode 100644 src/Umbraco.Web/NiceUrls.cs create mode 100644 src/Umbraco.Web/PluginResolverExtensions.cs create mode 100644 src/Umbraco.Web/Routing/DocumentRequest.cs create mode 100644 src/Umbraco.Web/Routing/ILookup.cs create mode 100644 src/Umbraco.Web/Routing/ILookupNotFound.cs create mode 100644 src/Umbraco.Web/Routing/LookupByAlias.cs create mode 100644 src/Umbraco.Web/Routing/LookupById.cs create mode 100644 src/Umbraco.Web/Routing/LookupByPath.cs create mode 100644 src/Umbraco.Web/Routing/LookupByPathWithTemplate.cs create mode 100644 src/Umbraco.Web/Routing/LookupByProfile.cs create mode 100644 src/Umbraco.Web/Routing/LookupFor404.cs create mode 100644 src/Umbraco.Web/Routing/LookupWeightAttribute.cs create mode 100644 src/Umbraco.Web/Routing/RoutesCache.cs create mode 100644 src/Umbraco.Web/Routing/RoutingEnvironment.cs create mode 100644 src/Umbraco.Web/UmbracoContext.cs create mode 100644 src/Umbraco.Web/UmbracoModule.cs create mode 100644 src/Umbraco.Web/UrlUtility.cs diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs new file mode 100644 index 0000000000..4f1e449a20 --- /dev/null +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Umbraco.Core +{ + /// + /// the Umbraco Application context + /// + /// + /// one per AppDomain, represents the global Umbraco application + /// + public class ApplicationContext + { + + private static ApplicationContext _instance; + private static readonly object Locker = new object(); + + /// + /// Constructor + /// + /// + public ApplicationContext(PluginResolver pluginResolver) + { + Plugins = pluginResolver; + } + + /// + /// Singleton accessor + /// + public static ApplicationContext Current + { + get + { + return _instance; + } + set + { + lock (Locker) + { + _instance = value; + } + } + } + + // IsReady is set to true by the boot manager once it has successfully booted + // note - the original umbraco module checks on content.Instance in umbraco.dll + // now, the boot task that setup the content store ensures that it is ready + bool _isReady = false; + public bool IsReady + { + get + { + return _isReady; + } + internal set + { + AssertIsNotReady(); + _isReady = value; + } + } + + /// + /// Gets the plugin resolver for the application + /// + public PluginResolver Plugins { get; private set; } + + // notes + // GlobalSettings.ConfigurationStatus returns the value that's in the web.config, so it's the "configured version" + // GlobalSettings.CurrentVersion returns the hard-coded "current version" + // the system is configured if they match + // if they don't, install runs, updates web.config (presumably) and updates GlobalSettings.ConfiguredStatus + // + // then there is Application["umbracoNeedConfiguration"] which makes no sense... getting rid of it... + // + public bool IsConfigured + { + // fixme - let's do this for the time being + get { return umbraco.GlobalSettings.Configured; } + } + + private void AssertIsReady() + { + if (!this.IsReady) + throw new Exception("ApplicationContext is not ready yet."); + } + + private void AssertIsNotReady() + { + if (this.IsReady) + throw new Exception("ApplicationContext has already been initialized."); + } + } +} diff --git a/src/Umbraco.Core/PluginResolver.cs b/src/Umbraco.Core/PluginResolver.cs new file mode 100644 index 0000000000..1ba705345d --- /dev/null +++ b/src/Umbraco.Core/PluginResolver.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Umbraco.Core +{ + + /// + /// Used to resolve all plugin types + /// + /// + /// + /// This class should be used to resolve all plugin types, the TypeFinder should not be used directly! + /// + /// This class can expose extension methods to resolve custom plugins + /// + /// + public class PluginResolver + { + + } +} diff --git a/src/Umbraco.Core/Properties/AssemblyInfo.cs b/src/Umbraco.Core/Properties/AssemblyInfo.cs index cb87b228d3..41a997d394 100644 --- a/src/Umbraco.Core/Properties/AssemblyInfo.cs +++ b/src/Umbraco.Core/Properties/AssemblyInfo.cs @@ -18,3 +18,5 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("130a6b5c-50e7-4df3-a0dd-e9e7eb0b7c5c")] +[assembly: InternalsVisibleTo("umbraco")] + diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index b45944b80c..ca5650e3d8 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -44,14 +44,23 @@ Properties\SolutionInfo.cs + + + + + + {E469A9CE-1BEC-423F-AC44-713CD72457EA} + umbraco.businesslogic + +