Changing IOrchardRuntime to IOrchardShell

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4039304
This commit is contained in:
loudej 2009-11-10 03:46:00 +00:00
parent f0b46afc84
commit b72472c8f1
10 changed files with 63 additions and 28 deletions

View File

@ -67,10 +67,10 @@ namespace Orchard.Tests.Environment {
}
[Test]
public void DifferentRuntimeInstanceShouldBeReturnedAfterEachCreate() {
public void DifferentShellInstanceShouldBeReturnedAfterEachCreate() {
var host = _container.Resolve<IOrchardHost>();
var runtime1 = host.CreateRuntime();
var runtime2 = host.CreateRuntime();
var runtime1 = host.CreateShell();
var runtime2 = host.CreateShell();
Assert.That(runtime1, Is.Not.SameAs(runtime2));
}
}

View File

@ -10,7 +10,7 @@ using Orchard.Mvc;
namespace Orchard.Tests.Environment {
[TestFixture]
public class DefaultOrchardRuntimeTests {
public class DefaultOrchardShellTests {
static RouteDescriptor Desc(string name, string url) {
return new RouteDescriptor { Name = name, Route = new Route(url, new MvcRouteHandler()) };
}
@ -30,7 +30,7 @@ namespace Orchard.Tests.Environment {
var modelBinderProvider2 = new StubModelBinderProvider(new[] { BinderDesc(typeof(int), null), BinderDesc(typeof(long), null) });
var modelBinderPublisher = new StubModelBinderPublisher();
var runtime = new DefaultOrchardRuntime(
var runtime = new DefaultOrchardShell(
new[] { provider1, provider2 },
publisher,
new[] { modelBinderProvider1, modelBinderProvider2 },

View File

@ -0,0 +1,35 @@
using System;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using Orchard.Data;
using Orchard.Models;
using Orchard.Models.Driver;
using Orchard.Models.Records;
namespace Orchard.Tests.Models.Stubs {
public class Gamma : ModelPart<GammaRecord> {
}
public class GammaRecord {
public virtual int Id { get; set; }
public virtual ModelRecord Model { get; set; }
public virtual string Frap { get; set; }
}
public class GammaRecordOverride : IAutoMappingOverride<GammaRecord> {
public void Override(AutoMapping<GammaRecord> mapping) {
mapping.HasOne(x => x.Model);
}
}
public class GammaDriver : ModelDriver<GammaRecord> {
public GammaDriver(IRepository<GammaRecord> repository) : base(repository) {
}
protected override void New(NewModelContext context) {
if(context.ModelType == "gamma") {
WeldModelPart<Gamma>(context);
}
}
}
}

View File

@ -101,7 +101,7 @@
<Compile Include="Data\RepositoryTests.cs" />
<Compile Include="Data\StubLocator.cs" />
<Compile Include="Environment\DefaultOrchardHostTests.cs" />
<Compile Include="Environment\DefaultOrchardRuntimeTests.cs" />
<Compile Include="Environment\DefaultOrchardShellTests.cs" />
<Compile Include="Environment\OrchardStarterTests.cs" />
<Compile Include="Logging\LoggingModuleTests.cs" />
<Compile Include="Models\DefaultModelBuilderTests.cs" />

View File

@ -12,7 +12,7 @@ namespace Orchard.Environment {
private readonly ICompositionStrategy _compositionStrategy;
private readonly ControllerBuilder _controllerBuilder;
private IOrchardRuntime _current;
private IOrchardShell _current;
public DefaultOrchardHost(
@ -26,14 +26,14 @@ namespace Orchard.Environment {
}
public IOrchardRuntime Current {
public IOrchardShell Current {
get { return _current; }
}
protected virtual void Initialize() {
var runtime = CreateRuntime();
runtime.Activate();
_current = runtime;
var shell = CreateShell();
shell.Activate();
_current = shell;
_controllerBuilder.SetControllerFactory(new OrchardControllerFactory());
ServiceLocator.SetLocator(t=>_containerProvider.RequestContainer.Resolve(t));
@ -44,7 +44,7 @@ namespace Orchard.Environment {
}
protected virtual IOrchardRuntime CreateRuntime() {
protected virtual IOrchardShell CreateShell() {
// add module types to container being built
var addingModulesAndServices = new ContainerBuilder();
@ -59,18 +59,18 @@ namespace Orchard.Environment {
addingModulesAndServices.Register(serviceType).As(interfaceType).ContainerScoped();
}
var runtimeContainer = _container.CreateInnerContainer();
runtimeContainer.TagWith("runtime");
addingModulesAndServices.Build(runtimeContainer);
var shellContainer = _container.CreateInnerContainer();
shellContainer.TagWith("shell");
addingModulesAndServices.Build(shellContainer);
// instantiate and register modules on container being built
var addingModules = new ContainerBuilder();
foreach (var module in runtimeContainer.Resolve<IEnumerable<IModule>>()) {
foreach (var module in shellContainer.Resolve<IEnumerable<IModule>>()) {
addingModules.RegisterModule(module);
}
addingModules.Build(runtimeContainer);
addingModules.Build(shellContainer);
return runtimeContainer.Resolve<IOrchardRuntime>();
return shellContainer.Resolve<IOrchardShell>();
}
#region IOrchardHost Members
@ -81,8 +81,8 @@ namespace Orchard.Environment {
void IOrchardHost.EndRequest() {
EndRequest();
}
IOrchardRuntime IOrchardHost.CreateRuntime() {
return CreateRuntime();
IOrchardShell IOrchardHost.CreateShell() {
return CreateShell();
}
#endregion
}

View File

@ -3,13 +3,13 @@ using System.Linq;
using Orchard.Mvc;
namespace Orchard.Environment {
public class DefaultOrchardRuntime : IOrchardRuntime {
public class DefaultOrchardShell : IOrchardShell {
private readonly IEnumerable<IRouteProvider> _routeProviders;
private readonly IRoutePublisher _routePublisher;
private readonly IEnumerable<IModelBinderProvider> _modelBinderProviders;
private readonly IModelBinderPublisher _modelBinderPublisher;
public DefaultOrchardRuntime(
public DefaultOrchardShell(
IEnumerable<IRouteProvider> routeProviders,
IRoutePublisher routePublisher,
IEnumerable<IModelBinderProvider> modelBinderProviders,

View File

@ -2,6 +2,6 @@ namespace Orchard.Environment {
public interface IOrchardHost {
void Initialize();
void EndRequest();
IOrchardRuntime CreateRuntime();
IOrchardShell CreateShell();
}
}

View File

@ -1,5 +1,5 @@
namespace Orchard.Environment {
public interface IOrchardRuntime {
public interface IOrchardShell {
void Activate();
}
}

View File

@ -17,8 +17,8 @@ namespace Orchard.Environment {
.SingletonScoped();
builder.Register<DefaultCompositionStrategy>().As<ICompositionStrategy>()
.SingletonScoped();
builder.Register<DefaultOrchardRuntime>().As<IOrchardRuntime>()
.ContainerScoped().InContext("runtime");
builder.Register<DefaultOrchardShell>().As<IOrchardShell>()
.ContainerScoped().InContext("shell");
// The container provider gives you access to the lowest container at the time,
// and dynamically creates a per-request container. The DisposeRequestContainer method

View File

@ -90,8 +90,8 @@
<Compile Include="Data\ISessionLocator.cs" />
<Compile Include="Data\DataModule.cs" />
<Compile Include="Data\Orderable.cs" />
<Compile Include="Environment\DefaultOrchardRuntime.cs" />
<Compile Include="Environment\IOrchardRuntime.cs" />
<Compile Include="Environment\DefaultOrchardShell.cs" />
<Compile Include="Environment\IOrchardShell.cs" />
<Compile Include="Environment\OrchardStarter.cs" />
<Compile Include="IDependency.cs" />
<Compile Include="Mvc\Html\ThemeExtensions.cs" />