mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Specs.Hosting.Orchard.Web;
|
||||
using TechTalk.SpecFlow;
|
||||
|
||||
|
@@ -111,7 +111,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Roles\Controllers\AdminControllerTests.cs" />
|
||||
<Compile Include="Roles\Services\RoleServiceTests.cs" />
|
||||
<Compile Include="Settings\Topology\ShellDescriptorManagerTests.cs" />
|
||||
<Compile Include="Settings\Blueprint\ShellDescriptorManagerTests.cs" />
|
||||
<Compile Include="Values.cs" />
|
||||
<Compile Include="Users\Controllers\AdminControllerTests.cs" />
|
||||
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
||||
|
@@ -4,14 +4,14 @@ using System.Linq;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Core.Settings.State;
|
||||
using Orchard.Core.Settings.Topology;
|
||||
using Orchard.Core.Settings.Topology.Records;
|
||||
using Orchard.Core.Settings.Descriptor;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
namespace Orchard.Tests.Modules.Settings.Blueprint {
|
||||
[TestFixture]
|
||||
public class ShellDescriptorManagerTests : DatabaseEnabledTestsBase {
|
||||
public override void Register(ContainerBuilder builder) {
|
||||
@@ -45,10 +45,10 @@ namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TopologyShouldBeNullWhenItsNotInitialized() {
|
||||
public void BlueprintShouldBeNullWhenItsNotInitialized() {
|
||||
var manager = _container.Resolve<IShellDescriptorManager>();
|
||||
var topology = manager.GetShellDescriptor();
|
||||
Assert.That(topology, Is.Null);
|
||||
var descriptor = manager.GetShellDescriptor();
|
||||
Assert.That(descriptor, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -59,9 +59,9 @@ namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>());
|
||||
|
||||
var topology = manager.GetShellDescriptor();
|
||||
Assert.That(topology, Is.Not.Null);
|
||||
Assert.That(topology.SerialNumber, Is.Not.EqualTo(0));
|
||||
var descriptor = manager.GetShellDescriptor();
|
||||
Assert.That(descriptor, Is.Not.Null);
|
||||
Assert.That(descriptor.SerialNumber, Is.Not.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -81,8 +81,8 @@ namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>());
|
||||
|
||||
var topology = manager.GetShellDescriptor();
|
||||
Assert.That(topology.SerialNumber, Is.Not.EqualTo(0));
|
||||
var descriptor = manager.GetShellDescriptor();
|
||||
Assert.That(descriptor.SerialNumber, Is.Not.EqualTo(0));
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => manager.UpdateShellDescriptor(
|
||||
0,
|
||||
@@ -90,18 +90,18 @@ namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
Enumerable.Empty<ShellParameter>()));
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => manager.UpdateShellDescriptor(
|
||||
topology.SerialNumber + 665321,
|
||||
descriptor.SerialNumber + 665321,
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>()));
|
||||
|
||||
manager.UpdateShellDescriptor(
|
||||
topology.SerialNumber,
|
||||
descriptor.SerialNumber,
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>());
|
||||
|
||||
var topology2 = manager.GetShellDescriptor();
|
||||
Assert.That(topology2.SerialNumber, Is.Not.EqualTo(0));
|
||||
Assert.That(topology2.SerialNumber, Is.Not.EqualTo(topology.SerialNumber));
|
||||
var descriptor2 = manager.GetShellDescriptor();
|
||||
Assert.That(descriptor2.SerialNumber, Is.Not.EqualTo(0));
|
||||
Assert.That(descriptor2.SerialNumber, Is.Not.EqualTo(descriptor.SerialNumber));
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => manager.UpdateShellDescriptor(
|
||||
0,
|
||||
@@ -109,17 +109,17 @@ namespace Orchard.Tests.Modules.Settings.Topology {
|
||||
Enumerable.Empty<ShellParameter>()));
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => manager.UpdateShellDescriptor(
|
||||
topology.SerialNumber,
|
||||
descriptor.SerialNumber,
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>()));
|
||||
|
||||
manager.UpdateShellDescriptor(
|
||||
topology2.SerialNumber,
|
||||
descriptor2.SerialNumber,
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>());
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => manager.UpdateShellDescriptor(
|
||||
topology2.SerialNumber,
|
||||
descriptor2.SerialNumber,
|
||||
Enumerable.Empty<ShellFeature>(),
|
||||
Enumerable.Empty<ShellParameter>()));
|
||||
}
|
@@ -2,8 +2,9 @@
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Data.Builders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.Tests.Records;
|
||||
|
||||
namespace Orchard.Tests.Data.Builders {
|
||||
@@ -49,7 +50,7 @@ namespace Orchard.Tests.Data.Builders {
|
||||
[Test]
|
||||
public void SQLiteSchemaShouldBeGeneratedAndUsable() {
|
||||
var recordDescriptors = new[] {
|
||||
new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
|
||||
new RecordBlueprint {TableName = "Hello", Type = typeof (FooRecord)}
|
||||
};
|
||||
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
||||
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
|
||||
@@ -78,7 +79,7 @@ namespace Orchard.Tests.Data.Builders {
|
||||
CreateSqlServerDatabase(databasePath);
|
||||
|
||||
var recordDescriptors = new[] {
|
||||
new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
|
||||
new RecordBlueprint {TableName = "Hello", Type = typeof (FooRecord)}
|
||||
};
|
||||
|
||||
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
||||
|
@@ -9,7 +9,8 @@ using NHibernate;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data.Builders;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Tests {
|
||||
public static class DataUtility {
|
||||
@@ -18,7 +19,7 @@ namespace Orchard.Tests {
|
||||
//var persistenceModel = AutoMap.Source(new Types(types))
|
||||
// .Alterations(alt => AddAlterations(alt, types))
|
||||
// .Conventions.AddFromAssemblyOf<DataModule>();
|
||||
var persistenceModel = AbstractBuilder.CreatePersistenceModel(types.Select(t => new RecordTopology { TableName = "Test_" + t.Name,Type = t }));
|
||||
var persistenceModel = AbstractBuilder.CreatePersistenceModel(types.Select(t => new RecordBlueprint { TableName = "Test_" + t.Name,Type = t }));
|
||||
|
||||
return Fluently.Configure()
|
||||
.Database(SQLiteConfiguration.Standard.UsingFile(fileName).ShowSql())
|
||||
|
@@ -3,14 +3,11 @@ using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.FileSystems.VirtualPath;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Tests.Environment.Topology {
|
||||
namespace Orchard.Tests.Environment.Blueprint {
|
||||
[TestFixture]
|
||||
public class DefaultShellDescriptorCacheTests {
|
||||
private IContainer _container;
|
||||
@@ -22,7 +19,7 @@ namespace Orchard.Tests.Environment.Topology {
|
||||
_tempFolder = Path.GetTempFileName();
|
||||
File.Delete(_tempFolder);
|
||||
Directory.CreateDirectory(_tempFolder);
|
||||
_appDataFolder = new AppDataFolder(new DefaultVirtualPathMonitor(new Clock()));
|
||||
_appDataFolder = new AppDataFolder();
|
||||
_appDataFolder.SetBasePath(_tempFolder);
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterInstance(_appDataFolder).As<IAppDataFolder>();
|
@@ -11,7 +11,8 @@ using Orchard.ContentManagement.Records;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Tests.Environment.Utility;
|
||||
using Orchard.Tests.Records;
|
||||
using Orchard.Tests.Utility;
|
||||
@@ -57,19 +58,19 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TopologyIsNotNull() {
|
||||
var descriptor = Build.TopologyDescriptor();
|
||||
public void BlueprintIsNotNull() {
|
||||
var descriptor = Build.ShellDescriptor();
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
Assert.That(topology, Is.Not.Null);
|
||||
Assert.That(blueprint, Is.Not.Null);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DependenciesFromFeatureArePutIntoTopology() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo", "Bar");
|
||||
public void DependenciesFromFeatureArePutIntoBlueprint() {
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Foo", "Bar");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("Foo").WithFeatures("Foo"),
|
||||
@@ -80,16 +81,16 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Bar"] = new[] { typeof(BarService1) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
Assert.That(topology, Is.Not.Null);
|
||||
Assert.That(topology.Dependencies.Count(), Is.EqualTo(2));
|
||||
Assert.That(blueprint, Is.Not.Null);
|
||||
Assert.That(blueprint.Dependencies.Count(), Is.EqualTo(2));
|
||||
|
||||
var foo = topology.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
var foo = blueprint.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
Assert.That(foo, Is.Not.Null);
|
||||
Assert.That(foo.Feature.Descriptor.Name, Is.EqualTo("Foo"));
|
||||
|
||||
var bar = topology.Dependencies.SingleOrDefault(t => t.Type == typeof(BarService1));
|
||||
var bar = blueprint.Dependencies.SingleOrDefault(t => t.Type == typeof(BarService1));
|
||||
Assert.That(bar, Is.Not.Null);
|
||||
Assert.That(bar.Feature.Descriptor.Name, Is.EqualTo("Bar"));
|
||||
}
|
||||
@@ -109,7 +110,7 @@ namespace Orchard.Tests.Environment {
|
||||
|
||||
[Test]
|
||||
public void DependenciesAreGivenParameters() {
|
||||
var descriptor = Build.TopologyDescriptor()
|
||||
var descriptor = Build.ShellDescriptor()
|
||||
.WithFeatures("Foo")
|
||||
.WithParameter<FooService1>("one", "two")
|
||||
.WithParameter<FooService1>("three", "four");
|
||||
@@ -121,9 +122,9 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Foo"] = new[] { typeof(FooService1) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
var foo = topology.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
var foo = blueprint.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
Assert.That(foo, Is.Not.Null);
|
||||
Assert.That(foo.Parameters.Count(), Is.EqualTo(2));
|
||||
Assert.That(foo.Parameters.Single(x => x.Name == "one").Value, Is.EqualTo("two"));
|
||||
@@ -131,8 +132,8 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ModulesArePutIntoTopology() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo", "Bar");
|
||||
public void ModulesArePutIntoBlueprint() {
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Foo", "Bar");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("Foo").WithFeatures("Foo"),
|
||||
@@ -143,10 +144,10 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Bar"] = new[] { typeof(BetaModule) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
var alpha = topology.Dependencies.Single(x => x.Type == typeof(AlphaModule));
|
||||
var beta = topology.Dependencies.Single(x => x.Type == typeof(BetaModule));
|
||||
var alpha = blueprint.Dependencies.Single(x => x.Type == typeof(AlphaModule));
|
||||
var beta = blueprint.Dependencies.Single(x => x.Type == typeof(BetaModule));
|
||||
|
||||
Assert.That(alpha.Feature.Descriptor.Name, Is.EqualTo("Foo"));
|
||||
Assert.That(beta.Feature.Descriptor.Name, Is.EqualTo("Bar"));
|
||||
@@ -162,8 +163,8 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ControllersArePutIntoTopologyWithAreaAndControllerName() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo Plus", "Bar Minus");
|
||||
public void ControllersArePutIntoBlueprintWithAreaAndControllerName() {
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Foo Plus", "Bar Minus");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("MyCompany.Foo", "Foo").WithFeatures("Foo", "Foo Plus"),
|
||||
@@ -176,11 +177,11 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Bar Minus"] = new[] { typeof(DeltaController), typeof(EpsilonController) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
var gamma = topology.Controllers.Single(x => x.Type == typeof(GammaController));
|
||||
var delta = topology.Controllers.Single(x => x.Type == typeof(DeltaController));
|
||||
var epsilon = topology.Controllers.Single(x => x.Type == typeof(EpsilonController));
|
||||
var gamma = blueprint.Controllers.Single(x => x.Type == typeof(GammaController));
|
||||
var delta = blueprint.Controllers.Single(x => x.Type == typeof(DeltaController));
|
||||
var epsilon = blueprint.Controllers.Single(x => x.Type == typeof(EpsilonController));
|
||||
|
||||
Assert.That(gamma.Feature.Descriptor.Name, Is.EqualTo("Foo Plus"));
|
||||
Assert.That(gamma.AreaName, Is.EqualTo("MyCompany.Foo"));
|
||||
@@ -213,8 +214,8 @@ namespace Orchard.Tests.Environment {
|
||||
|
||||
|
||||
[Test]
|
||||
public void RecordsArePutIntoTopologyWithTableName() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo Plus", "Bar", "Bar Minus");
|
||||
public void RecordsArePutIntoBlueprintWithTableName() {
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Foo Plus", "Bar", "Bar Minus");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("MyCompany.Foo", "Foo").WithFeatures("Foo", "Foo Plus"),
|
||||
@@ -227,10 +228,10 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Bar Minus"] = Enumerable.Empty<Type>();
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
var foo = topology.Records.Single(x => x.Type == typeof(FooRecord));
|
||||
var bar = topology.Records.Single(x => x.Type == typeof(BarRecord));
|
||||
var foo = blueprint.Records.Single(x => x.Type == typeof(FooRecord));
|
||||
var bar = blueprint.Records.Single(x => x.Type == typeof(BarRecord));
|
||||
|
||||
Assert.That(foo.Feature.Descriptor.Name, Is.EqualTo("Foo Plus"));
|
||||
Assert.That(foo.TableName, Is.EqualTo("MyCompany_Foo_FooRecord"));
|
||||
@@ -241,14 +242,14 @@ namespace Orchard.Tests.Environment {
|
||||
|
||||
[Test]
|
||||
public void CoreRecordsAreAddedAutomatically() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Orchard.Framework");
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Orchard.Framework");
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
var blueprint = compositionStrategy.Compose(BuildDefaultSettings(), descriptor);
|
||||
|
||||
var ct = topology.Records.Single(x => x.Type == typeof(ContentTypeRecord));
|
||||
var ci = topology.Records.Single(x => x.Type == typeof(ContentItemRecord));
|
||||
var civ = topology.Records.Single(x => x.Type == typeof(ContentItemVersionRecord));
|
||||
var ct = blueprint.Records.Single(x => x.Type == typeof(ContentTypeRecord));
|
||||
var ci = blueprint.Records.Single(x => x.Type == typeof(ContentItemRecord));
|
||||
var civ = blueprint.Records.Single(x => x.Type == typeof(ContentItemVersionRecord));
|
||||
|
||||
Assert.That(ct.Feature.Descriptor.Name, Is.EqualTo("Orchard.Framework"));
|
||||
Assert.That(ct.TableName, Is.EqualTo("Orchard_Framework_ContentTypeRecord"));
|
||||
@@ -264,7 +265,7 @@ namespace Orchard.Tests.Environment {
|
||||
public void DataPrefixChangesTableName() {
|
||||
var settings = BuildDefaultSettings();
|
||||
settings.DataTablePrefix = "Yadda";
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo Plus", "Bar", "Bar Minus");
|
||||
var descriptor = Build.ShellDescriptor().WithFeatures("Foo Plus", "Bar", "Bar Minus");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("MyCompany.Foo", "Foo").WithFeatures("Foo", "Foo Plus"),
|
||||
@@ -277,10 +278,10 @@ namespace Orchard.Tests.Environment {
|
||||
_featureTypes["Bar Minus"] = Enumerable.Empty<Type>();
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(settings, descriptor);
|
||||
var blueprint = compositionStrategy.Compose(settings, descriptor);
|
||||
|
||||
var foo = topology.Records.Single(x => x.Type == typeof(FooRecord));
|
||||
var bar = topology.Records.Single(x => x.Type == typeof(BarRecord));
|
||||
var foo = blueprint.Records.Single(x => x.Type == typeof(FooRecord));
|
||||
var bar = blueprint.Records.Single(x => x.Type == typeof(BarRecord));
|
||||
|
||||
Assert.That(foo.Feature.Descriptor.Name, Is.EqualTo("Foo Plus"));
|
||||
Assert.That(foo.TableName, Is.EqualTo("Yadda_MyCompany_Foo_FooRecord"));
|
||||
|
@@ -16,8 +16,8 @@ using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ModelBinders;
|
||||
|
@@ -14,7 +14,8 @@ using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[TestFixture]
|
||||
@@ -33,32 +34,32 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
ShellSettings CreateSettings() {
|
||||
return new ShellSettings {Name = "Default"};
|
||||
}
|
||||
ShellTopology CreateTopology(params ShellTopologyItem[] items) {
|
||||
return new ShellTopology {
|
||||
Dependencies = items.OfType<DependencyTopology>(),
|
||||
Controllers = items.OfType<ControllerTopology>(),
|
||||
Records = items.OfType<RecordTopology>(),
|
||||
ShellBlueprint CreateBlueprint(params ShellBlueprintItem[] items) {
|
||||
return new ShellBlueprint {
|
||||
Dependencies = items.OfType<DependencyBlueprint>(),
|
||||
Controllers = items.OfType<ControllerBlueprint>(),
|
||||
Records = items.OfType<RecordBlueprint>(),
|
||||
};
|
||||
}
|
||||
|
||||
DependencyTopology WithModule<T>() {
|
||||
return new DependencyTopology { Type = typeof(T), Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
DependencyBlueprint WithModule<T>() {
|
||||
return new DependencyBlueprint { Type = typeof(T), Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
}
|
||||
|
||||
ControllerTopology WithController<T>(string areaName, string controllerName) {
|
||||
return new ControllerTopology { Type = typeof(T), AreaName = areaName, ControllerName = controllerName };
|
||||
ControllerBlueprint WithController<T>(string areaName, string controllerName) {
|
||||
return new ControllerBlueprint { Type = typeof(T), AreaName = areaName, ControllerName = controllerName };
|
||||
}
|
||||
|
||||
DependencyTopology WithDependency<T>() {
|
||||
return new DependencyTopology { Type = typeof(T), Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
DependencyBlueprint WithDependency<T>() {
|
||||
return new DependencyBlueprint { Type = typeof(T), Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldReturnChildLifetimeScopeNamedShell() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology();
|
||||
var blueprint = CreateBlueprint();
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
Assert.That(shellContainer.Tag, Is.EqualTo("shell"));
|
||||
|
||||
@@ -72,12 +73,12 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void ControllersAreRegisteredAsKeyedServices() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithModule<TestModule>(),
|
||||
WithController<TestController>("foo", "bar"));
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
var controllers = shellContainer.Resolve<IIndex<string, IController>>();
|
||||
var controller = controllers["foo/bar"];
|
||||
Assert.That(controller, Is.Not.Null);
|
||||
@@ -91,12 +92,12 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void ModulesAreResolvedAndRegistered() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithModule<TestModule>(),
|
||||
WithController<TestController>("foo", "bar"));
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var controllerMetas = shellContainer.Resolve<IIndex<string, Meta<IController>>>();
|
||||
var metadata = controllerMetas["foo/bar"].Metadata;
|
||||
@@ -114,11 +115,11 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void ModulesMayResolveHostServices() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithModule<ModuleUsingThatComponent>());
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
Assert.That(shellContainer.Resolve<string>(), Is.EqualTo("Module was loaded"));
|
||||
}
|
||||
|
||||
@@ -141,11 +142,11 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void DependenciesAreResolvable() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithDependency<TestDependency>());
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var testDependency = shellContainer.Resolve<ITestDependency>();
|
||||
Assert.That(testDependency, Is.Not.Null);
|
||||
@@ -161,14 +162,14 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void ExtraInformationCanDropIntoProperties() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithDependency<TestDependency2>());
|
||||
|
||||
topology.Dependencies.Single().Feature =
|
||||
blueprint.Dependencies.Single().Feature =
|
||||
new Feature { Descriptor = new FeatureDescriptor { Name = "Hello" } };
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var testDependency = shellContainer.Resolve<ITestDependency>();
|
||||
Assert.That(testDependency, Is.Not.Null);
|
||||
@@ -187,10 +188,10 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void ParametersMayOrMayNotBeUsedAsPropertiesAndConstructorParameters() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithDependency<TestDependency3>());
|
||||
|
||||
topology.Dependencies.Single().Parameters =
|
||||
blueprint.Dependencies.Single().Parameters =
|
||||
new[] {
|
||||
new ShellParameter {Name = "alpha", Value = "-a-"},
|
||||
new ShellParameter {Name = "Beta", Value = "-b-"},
|
||||
@@ -198,7 +199,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
};
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var testDependency = shellContainer.Resolve<ITestDependency>();
|
||||
Assert.That(testDependency, Is.Not.Null);
|
||||
@@ -231,20 +232,20 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void DynamicProxyIsInEffect() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology(
|
||||
var blueprint = CreateBlueprint(
|
||||
WithModule<ProxModule>(),
|
||||
WithDependency<ProxDependency>());
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var testDependency = shellContainer.Resolve<IProxDependency>();
|
||||
Assert.That(testDependency.Hello(), Is.EqualTo("Foo"));
|
||||
|
||||
var topology2 = CreateTopology(
|
||||
var blueprint2 = CreateBlueprint(
|
||||
WithDependency<ProxDependency>());
|
||||
|
||||
var shellContainer2 = factory.CreateContainer(settings, topology2);
|
||||
var shellContainer2 = factory.CreateContainer(settings, blueprint2);
|
||||
|
||||
var testDependency2 = shellContainer2.Resolve<IProxDependency>();
|
||||
Assert.That(testDependency2.Hello(), Is.EqualTo("World"));
|
||||
@@ -281,10 +282,10 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void DynamicProxyAndShellSettingsAreResolvableToSameInstances() {
|
||||
var settings = CreateSettings();
|
||||
var topology = CreateTopology();
|
||||
var blueprint = CreateBlueprint();
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, topology);
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var proxa = shellContainer.Resolve<DynamicProxyContext>();
|
||||
var proxb = shellContainer.Resolve<DynamicProxyContext>();
|
||||
@@ -297,8 +298,8 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
Assert.That(setta, Is.SameAs(settb));
|
||||
|
||||
var settings2 = CreateSettings();
|
||||
var topology2 = CreateTopology();
|
||||
var shellContainer2 = factory.CreateContainer(settings2, topology2);
|
||||
var blueprint2 = CreateBlueprint();
|
||||
var shellContainer2 = factory.CreateContainer(settings2, blueprint2);
|
||||
|
||||
var proxa2 = shellContainer2.Resolve<DynamicProxyContext>();
|
||||
var proxb2 = shellContainer2.Resolve<DynamicProxyContext>();
|
||||
|
@@ -5,8 +5,9 @@ using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.Tests.Utility;
|
||||
|
||||
namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
@@ -25,33 +26,33 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[Test]
|
||||
public void NormalExecutionReturnsExpectedObjects() {
|
||||
var settings = new ShellSettings { Name = "Default" };
|
||||
var topologyDescriptor = new ShellDescriptor { SerialNumber = 6655321 };
|
||||
var topology = new ShellTopology();
|
||||
var descriptor = new ShellDescriptor { SerialNumber = 6655321 };
|
||||
var blueprint = new ShellBlueprint();
|
||||
var shellLifetimeScope = _container.BeginLifetimeScope("shell");
|
||||
|
||||
_container.Mock<IShellDescriptorCache>()
|
||||
.Setup(x => x.Fetch("Default"))
|
||||
.Returns(topologyDescriptor);
|
||||
.Returns(descriptor);
|
||||
|
||||
_container.Mock<ICompositionStrategy>()
|
||||
.Setup(x => x.Compose(settings, topologyDescriptor))
|
||||
.Returns(topology);
|
||||
.Setup(x => x.Compose(settings, descriptor))
|
||||
.Returns(blueprint);
|
||||
|
||||
_container.Mock<IShellContainerFactory>()
|
||||
.Setup(x => x.CreateContainer(settings, topology))
|
||||
.Setup(x => x.CreateContainer(settings, blueprint))
|
||||
.Returns(shellLifetimeScope);
|
||||
|
||||
_container.Mock<IShellDescriptorManager>()
|
||||
.Setup(x => x.GetShellDescriptor())
|
||||
.Returns(topologyDescriptor);
|
||||
.Returns(descriptor);
|
||||
|
||||
var factory = _container.Resolve<IShellContextFactory>();
|
||||
|
||||
var context = factory.CreateShellContext(settings);
|
||||
|
||||
Assert.That(context.Settings, Is.SameAs(settings));
|
||||
Assert.That(context.Descriptor, Is.SameAs(topologyDescriptor));
|
||||
Assert.That(context.Topology, Is.SameAs(topology));
|
||||
Assert.That(context.Descriptor, Is.SameAs(descriptor));
|
||||
Assert.That(context.Blueprint, Is.SameAs(blueprint));
|
||||
Assert.That(context.LifetimeScope, Is.SameAs(shellLifetimeScope));
|
||||
Assert.That(context.Shell, Is.SameAs(shellLifetimeScope.Resolve<IOrchardShell>()));
|
||||
}
|
||||
@@ -60,7 +61,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
public void CreatingSetupContextUsesOrchardSetupFeature() {
|
||||
var settings = default(ShellSettings);
|
||||
var descriptor = default(ShellDescriptor);
|
||||
var topology = new ShellTopology();
|
||||
var blueprint = new ShellBlueprint();
|
||||
|
||||
_container.Mock<ICompositionStrategy>()
|
||||
.Setup(x => x.Compose(It.IsAny<ShellSettings>(), It.IsAny<ShellDescriptor>()))
|
||||
@@ -68,10 +69,10 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
settings = s;
|
||||
descriptor = d;
|
||||
})
|
||||
.Returns(topology);
|
||||
.Returns(blueprint);
|
||||
|
||||
_container.Mock<IShellContainerFactory>()
|
||||
.Setup(x => x.CreateContainer(It.IsAny<ShellSettings>(), topology))
|
||||
.Setup(x => x.CreateContainer(It.IsAny<ShellSettings>(), blueprint))
|
||||
.Returns(_container.BeginLifetimeScope("shell"));
|
||||
|
||||
var factory = _container.Resolve<IShellContextFactory>();
|
||||
|
@@ -5,7 +5,7 @@ using NUnit.Framework;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Events;
|
||||
using Orchard.Tests.Utility;
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
|
||||
namespace Orchard.Tests.Environment.Utility {
|
||||
static class Build {
|
||||
|
||||
public static ShellDescriptor TopologyDescriptor() {
|
||||
public static ShellDescriptor ShellDescriptor() {
|
||||
var descriptor = new ShellDescriptor {
|
||||
Features = Enumerable.Empty<ShellFeature>(),
|
||||
Parameters = Enumerable.Empty<ShellParameter>(),
|
||||
|
@@ -3,7 +3,8 @@ using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Tests.Mvc.Routes {
|
||||
@@ -11,9 +12,9 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
public class StandardExtensionRouteProviderTests {
|
||||
[Test]
|
||||
public void ExtensionDisplayNameShouldBeUsedInBothStandardRoutes() {
|
||||
var topology = new ShellTopology {
|
||||
var blueprint = new ShellBlueprint {
|
||||
Controllers = new[] {
|
||||
new ControllerTopology {
|
||||
new ControllerBlueprint {
|
||||
AreaName ="Long.Name.Foo",
|
||||
Feature =new Feature {
|
||||
Descriptor=new FeatureDescriptor {
|
||||
@@ -23,7 +24,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
}
|
||||
}
|
||||
},
|
||||
new ControllerTopology {
|
||||
new ControllerBlueprint {
|
||||
AreaName ="Long.Name.Bar",
|
||||
Feature =new Feature {
|
||||
Descriptor=new FeatureDescriptor {
|
||||
@@ -35,7 +36,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
}
|
||||
}
|
||||
};
|
||||
var routeProvider = new StandardExtensionRouteProvider(topology);
|
||||
var routeProvider = new StandardExtensionRouteProvider(blueprint);
|
||||
|
||||
var routes = new List<RouteDescriptor>();
|
||||
routeProvider.GetRoutes(routes);
|
||||
|
@@ -203,7 +203,7 @@
|
||||
<Compile Include="Stubs\StubWebSiteFolder.cs" />
|
||||
<Compile Include="Utility\ContainerExtensions.cs" />
|
||||
<Compile Include="Environment\TestDependencies\TestDependency.cs" />
|
||||
<Compile Include="Environment\Topology\DefaultShellDescriptorCacheTests.cs" />
|
||||
<Compile Include="Environment\Blueprint\DefaultShellDescriptorCacheTests.cs" />
|
||||
<Compile Include="EventsTests.cs" />
|
||||
<Compile Include="Events\EventTests.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionFoldersTests.cs" />
|
||||
|
@@ -83,10 +83,10 @@ msgstr "Not authorized to manage settings"
|
||||
msgid "Settings updated"
|
||||
msgstr "Settings updated"
|
||||
|
||||
#: ~/Core/Settings/Topology/ShellDescriptorManager.cs
|
||||
#| msgid : "Invalid serial number for shell topology"
|
||||
msgid "Invalid serial number for shell topology"
|
||||
msgstr "Invalid serial number for shell topology"
|
||||
#: ~/Core/Settings/Descriptor/ShellDescriptorManager.cs
|
||||
#| msgid : "Invalid serial number for shell descriptor"
|
||||
msgid "Invalid serial number for shell descriptor"
|
||||
msgstr "Invalid serial number for shell descriptor"
|
||||
|
||||
#: ~/Core/Settings/Views/Admin/Index.ascx
|
||||
#| msgid : "Manage Settings"
|
||||
|
@@ -83,9 +83,9 @@ msgstr "Non autorisé à gérer la configuration"
|
||||
msgid "Settings updated"
|
||||
msgstr "Configuration mise à jour"
|
||||
|
||||
#: ~/Core/Settings/Topology/ShellDescriptorManager.cs
|
||||
#| msgid : "Invalid serial number for shell topology"
|
||||
msgid "Invalid serial number for shell topology"
|
||||
#: ~/Core/Settings/Descriptor/ShellDescriptorManager.cs
|
||||
#| msgid : "Invalid serial number for shell descriptor"
|
||||
msgid "Invalid serial number for shell descriptor"
|
||||
msgstr "Numéro de série de topologie de shell invalide."
|
||||
|
||||
#: ~/Core/Settings/Views/Admin/Index.ascx
|
||||
|
@@ -15,6 +15,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
// /Contents/Item/Display/72
|
||||
public ActionResult Display(int id) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
||||
|
||||
@@ -25,6 +26,8 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return View("Display", model);
|
||||
}
|
||||
|
||||
// /Contents/Item/Preview/72
|
||||
// /Contents/Item/Preview/72?version=5
|
||||
public ActionResult Preview(int id, int? version) {
|
||||
var versionOptions = VersionOptions.Latest;
|
||||
if (version != null) {
|
||||
|
@@ -182,10 +182,10 @@
|
||||
<Compile Include="Settings\State\Records\ShellFeatureStateRecord.cs" />
|
||||
<Compile Include="Settings\State\Records\ShellStateRecord.cs" />
|
||||
<Compile Include="Settings\State\ShellStateManager.cs" />
|
||||
<Compile Include="Settings\Topology\Records\ShellFeatureRecord.cs" />
|
||||
<Compile Include="Settings\Topology\Records\ShellParameterRecord.cs" />
|
||||
<Compile Include="Settings\Topology\Records\ShellDescriptorRecord.cs" />
|
||||
<Compile Include="Settings\Topology\ShellDescriptorManager.cs" />
|
||||
<Compile Include="Settings\Descriptor\Records\ShellFeatureRecord.cs" />
|
||||
<Compile Include="Settings\Descriptor\Records\ShellParameterRecord.cs" />
|
||||
<Compile Include="Settings\Descriptor\Records\ShellDescriptorRecord.cs" />
|
||||
<Compile Include="Settings\Descriptor\ShellDescriptorManager.cs" />
|
||||
<Compile Include="Settings\AdminMenu.cs" />
|
||||
<Compile Include="Settings\Controllers\AdminController.cs" />
|
||||
<Compile Include="Settings\Handlers\SiteSettingsHandler.cs" />
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
namespace Orchard.Core.Settings.Descriptor.Records {
|
||||
public class ShellDescriptorRecord {
|
||||
public ShellDescriptorRecord() {
|
||||
Features=new List<ShellFeatureRecord>();
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
namespace Orchard.Core.Settings.Descriptor.Records {
|
||||
public class ShellFeatureRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual ShellDescriptorRecord ShellDescriptorRecord { get; set; }
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
namespace Orchard.Core.Settings.Descriptor.Records {
|
||||
public class ShellParameterRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual ShellDescriptorRecord ShellDescriptorRecord { get; set; }
|
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Settings.Topology.Records;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Core.Settings.Topology {
|
||||
namespace Orchard.Core.Settings.Descriptor {
|
||||
public class ShellDescriptorManager : IShellDescriptorManager {
|
||||
private readonly IRepository<ShellDescriptorRecord> _shellDescriptorRepository;
|
||||
private readonly IShellDescriptorManagerEventHandler _events;
|
||||
@@ -22,25 +22,25 @@ namespace Orchard.Core.Settings.Topology {
|
||||
Localizer T { get; set; }
|
||||
|
||||
public ShellDescriptor GetShellDescriptor() {
|
||||
ShellDescriptorRecord shellDescriptorRecord = GetTopologyRecord();
|
||||
ShellDescriptorRecord shellDescriptorRecord = GetDescriptorRecord();
|
||||
if (shellDescriptorRecord == null) return null;
|
||||
return GetShellTopologyDescriptorFromRecord(shellDescriptorRecord);
|
||||
return GetShellDescriptorFromRecord(shellDescriptorRecord);
|
||||
}
|
||||
|
||||
private static ShellDescriptor GetShellTopologyDescriptorFromRecord(ShellDescriptorRecord shellDescriptorRecord) {
|
||||
private static ShellDescriptor GetShellDescriptorFromRecord(ShellDescriptorRecord shellDescriptorRecord) {
|
||||
ShellDescriptor descriptor = new ShellDescriptor { SerialNumber = shellDescriptorRecord.SerialNumber };
|
||||
var descriptorFeatures = new List<ShellFeature>();
|
||||
foreach (var topologyFeatureRecord in shellDescriptorRecord.Features) {
|
||||
descriptorFeatures.Add(new ShellFeature { Name = topologyFeatureRecord.Name });
|
||||
foreach (var descriptorFeatureRecord in shellDescriptorRecord.Features) {
|
||||
descriptorFeatures.Add(new ShellFeature { Name = descriptorFeatureRecord.Name });
|
||||
}
|
||||
descriptor.Features = descriptorFeatures;
|
||||
var descriptorParameters = new List<ShellParameter>();
|
||||
foreach (var topologyParameterRecord in shellDescriptorRecord.Parameters) {
|
||||
foreach (var descriptorParameterRecord in shellDescriptorRecord.Parameters) {
|
||||
descriptorParameters.Add(
|
||||
new ShellParameter {
|
||||
Component = topologyParameterRecord.Component,
|
||||
Name = topologyParameterRecord.Name,
|
||||
Value = topologyParameterRecord.Value
|
||||
Component = descriptorParameterRecord.Component,
|
||||
Name = descriptorParameterRecord.Name,
|
||||
Value = descriptorParameterRecord.Value
|
||||
});
|
||||
}
|
||||
descriptor.Parameters = descriptorParameters;
|
||||
@@ -48,15 +48,15 @@ namespace Orchard.Core.Settings.Topology {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
private ShellDescriptorRecord GetTopologyRecord() {
|
||||
private ShellDescriptorRecord GetDescriptorRecord() {
|
||||
return _shellDescriptorRepository.Get(x => true);
|
||||
}
|
||||
|
||||
public void UpdateShellDescriptor(int priorSerialNumber, IEnumerable<ShellFeature> enabledFeatures, IEnumerable<ShellParameter> parameters) {
|
||||
ShellDescriptorRecord shellDescriptorRecord = GetTopologyRecord();
|
||||
ShellDescriptorRecord shellDescriptorRecord = GetDescriptorRecord();
|
||||
var serialNumber = shellDescriptorRecord == null ? 0 : shellDescriptorRecord.SerialNumber;
|
||||
if (priorSerialNumber != serialNumber)
|
||||
throw new InvalidOperationException(T("Invalid serial number for shell topology").ToString());
|
||||
throw new InvalidOperationException(T("Invalid serial number for shell descriptor").ToString());
|
||||
|
||||
if (shellDescriptorRecord == null) {
|
||||
shellDescriptorRecord = new ShellDescriptorRecord { SerialNumber = 1 };
|
||||
@@ -82,7 +82,7 @@ namespace Orchard.Core.Settings.Topology {
|
||||
});
|
||||
}
|
||||
|
||||
_events.Changed(GetShellTopologyDescriptorFromRecord(shellDescriptorRecord));
|
||||
_events.Changed(GetShellDescriptorFromRecord(shellDescriptorRecord));
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ using Orchard.Core.Settings.State.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.State.Models;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Core.Settings.State {
|
||||
|
@@ -4,8 +4,8 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.Models;
|
||||
using Orchard.UI.Notify;
|
||||
|
@@ -10,8 +10,8 @@ using Orchard.Data;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
|
@@ -12,8 +12,8 @@ using Orchard.Data;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Localization.Services;
|
||||
|
39
src/Orchard/Caching/Signals.cs
Normal file
39
src/Orchard/Caching/Signals.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Caching {
|
||||
public interface ISignals : IVolatileProvider {
|
||||
void Trigger<T>(T signal);
|
||||
IVolatileToken When<T>(T signal);
|
||||
}
|
||||
|
||||
public class Signals : ISignals {
|
||||
readonly IDictionary<object, Token> _tokens = new Dictionary<object, Token>();
|
||||
|
||||
public void Trigger<T>(T signal) {
|
||||
lock (_tokens) {
|
||||
Token token;
|
||||
if (_tokens.TryGetValue(signal, out token)) {
|
||||
_tokens.Remove(signal);
|
||||
token.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IVolatileToken When<T>(T signal) {
|
||||
lock (_tokens) {
|
||||
Token token;
|
||||
if (!_tokens.TryGetValue(signal, out token)) {
|
||||
token = new Token();
|
||||
_tokens[signal] = token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
class Token : IVolatileToken {
|
||||
public bool IsCurrent { get; private set; }
|
||||
public void Trigger() { IsCurrent = false; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,19 +8,20 @@ using System.Reflection.Emit;
|
||||
using FluentNHibernate.Automapping;
|
||||
using FluentNHibernate.Automapping.Alterations;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.ContentManagement.Records {
|
||||
class ContentItemAlteration : IAutoMappingAlteration {
|
||||
private readonly IEnumerable<RecordTopology> _recordDescriptors;
|
||||
private readonly IEnumerable<RecordBlueprint> _recordDescriptors;
|
||||
|
||||
[UsedImplicitly]
|
||||
public ContentItemAlteration() {
|
||||
_recordDescriptors = Enumerable.Empty<RecordTopology>();
|
||||
_recordDescriptors = Enumerable.Empty<RecordBlueprint>();
|
||||
}
|
||||
|
||||
public ContentItemAlteration(IEnumerable<RecordTopology> recordDescriptors) {
|
||||
public ContentItemAlteration(IEnumerable<RecordBlueprint> recordDescriptors) {
|
||||
_recordDescriptors = recordDescriptors;
|
||||
}
|
||||
|
||||
|
@@ -11,8 +11,9 @@ using NHibernate.Cfg;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data.Conventions;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Data.Builders {
|
||||
public abstract class AbstractBuilder {
|
||||
@@ -42,7 +43,7 @@ namespace Orchard.Data.Builders {
|
||||
}
|
||||
}
|
||||
|
||||
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordTopology> recordDescriptors) {
|
||||
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordBlueprint> recordDescriptors) {
|
||||
return AutoMap.Source(new TypeSource(recordDescriptors))
|
||||
// Ensure that namespaces of types are never auto-imported, so that
|
||||
// identical type names from different namespaces can be mapped without ambiguity
|
||||
@@ -59,9 +60,9 @@ namespace Orchard.Data.Builders {
|
||||
}
|
||||
|
||||
class TypeSource : ITypeSource {
|
||||
private readonly IEnumerable<RecordTopology> _recordDescriptors;
|
||||
private readonly IEnumerable<RecordBlueprint> _recordDescriptors;
|
||||
|
||||
public TypeSource(IEnumerable<RecordTopology> recordDescriptors) { _recordDescriptors = recordDescriptors; }
|
||||
public TypeSource(IEnumerable<RecordBlueprint> recordDescriptors) { _recordDescriptors = recordDescriptors; }
|
||||
|
||||
public IEnumerable<Type> GetTypes() { return _recordDescriptors.Select(descriptor => descriptor.Type); }
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using NHibernate;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Data.Builders {
|
||||
|
||||
@@ -17,6 +18,6 @@ namespace Orchard.Data.Builders {
|
||||
public bool CreateDatabase { get; set; }
|
||||
public bool UpdateSchema { get; set; }
|
||||
|
||||
public IEnumerable<RecordTopology> RecordDescriptors { get; set; }
|
||||
public IEnumerable<RecordBlueprint> RecordDescriptors { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentNHibernate.Conventions;
|
||||
using FluentNHibernate.Conventions.Instances;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Data.Conventions {
|
||||
public class RecordTableNameConvention : IClassConvention {
|
||||
private readonly IEnumerable<RecordTopology> _descriptors;
|
||||
private readonly IEnumerable<RecordBlueprint> _descriptors;
|
||||
|
||||
public RecordTableNameConvention(IEnumerable<RecordTopology> descriptors) {
|
||||
public RecordTableNameConvention(IEnumerable<RecordBlueprint> descriptors) {
|
||||
_descriptors = descriptors;
|
||||
}
|
||||
|
||||
|
@@ -3,8 +3,9 @@ using System.IO;
|
||||
using NHibernate;
|
||||
using Orchard.Data.Builders;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Logging;
|
||||
|
||||
@@ -17,7 +18,7 @@ namespace Orchard.Data {
|
||||
|
||||
public class SessionFactoryHolder : ISessionFactoryHolder {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ShellTopology _shellTopology;
|
||||
private readonly ShellBlueprint _shellBlueprint;
|
||||
private readonly ISessionFactoryBuilder _sessionFactoryBuilder;
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
|
||||
@@ -25,11 +26,11 @@ namespace Orchard.Data {
|
||||
|
||||
public SessionFactoryHolder(
|
||||
ShellSettings shellSettings,
|
||||
ShellTopology shellTopology,
|
||||
ShellBlueprint shellBlueprint,
|
||||
ISessionFactoryBuilder sessionFactoryBuilder,
|
||||
IAppDataFolder appDataFolder) {
|
||||
_shellSettings = shellSettings;
|
||||
_shellTopology = shellTopology;
|
||||
_shellBlueprint = shellBlueprint;
|
||||
_sessionFactoryBuilder = sessionFactoryBuilder;
|
||||
_appDataFolder = appDataFolder;
|
||||
Logger = NullLogger.Instance;
|
||||
@@ -79,7 +80,7 @@ namespace Orchard.Data {
|
||||
ConnectionString = _shellSettings.DataConnectionString,
|
||||
CreateDatabase = createDatabase,
|
||||
UpdateSchema = updateSchema,
|
||||
RecordDescriptors = _shellTopology.Records,
|
||||
RecordDescriptors = _shellBlueprint.Records,
|
||||
});
|
||||
|
||||
return sessionFactory;
|
||||
|
@@ -9,8 +9,8 @@ using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
namespace Orchard.Environment.Descriptor {
|
||||
/// <summary>
|
||||
/// Service resolved out of the shell container. Primarily used by host.
|
||||
/// </summary>
|
@@ -1,13 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
namespace Orchard.Environment.Descriptor.Models {
|
||||
|
||||
/// <summary>
|
||||
/// Contains a snapshot of a tenant's enabled features.
|
||||
/// The information is drawn out of the shell via IShellDescriptorManager
|
||||
/// and cached by the host via IShellDescriptorCache. It is
|
||||
/// passed to the ICompositionStrategy to build the ShellTopology.
|
||||
/// passed to the ICompositionStrategy to build the ShellBlueprint.
|
||||
/// </summary>
|
||||
public class ShellDescriptor {
|
||||
public ShellDescriptor() {
|
@@ -2,15 +2,15 @@
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
namespace Orchard.Environment.Descriptor {
|
||||
/// <summary>
|
||||
/// Single service instance registered at the host level. Provides storage
|
||||
/// and recall of topology descriptor information. Default implementation uses
|
||||
/// and recall of shell descriptor information. Default implementation uses
|
||||
/// app_data, but configured replacements could use other per-host writable location.
|
||||
/// </summary>
|
||||
public interface IShellDescriptorCache {
|
||||
@@ -30,7 +30,7 @@ namespace Orchard.Environment.Topology {
|
||||
|
||||
public class ShellDescriptorCache : IShellDescriptorCache {
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
private const string TopologyCacheFileName = "cache.dat";
|
||||
private const string DescriptorCacheFileName = "cache.dat";
|
||||
|
||||
public ShellDescriptorCache(IAppDataFolder appDataFolder) {
|
||||
_appDataFolder = appDataFolder;
|
||||
@@ -46,7 +46,7 @@ namespace Orchard.Environment.Topology {
|
||||
|
||||
public ShellDescriptor Fetch(string name) {
|
||||
VerifyCacheFile();
|
||||
var text = _appDataFolder.ReadFile(TopologyCacheFileName);
|
||||
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.LoadXml(text);
|
||||
XmlNode rootNode = xmlDocument.DocumentElement;
|
||||
@@ -65,7 +65,7 @@ namespace Orchard.Environment.Topology {
|
||||
|
||||
public void Store(string name, ShellDescriptor descriptor) {
|
||||
VerifyCacheFile();
|
||||
var text = _appDataFolder.ReadFile(TopologyCacheFileName);
|
||||
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
||||
bool tenantCacheUpdated = false;
|
||||
var saveWriter = new StringWriter();
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
@@ -95,13 +95,13 @@ namespace Orchard.Environment.Topology {
|
||||
}
|
||||
|
||||
xmlDocument.Save(saveWriter);
|
||||
_appDataFolder.CreateFile(TopologyCacheFileName, saveWriter.ToString());
|
||||
_appDataFolder.CreateFile(DescriptorCacheFileName, saveWriter.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void VerifyCacheFile() {
|
||||
if (!_appDataFolder.FileExists(TopologyCacheFileName)) {
|
||||
if (!_appDataFolder.FileExists(DescriptorCacheFileName)) {
|
||||
var writer = new StringWriter();
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(writer)) {
|
||||
if (xmlWriter != null) {
|
||||
@@ -111,7 +111,7 @@ namespace Orchard.Environment.Topology {
|
||||
xmlWriter.WriteEndDocument();
|
||||
}
|
||||
}
|
||||
_appDataFolder.CreateFile(TopologyCacheFileName, writer.ToString());
|
||||
_appDataFolder.CreateFile(DescriptorCacheFileName, writer.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public interface IOrchardHost {
|
||||
|
@@ -13,7 +13,7 @@ using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Loaders;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Events;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.FileSystems.Dependencies;
|
||||
|
@@ -7,20 +7,21 @@ using Autofac.Core;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
/// <summary>
|
||||
/// Service at the host level to transform the cachable topology into the loadable topology.
|
||||
/// Service at the host level to transform the cachable descriptor into the loadable blueprint.
|
||||
/// </summary>
|
||||
public interface ICompositionStrategy {
|
||||
/// <summary>
|
||||
/// Using information from the IExtensionManager, transforms and populates all of the
|
||||
/// topology model the shell builders will need to correctly initialize a tenant IoC container.
|
||||
/// blueprint model the shell builders will need to correctly initialize a tenant IoC container.
|
||||
/// </summary>
|
||||
ShellTopology Compose(ShellSettings settings, ShellDescriptor descriptor);
|
||||
ShellBlueprint Compose(ShellSettings settings, ShellDescriptor descriptor);
|
||||
}
|
||||
|
||||
public class CompositionStrategy : ICompositionStrategy {
|
||||
@@ -30,30 +31,30 @@ namespace Orchard.Environment.Topology {
|
||||
_extensionManager = extensionManager;
|
||||
}
|
||||
|
||||
public ShellTopology Compose(ShellSettings settings, ShellDescriptor descriptor) {
|
||||
public ShellBlueprint Compose(ShellSettings settings, ShellDescriptor descriptor) {
|
||||
var enabledFeatures = _extensionManager.AvailableExtensions()
|
||||
.SelectMany(extensionDescriptor => extensionDescriptor.Features)
|
||||
.Where(featureDescriptor => IsFeatureEnabledInTopology(featureDescriptor, descriptor));
|
||||
.Where(featureDescriptor => IsFeatureEnabledInDescriptor(featureDescriptor, descriptor));
|
||||
|
||||
var features = _extensionManager.LoadFeatures(enabledFeatures);
|
||||
|
||||
if (descriptor.Features.Any(feature => feature.Name == "Orchard.Framework"))
|
||||
features = features.Concat(BuiltinFeatures());
|
||||
|
||||
var modules = BuildTopology(features, IsModule, BuildModule);
|
||||
var dependencies = BuildTopology(features, IsDependency, (t, f) => BuildDependency(t, f, descriptor));
|
||||
var controllers = BuildTopology(features, IsController, BuildController);
|
||||
var records = BuildTopology(features, IsRecord, (t, f) => BuildRecord(t, f, settings));
|
||||
var modules = BuildBlueprint(features, IsModule, BuildModule);
|
||||
var dependencies = BuildBlueprint(features, IsDependency, (t, f) => BuildDependency(t, f, descriptor));
|
||||
var controllers = BuildBlueprint(features, IsController, BuildController);
|
||||
var records = BuildBlueprint(features, IsRecord, (t, f) => BuildRecord(t, f, settings));
|
||||
|
||||
return new ShellTopology {
|
||||
return new ShellBlueprint {
|
||||
Dependencies = dependencies.Concat(modules).ToArray(),
|
||||
Controllers = controllers,
|
||||
Records = records,
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsFeatureEnabledInTopology(FeatureDescriptor featureDescriptor, ShellDescriptor descriptor) {
|
||||
return descriptor.Features.Any(topologyFeature => topologyFeature.Name == featureDescriptor.Name);
|
||||
private static bool IsFeatureEnabledInDescriptor(FeatureDescriptor featureDescriptor, ShellDescriptor shellDescriptor) {
|
||||
return shellDescriptor.Features.Any(shellDescriptorFeature => shellDescriptorFeature.Name == featureDescriptor.Name);
|
||||
}
|
||||
|
||||
private static IEnumerable<Feature> BuiltinFeatures() {
|
||||
@@ -72,7 +73,7 @@ namespace Orchard.Environment.Topology {
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<T> BuildTopology<T>(
|
||||
private static IEnumerable<T> BuildBlueprint<T>(
|
||||
IEnumerable<Feature> features,
|
||||
Func<Type, bool> predicate,
|
||||
Func<Type, Feature, T> selector) {
|
||||
@@ -87,16 +88,16 @@ namespace Orchard.Environment.Topology {
|
||||
return typeof(IModule).IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
private static DependencyTopology BuildModule(Type type, Feature feature) {
|
||||
return new DependencyTopology { Type = type, Feature = feature, Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
private static DependencyBlueprint BuildModule(Type type, Feature feature) {
|
||||
return new DependencyBlueprint { Type = type, Feature = feature, Parameters = Enumerable.Empty<ShellParameter>() };
|
||||
}
|
||||
|
||||
private static bool IsDependency(Type type) {
|
||||
return typeof(IDependency).IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
private static DependencyTopology BuildDependency(Type type, Feature feature, ShellDescriptor descriptor) {
|
||||
return new DependencyTopology {
|
||||
private static DependencyBlueprint BuildDependency(Type type, Feature feature, ShellDescriptor descriptor) {
|
||||
return new DependencyBlueprint {
|
||||
Type = type,
|
||||
Feature = feature,
|
||||
Parameters = descriptor.Parameters.Where(x => x.Component == type.FullName).ToArray()
|
||||
@@ -107,14 +108,14 @@ namespace Orchard.Environment.Topology {
|
||||
return typeof(IController).IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
private static ControllerTopology BuildController(Type type, Feature feature) {
|
||||
private static ControllerBlueprint BuildController(Type type, Feature feature) {
|
||||
var areaName = feature.Descriptor.Extension.Name;
|
||||
|
||||
var controllerName = type.Name;
|
||||
if (controllerName.EndsWith("Controller"))
|
||||
controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
|
||||
|
||||
return new ControllerTopology {
|
||||
return new ControllerBlueprint {
|
||||
Type = type,
|
||||
Feature = feature,
|
||||
AreaName = areaName,
|
||||
@@ -131,7 +132,7 @@ namespace Orchard.Environment.Topology {
|
||||
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type));
|
||||
}
|
||||
|
||||
private static RecordTopology BuildRecord(Type type, Feature feature, ShellSettings settings) {
|
||||
private static RecordBlueprint BuildRecord(Type type, Feature feature, ShellSettings settings) {
|
||||
var extensionDescriptor = feature.Descriptor.Extension;
|
||||
var extensionName = extensionDescriptor.Name.Replace('.', '_');
|
||||
|
||||
@@ -139,7 +140,7 @@ namespace Orchard.Environment.Topology {
|
||||
if (!string.IsNullOrEmpty(settings.DataTablePrefix))
|
||||
dataTablePrefix = settings.DataTablePrefix + "_";
|
||||
|
||||
return new RecordTopology {
|
||||
return new RecordBlueprint {
|
||||
Type = type,
|
||||
Feature = feature,
|
||||
TableName = dataTablePrefix + extensionName + '_' + type.Name,
|
@@ -1,35 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
namespace Orchard.Environment.ShellBuilders.Models {
|
||||
|
||||
/// <summary>
|
||||
/// Contains the information necessary to initialize an IoC container
|
||||
/// for a particular tenant. This model is created by the ICompositionStrategy
|
||||
/// and is passed into the IShellContainerFactory.
|
||||
/// </summary>
|
||||
public class ShellTopology {
|
||||
public IEnumerable<DependencyTopology> Dependencies { get; set; }
|
||||
public IEnumerable<ControllerTopology> Controllers { get; set; }
|
||||
public IEnumerable<RecordTopology> Records { get; set; }
|
||||
public class ShellBlueprint {
|
||||
public IEnumerable<DependencyBlueprint> Dependencies { get; set; }
|
||||
public IEnumerable<ControllerBlueprint> Controllers { get; set; }
|
||||
public IEnumerable<RecordBlueprint> Records { get; set; }
|
||||
}
|
||||
|
||||
public class ShellTopologyItem {
|
||||
public class ShellBlueprintItem {
|
||||
public Type Type { get; set; }
|
||||
public Feature Feature { get; set; }
|
||||
}
|
||||
|
||||
public class DependencyTopology : ShellTopologyItem {
|
||||
public class DependencyBlueprint : ShellBlueprintItem {
|
||||
public IEnumerable<ShellParameter> Parameters { get; set; }
|
||||
}
|
||||
|
||||
public class ControllerTopology : ShellTopologyItem {
|
||||
public class ControllerBlueprint : ShellBlueprintItem {
|
||||
public string AreaName { get; set; }
|
||||
public string ControllerName { get; set; }
|
||||
}
|
||||
|
||||
public class RecordTopology : ShellTopologyItem {
|
||||
public class RecordBlueprint : ShellBlueprintItem {
|
||||
public string TableName { get; set; }
|
||||
}
|
||||
}
|
@@ -11,13 +11,14 @@ using Autofac.Features.Indexed;
|
||||
using Autofac.Integration.Web.Mvc;
|
||||
using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
|
||||
public interface IShellContainerFactory {
|
||||
ILifetimeScope CreateContainer(ShellSettings settings, ShellTopology topology);
|
||||
ILifetimeScope CreateContainer(ShellSettings settings, ShellBlueprint blueprint);
|
||||
}
|
||||
|
||||
public class ShellContainerFactory : IShellContainerFactory {
|
||||
@@ -27,10 +28,10 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
_lifetimeScope = lifetimeScope;
|
||||
}
|
||||
|
||||
public ILifetimeScope CreateContainer(ShellSettings settings, ShellTopology topology) {
|
||||
public ILifetimeScope CreateContainer(ShellSettings settings, ShellBlueprint blueprint) {
|
||||
var intermediateScope = _lifetimeScope.BeginLifetimeScope(
|
||||
builder => {
|
||||
foreach (var item in topology.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
|
||||
foreach (var item in blueprint.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
|
||||
var registration = RegisterType(builder, item)
|
||||
.Keyed<IModule>(item.Type)
|
||||
.InstancePerDependency();
|
||||
@@ -50,14 +51,14 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
|
||||
builder.Register(ctx => dynamicProxyContext);
|
||||
builder.Register(ctx => settings);
|
||||
builder.Register(ctx => topology);
|
||||
builder.Register(ctx => blueprint);
|
||||
|
||||
var moduleIndex = intermediateScope.Resolve<IIndex<Type, IModule>>();
|
||||
foreach (var item in topology.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
|
||||
foreach (var item in blueprint.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
|
||||
builder.RegisterModule(moduleIndex[item.Type]);
|
||||
}
|
||||
|
||||
foreach (var item in topology.Dependencies.Where(t => typeof(IDependency).IsAssignableFrom(t.Type))) {
|
||||
foreach (var item in blueprint.Dependencies.Where(t => typeof(IDependency).IsAssignableFrom(t.Type))) {
|
||||
var registration = RegisterType(builder, item)
|
||||
.EnableDynamicProxy(dynamicProxyContext)
|
||||
.InstancePerLifetimeScope();
|
||||
@@ -85,7 +86,7 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in topology.Controllers) {
|
||||
foreach (var item in blueprint.Controllers) {
|
||||
var serviceKey = (item.AreaName + "/" + item.ControllerName).ToLowerInvariant();
|
||||
RegisterType(builder, item)
|
||||
.EnableDynamicProxy(dynamicProxyContext)
|
||||
@@ -104,7 +105,7 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
});
|
||||
}
|
||||
|
||||
private IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle> RegisterType(ContainerBuilder builder, ShellTopologyItem item) {
|
||||
private IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle> RegisterType(ContainerBuilder builder, ShellBlueprintItem item) {
|
||||
return builder.RegisterType(item.Type)
|
||||
.WithProperty("Feature", item.Feature)
|
||||
.WithMetadata("Feature", item.Feature);
|
||||
|
@@ -1,12 +1,13 @@
|
||||
using Autofac;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
public class ShellContext {
|
||||
public ShellSettings Settings { get; set; }
|
||||
public ShellDescriptor Descriptor { get; set; }
|
||||
public ShellTopology Topology { get; set; }
|
||||
public ShellBlueprint Blueprint { get; set; }
|
||||
public ILifetimeScope LifetimeScope { get; set; }
|
||||
public IOrchardShell Shell { get; set; }
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ using System;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
@@ -54,37 +54,37 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
|
||||
var knownDescriptor = _shellDescriptorCache.Fetch(settings.Name);
|
||||
if (knownDescriptor == null) {
|
||||
Logger.Information("No topology cached. Starting with minimum components.");
|
||||
knownDescriptor = MinimumTopologyDescriptor();
|
||||
Logger.Information("No descriptor cached. Starting with minimum components.");
|
||||
knownDescriptor = MinimumShellDescriptor();
|
||||
}
|
||||
|
||||
var topology = _compositionStrategy.Compose(settings, knownDescriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, topology);
|
||||
var blueprint = _compositionStrategy.Compose(settings, knownDescriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
|
||||
|
||||
ShellDescriptor currentDescriptor;
|
||||
using (var standaloneEnvironment = new StandaloneEnvironment(shellScope)) {
|
||||
var topologyDescriptorProvider = standaloneEnvironment.Resolve<IShellDescriptorManager>();
|
||||
currentDescriptor = topologyDescriptorProvider.GetShellDescriptor();
|
||||
var shellDescriptorManager = standaloneEnvironment.Resolve<IShellDescriptorManager>();
|
||||
currentDescriptor = shellDescriptorManager.GetShellDescriptor();
|
||||
}
|
||||
|
||||
if (currentDescriptor != null && knownDescriptor.SerialNumber != currentDescriptor.SerialNumber) {
|
||||
Logger.Information("Newer topology obtained. Rebuilding shell container.");
|
||||
Logger.Information("Newer descriptor obtained. Rebuilding shell container.");
|
||||
|
||||
_shellDescriptorCache.Store(settings.Name, currentDescriptor);
|
||||
topology = _compositionStrategy.Compose(settings, currentDescriptor);
|
||||
shellScope = _shellContainerFactory.CreateContainer(settings, topology);
|
||||
blueprint = _compositionStrategy.Compose(settings, currentDescriptor);
|
||||
shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
|
||||
}
|
||||
|
||||
return new ShellContext {
|
||||
Settings = settings,
|
||||
Descriptor = currentDescriptor,
|
||||
Topology = topology,
|
||||
Blueprint = blueprint,
|
||||
LifetimeScope = shellScope,
|
||||
Shell = shellScope.Resolve<IOrchardShell>(),
|
||||
};
|
||||
}
|
||||
|
||||
private static ShellDescriptor MinimumTopologyDescriptor() {
|
||||
private static ShellDescriptor MinimumShellDescriptor() {
|
||||
return new ShellDescriptor {
|
||||
SerialNumber = -1,
|
||||
Features = new[] {
|
||||
@@ -103,13 +103,13 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
Features = new[] { new ShellFeature { Name = "Orchard.Setup" } },
|
||||
};
|
||||
|
||||
var topology = _compositionStrategy.Compose(settings, descriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, topology);
|
||||
var blueprint = _compositionStrategy.Compose(settings, descriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
|
||||
|
||||
return new ShellContext {
|
||||
Settings = settings,
|
||||
Descriptor = descriptor,
|
||||
Topology = topology,
|
||||
Blueprint = blueprint,
|
||||
LifetimeScope = shellScope,
|
||||
Shell = shellScope.Resolve<IOrchardShell>(),
|
||||
};
|
||||
@@ -118,14 +118,14 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
public ShellContext CreateDescribedContext(ShellSettings settings, ShellDescriptor shellDescriptor) {
|
||||
Logger.Debug("Creating described context for tenant {0}", settings.Name);
|
||||
|
||||
var topology = _compositionStrategy.Compose(settings, shellDescriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, topology);
|
||||
var blueprint = _compositionStrategy.Compose(settings, shellDescriptor);
|
||||
var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
|
||||
|
||||
return new ShellContext
|
||||
{
|
||||
Settings = settings,
|
||||
Descriptor = shellDescriptor,
|
||||
Topology = topology,
|
||||
Blueprint = blueprint,
|
||||
LifetimeScope = shellScope,
|
||||
Shell = shellScope.Resolve<IOrchardShell>(),
|
||||
};
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Events;
|
||||
using Orchard.Logging;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
|
||||
namespace Orchard.Environment.State
|
||||
{
|
||||
|
@@ -5,8 +5,8 @@ using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.State.Models;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
|
||||
namespace Orchard.Environment.State {
|
||||
public class ShellStateCoordinator : IShellStateManagerEventHandler, IShellDescriptorManagerEventHandler {
|
||||
|
@@ -3,18 +3,19 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Mvc.Routes {
|
||||
public class StandardExtensionRouteProvider : IRouteProvider {
|
||||
private readonly ShellTopology _topology;
|
||||
private readonly ShellBlueprint _blueprint;
|
||||
|
||||
public StandardExtensionRouteProvider(ShellTopology topology) {
|
||||
_topology = topology;
|
||||
public StandardExtensionRouteProvider(ShellBlueprint blueprint) {
|
||||
_blueprint = blueprint;
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
var displayNamesPerArea = _topology.Controllers.GroupBy(
|
||||
var displayNamesPerArea = _blueprint.Controllers.GroupBy(
|
||||
x => x.AreaName,
|
||||
x => x.Feature.Descriptor.Extension.DisplayName);
|
||||
|
||||
|
@@ -130,6 +130,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Caching\Signals.cs" />
|
||||
<Compile Include="Collections\IPageOfItems.cs" />
|
||||
<Compile Include="Collections\PageOfItems.cs" />
|
||||
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
|
||||
@@ -397,7 +398,7 @@
|
||||
<Compile Include="Mvc\Routes\RoutePublisher.cs" />
|
||||
<Compile Include="Mvc\Routes\RouteDescriptor.cs" />
|
||||
<Compile Include="Data\Repository.cs" />
|
||||
<Compile Include="Environment\Topology\CompositionStrategy.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\CompositionStrategy.cs" />
|
||||
<Compile Include="Environment\DefaultOrchardHost.cs" />
|
||||
<Compile Include="Mvc\OrchardControllerFactory.cs" />
|
||||
<Compile Include="Environment\IOrchardHost.cs" />
|
||||
@@ -462,10 +463,10 @@
|
||||
<Compile Include="Environment\AutofacUtil\ContainerUpdater.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\ShellContextFactory.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\ShellContext.cs" />
|
||||
<Compile Include="Environment\Topology\ShellDescriptorCache.cs" />
|
||||
<Compile Include="Environment\Topology\IShellDescriptorManager.cs" />
|
||||
<Compile Include="Environment\Topology\Models\ShellTopology.cs" />
|
||||
<Compile Include="Environment\Topology\Models\ShellDescriptor.cs" />
|
||||
<Compile Include="Environment\Descriptor\ShellDescriptorCache.cs" />
|
||||
<Compile Include="Environment\Descriptor\IShellDescriptorManager.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\Models\ShellBlueprint.cs" />
|
||||
<Compile Include="Environment\Descriptor\Models\ShellDescriptor.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\ShellContainerFactory.cs" />
|
||||
<Compile Include="Environment\Configuration\ShellSettings.cs" />
|
||||
<Compile Include="Environment\StandaloneEnvironment.cs" />
|
||||
|
Reference in New Issue
Block a user