mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
- More work related to moving Orchard to Autofac 2.1.
Need to rework the host/shell container spin-off for multitenancy. Need to rework interception. dev branch is now broken until the end of this sprint, enjoy the default branch. --HG-- branch : dev
This commit is contained in:
@@ -5,15 +5,19 @@ using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Integration.Web;
|
||||
using Autofac.Integration.Web.Mvc;
|
||||
using Orchard.Environment;
|
||||
|
||||
namespace Orchard.Web {
|
||||
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
|
||||
// visit http://go.microsoft.com/?LinkId=9394801
|
||||
|
||||
public class MvcApplication : HttpApplication {
|
||||
public class MvcApplication : HttpApplication, IContainerProviderAccessor {
|
||||
private static IOrchardHost _host;
|
||||
private static IContainerProvider _containerProvider;
|
||||
|
||||
public static void RegisterRoutes(RouteCollection routes) {
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
@@ -26,6 +30,12 @@ namespace Orchard.Web {
|
||||
new Version("2.0.50217.0")/*MVC2 RTM file version #*/,
|
||||
new Version("2.0.50129.0")/*MVC2 RC2 file version #*/,
|
||||
new Version("2.0.41211.0")/*MVC2 RC file version #*/);
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterControllers(Assembly.GetExecutingAssembly());
|
||||
_containerProvider = new ContainerProvider(builder.Build());
|
||||
ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(ContainerProvider));
|
||||
|
||||
RegisterRoutes(RouteTable.Routes);
|
||||
|
||||
_host = OrchardStarter.CreateHost(MvcSingletons);
|
||||
@@ -91,11 +101,21 @@ namespace Orchard.Web {
|
||||
|
||||
|
||||
protected void MvcSingletons(ContainerBuilder builder) {
|
||||
builder.Register(ControllerBuilder.Current);
|
||||
builder.Register(RouteTable.Routes);
|
||||
builder.Register(ModelBinders.Binders);
|
||||
builder.Register(ModelMetadataProviders.Current);
|
||||
builder.Register(ViewEngines.Engines);
|
||||
builder.RegisterInstance(ControllerBuilder.Current);
|
||||
builder.RegisterInstance(RouteTable.Routes);
|
||||
builder.RegisterInstance(ModelBinders.Binders);
|
||||
builder.RegisterInstance(ModelMetadataProviders.Current);
|
||||
builder.RegisterInstance(ViewEngines.Engines);
|
||||
}
|
||||
|
||||
#region Implementation of IContainerProviderAccessor
|
||||
|
||||
public IContainerProvider ContainerProvider {
|
||||
get {
|
||||
return _containerProvider;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,18 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Web, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Web.Mvc, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate.ByteCode.Castle, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
|
||||
|
@@ -144,6 +144,7 @@
|
||||
</httpHandlers>
|
||||
|
||||
<httpModules>
|
||||
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web"/>
|
||||
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</httpModules>
|
||||
@@ -177,6 +178,7 @@
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
|
||||
<modules runAllManagedModulesForAllRequests="true">
|
||||
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web"/>
|
||||
<remove name="ScriptModule" />
|
||||
<remove name="UrlRoutingModule" />
|
||||
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
|
Reference in New Issue
Block a user