TEMP
This commit is contained in:
@@ -4,10 +4,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using LightInject;
|
||||
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -23,36 +20,76 @@ using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
|
||||
|
||||
// fixme
|
||||
// need an UmbracoInjectedModules that is declared in web.config
|
||||
// need a web.config configuration section w/ modules = umbraco.webServer/modules
|
||||
// so it's all explicit
|
||||
|
||||
[assembly: PreApplicationStartMethod(typeof(Umbraco.Web.ContainerUmbracoModule), "Start")]
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
{
|
||||
// fixme
|
||||
// name that one UmbracoModule, and the nested one UmbracoRequestModule - deals with front-end requests
|
||||
public class UmbracoModules : IHttpModule
|
||||
{
|
||||
private readonly List<IHttpModule> _modules = new List<IHttpModule>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
// fixme - need to get moduleTypes from some sort of Umbraco configuration
|
||||
|
||||
foreach (var moduleType in moduleTypes)
|
||||
{
|
||||
var module = (IHttpModule) Current.Container.GetInstance(moduleType);
|
||||
_modules.Add(module);
|
||||
module.Init(context);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var module in _modules)
|
||||
module.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerUmbracoModule : IHttpModule
|
||||
{
|
||||
private UmbracoModule umbracoModule;
|
||||
private static readonly Type[] ModuleTypes =
|
||||
{
|
||||
typeof(UmbracoModule)
|
||||
};
|
||||
|
||||
private readonly List<IHttpModule> _modules = new List<IHttpModule>();
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
DynamicModuleUtility.RegisterModule(typeof(ContainerUmbracoModule));
|
||||
{
|
||||
// registers the ContainerUmbracoModule (without having to have it in web.config)
|
||||
// fixme - in which order? is it going to be first or last?
|
||||
// fixme - do we need to remove the original UmbracoModule from web.config then?
|
||||
HttpApplication.RegisterModule(typeof(ContainerUmbracoModule));
|
||||
}
|
||||
|
||||
public ContainerUmbracoModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
// Should be extended with lazy list of modules from registry
|
||||
// Example here: https://haacked.com/archive/2011/06/03/dependency-injection-with-asp-net-httpmodules.aspx/
|
||||
// see: https://haacked.com/archive/2011/06/03/dependency-injection-with-asp-net-httpmodules.aspx/
|
||||
|
||||
umbracoModule = Current.Container.GetInstance<UmbracoModule>();
|
||||
umbracoModule.Init(context);
|
||||
foreach (var moduleType in ModuleTypes)
|
||||
{
|
||||
var module = (IHttpModule) Current.Container.GetInstance(moduleType);
|
||||
_modules.Add(module);
|
||||
module.Init(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
umbracoModule.Dispose();
|
||||
foreach (var module in _modules)
|
||||
module.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,32 +102,30 @@ namespace Umbraco.Web
|
||||
public class UmbracoModule : IHttpModule
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
// modules are *not* instanciated by the container so we have to
|
||||
// get our dependencies injected manually, through properties, in
|
||||
// Init(). works for dependencies that are singletons.
|
||||
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; set; }
|
||||
|
||||
public IGlobalSettings GlobalSettings { get; set; }
|
||||
|
||||
public IUmbracoContextAccessor UmbracoContextAccessor { get; set; }
|
||||
|
||||
public IPublishedSnapshotService PublishedSnapshotService { get; set; }
|
||||
|
||||
public IUserService UserService { get; set; }
|
||||
|
||||
public UrlProviderCollection UrlProviders { get; set; }
|
||||
// fixme these dont need to be publish and properties anymore?!
|
||||
|
||||
public IRuntimeState Runtime { get; set; }
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public IGlobalSettings GlobalSettings { get; }
|
||||
|
||||
internal PublishedRouter PublishedRouter { get; set; }
|
||||
public IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
||||
|
||||
internal IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
public IPublishedSnapshotService PublishedSnapshotService { get; }
|
||||
|
||||
public IUserService UserService { get; }
|
||||
|
||||
internal IVariationContextAccessor VariationContextAccessor { get; set; }
|
||||
public UrlProviderCollection UrlProviders { get; }
|
||||
|
||||
public IRuntimeState Runtime { get; }
|
||||
|
||||
public ILogger Logger { get; }
|
||||
|
||||
internal PublishedRouter PublishedRouter { get; }
|
||||
|
||||
internal IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
internal IVariationContextAccessor VariationContextAccessor { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -105,8 +140,7 @@ namespace Umbraco.Web
|
||||
ILogger logger,
|
||||
PublishedRouter publishedRouter,
|
||||
IUmbracoDatabaseFactory databaseFactory,
|
||||
IVariationContextAccessor variationContextAccessor
|
||||
)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_combinedRouteCollection = new Lazy<RouteCollection>(CreateRouteCollection);
|
||||
|
||||
@@ -558,7 +592,7 @@ namespace Umbraco.Web
|
||||
/// <param name="app"></param>
|
||||
public void Init(HttpApplication app)
|
||||
{
|
||||
if (Core.Composing.Current.RuntimeState.Level == RuntimeLevel.BootFailed)
|
||||
if (Core.Composing.Current.RuntimeState.Level == RuntimeLevel.BootFailed) // fixme inject the runtimeState!
|
||||
{
|
||||
// there's nothing we can do really
|
||||
app.BeginRequest += (sender, args) =>
|
||||
@@ -589,6 +623,7 @@ namespace Umbraco.Web
|
||||
return;
|
||||
}
|
||||
|
||||
// fixme
|
||||
// modules **are** instanciated by the container so we **don't** have to
|
||||
// get our dependencies injected manually, through properties.
|
||||
//Core.Composing.Current.Container.InjectProperties(this);
|
||||
|
||||
Reference in New Issue
Block a user