mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Fix dynamic compilation issue in command line host
--HG-- branch : dev
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Orchard.Commands {
|
|||||||
|
|
||||||
public int StartHost(TextReader input, TextWriter output) {
|
public int StartHost(TextReader input, TextWriter output) {
|
||||||
try {
|
try {
|
||||||
_hostContainer = OrchardStarter.CreateHostContainer(MvcSingletons);
|
_hostContainer = OrchardStarter.CreateHostContainer(ContainerRegistrations);
|
||||||
_tenants = new Dictionary<string, IStandaloneEnvironment>();
|
_tenants = new Dictionary<string, IStandaloneEnvironment>();
|
||||||
|
|
||||||
var host = _hostContainer.Resolve<IOrchardHost>();
|
var host = _hostContainer.Resolve<IOrchardHost>();
|
||||||
@@ -138,6 +138,11 @@ namespace Orchard.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void ContainerRegistrations(ContainerBuilder builder) {
|
||||||
|
MvcSingletons(builder);
|
||||||
|
builder.RegisterType<CommandHostEnvironment>().As<IHostEnvironment>();
|
||||||
|
}
|
||||||
|
|
||||||
protected void MvcSingletons(ContainerBuilder builder) {
|
protected void MvcSingletons(ContainerBuilder builder) {
|
||||||
builder.RegisterInstance(ControllerBuilder.Current);
|
builder.RegisterInstance(ControllerBuilder.Current);
|
||||||
builder.RegisterInstance(RouteTable.Routes);
|
builder.RegisterInstance(RouteTable.Routes);
|
||||||
|
23
src/Orchard/Commands/CommandHostEnvironment.cs
Normal file
23
src/Orchard/Commands/CommandHostEnvironment.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Web.Hosting;
|
||||||
|
using Orchard.Environment;
|
||||||
|
|
||||||
|
namespace Orchard.Commands {
|
||||||
|
public class CommandHostEnvironment : IHostEnvironment {
|
||||||
|
public bool IsFullTrust {
|
||||||
|
get { return AppDomain.CurrentDomain.IsFullyTrusted; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MapPath(string virtualPath) {
|
||||||
|
return HostingEnvironment.MapPath(virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RestartAppDomain() {
|
||||||
|
//Don't restart AppDomain in command line environment
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetSiteCompilation() {
|
||||||
|
//Don't restart AppDomain in command line environment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -115,18 +115,7 @@ namespace Orchard.Environment {
|
|||||||
.As<IContainer>()
|
.As<IContainer>()
|
||||||
.InstancePerMatchingLifetimeScope("shell");
|
.InstancePerMatchingLifetimeScope("shell");
|
||||||
|
|
||||||
return builder.Build();
|
var container = builder.Build();
|
||||||
}
|
|
||||||
|
|
||||||
private static void RegisterVolatileProvider<TRegister, TService>(ContainerBuilder builder) where TService : IVolatileProvider {
|
|
||||||
builder.RegisterType<TRegister>()
|
|
||||||
.As<TService>()
|
|
||||||
.As<IVolatileProvider>()
|
|
||||||
.SingleInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IOrchardHost CreateHost(Action<ContainerBuilder> registrations) {
|
|
||||||
var container = CreateHostContainer(registrations);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Virtual Path Providers
|
// Register Virtual Path Providers
|
||||||
@@ -138,6 +127,19 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrchardHostContainerRegistry.RegisterHostContainer(new DefaultOrchardHostContainer(container));
|
OrchardHostContainerRegistry.RegisterHostContainer(new DefaultOrchardHostContainer(container));
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RegisterVolatileProvider<TRegister, TService>(ContainerBuilder builder) where TService : IVolatileProvider {
|
||||||
|
builder.RegisterType<TRegister>()
|
||||||
|
.As<TService>()
|
||||||
|
.As<IVolatileProvider>()
|
||||||
|
.SingleInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IOrchardHost CreateHost(Action<ContainerBuilder> registrations) {
|
||||||
|
var container = CreateHostContainer(registrations);
|
||||||
return container.Resolve<IOrchardHost>();
|
return container.Resolve<IOrchardHost>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -133,6 +133,7 @@
|
|||||||
<Compile Include="Caching\Signals.cs" />
|
<Compile Include="Caching\Signals.cs" />
|
||||||
<Compile Include="Collections\IPageOfItems.cs" />
|
<Compile Include="Collections\IPageOfItems.cs" />
|
||||||
<Compile Include="Collections\PageOfItems.cs" />
|
<Compile Include="Collections\PageOfItems.cs" />
|
||||||
|
<Compile Include="Commands\CommandHostEnvironment.cs" />
|
||||||
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
|
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
Reference in New Issue
Block a user