mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Compacting code and removing some obsolete things
--HG-- branch : dev
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Orchard.Tests.Modules.Setup {
|
|||||||
//builder.Register<Notifier>().As<INotifier>();
|
//builder.Register<Notifier>().As<INotifier>();
|
||||||
//builder.Register<DefaultOrchardHost>().As<IOrchardHost>();
|
//builder.Register<DefaultOrchardHost>().As<IOrchardHost>();
|
||||||
//builder.Register<DatabaseMigrationManager>().As<IDatabaseMigrationManager>();
|
//builder.Register<DatabaseMigrationManager>().As<IDatabaseMigrationManager>();
|
||||||
//builder.Register<DefaultTenantManager>().As<ITenantManager>();
|
//builder.Register<ShellSettingsManager>().As<IShellSettingsManager>();
|
||||||
//builder.Register<TestAppDataFolder>().As<IAppDataFolder>();
|
//builder.Register<TestAppDataFolder>().As<IAppDataFolder>();
|
||||||
//_container = builder.Build();
|
//_container = builder.Build();
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.Data.Builders;
|
using Orchard.Data.Builders;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
using Orchard.Tests.Records;
|
using Orchard.Tests.Records;
|
||||||
|
|
||||||
namespace Orchard.Tests.Data.Builders {
|
namespace Orchard.Tests.Data.Builders {
|
||||||
@@ -48,7 +49,7 @@ namespace Orchard.Tests.Data.Builders {
|
|||||||
[Test]
|
[Test]
|
||||||
public void SQLiteSchemaShouldBeGeneratedAndUsable() {
|
public void SQLiteSchemaShouldBeGeneratedAndUsable() {
|
||||||
var recordDescriptors = new[] {
|
var recordDescriptors = new[] {
|
||||||
new RecordDescriptor_Obsolete {Prefix = "Hello", Type = typeof (FooRecord)}
|
new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
|
||||||
};
|
};
|
||||||
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
||||||
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
|
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
|
||||||
@@ -77,7 +78,7 @@ namespace Orchard.Tests.Data.Builders {
|
|||||||
CreateSqlServerDatabase(databasePath);
|
CreateSqlServerDatabase(databasePath);
|
||||||
|
|
||||||
var recordDescriptors = new[] {
|
var recordDescriptors = new[] {
|
||||||
new RecordDescriptor_Obsolete {Prefix = "Hello", Type = typeof (FooRecord)}
|
new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
|
||||||
};
|
};
|
||||||
|
|
||||||
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
|
||||||
|
@@ -10,7 +10,8 @@ using NHibernate;
|
|||||||
using NHibernate.Tool.hbm2ddl;
|
using NHibernate.Tool.hbm2ddl;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Data.Builders;
|
using Orchard.Data.Builders;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
|
|
||||||
namespace Orchard.Tests {
|
namespace Orchard.Tests {
|
||||||
public static class DataUtility {
|
public static class DataUtility {
|
||||||
@@ -19,7 +20,7 @@ namespace Orchard.Tests {
|
|||||||
//var persistenceModel = AutoMap.Source(new Types(types))
|
//var persistenceModel = AutoMap.Source(new Types(types))
|
||||||
// .Alterations(alt => AddAlterations(alt, types))
|
// .Alterations(alt => AddAlterations(alt, types))
|
||||||
// .Conventions.AddFromAssemblyOf<DataModule>();
|
// .Conventions.AddFromAssemblyOf<DataModule>();
|
||||||
var persistenceModel = AbstractBuilder.CreatePersistenceModel(types.Select(t => new RecordDescriptor_Obsolete { Prefix = "Test", Type = t }));
|
var persistenceModel = AbstractBuilder.CreatePersistenceModel(types.Select(t => new RecordTopology { TableName = "Test", Type = t }));
|
||||||
|
|
||||||
return Fluently.Configure()
|
return Fluently.Configure()
|
||||||
.Database(SQLiteConfiguration.Standard.UsingFile(fileName).ShowSql())
|
.Database(SQLiteConfiguration.Standard.UsingFile(fileName).ShowSql())
|
||||||
|
@@ -26,7 +26,7 @@ namespace Orchard.Tests.Environment.Configuration {
|
|||||||
|
|
||||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||||
|
|
||||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
IShellSettingsManager loader = new ShellSettingsManager(_appData);
|
||||||
var settings = loader.LoadSettings().Single();
|
var settings = loader.LoadSettings().Single();
|
||||||
Assert.That(settings, Is.Not.Null);
|
Assert.That(settings, Is.Not.Null);
|
||||||
Assert.That(settings.Name, Is.EqualTo("Default"));
|
Assert.That(settings.Name, Is.EqualTo("Default"));
|
||||||
@@ -41,7 +41,7 @@ namespace Orchard.Tests.Environment.Configuration {
|
|||||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||||
_appData.CreateFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SQLite2\r\nDataConnectionString: something else2");
|
_appData.CreateFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SQLite2\r\nDataConnectionString: something else2");
|
||||||
|
|
||||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
IShellSettingsManager loader = new ShellSettingsManager(_appData);
|
||||||
var settings = loader.LoadSettings();
|
var settings = loader.LoadSettings();
|
||||||
Assert.That(settings.Count(), Is.EqualTo(2));
|
Assert.That(settings.Count(), Is.EqualTo(2));
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ namespace Orchard.Tests.Environment.Configuration {
|
|||||||
public void NewSettingsCanBeStored() {
|
public void NewSettingsCanBeStored() {
|
||||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||||
|
|
||||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
IShellSettingsManager loader = new ShellSettingsManager(_appData);
|
||||||
var foo = new ShellSettings {Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux"};
|
var foo = new ShellSettings {Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux"};
|
||||||
|
|
||||||
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(1));
|
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(1));
|
||||||
|
@@ -8,7 +8,6 @@ using Autofac.Core;
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
using Orchard.Environment;
|
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Environment.Topology;
|
using Orchard.Environment.Topology;
|
||||||
@@ -29,7 +28,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Init() {
|
public void Init() {
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<DefaultCompositionStrategy>().As<ICompositionStrategy>();
|
builder.RegisterType<CompositionStrategy>().As<ICompositionStrategy>();
|
||||||
builder.RegisterAutoMocking(MockBehavior.Strict);
|
builder.RegisterAutoMocking(MockBehavior.Strict);
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
builder => {
|
builder => {
|
||||||
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
||||||
builder.RegisterType<StubContainerProvider>().As<IContainerProvider>().InstancePerLifetimeScope();
|
builder.RegisterType<StubContainerProvider>().As<IContainerProvider>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<StubCompositionStrategy>().As<ICompositionStrategy_Obsolete>().As<ICompositionStrategy>().InstancePerLifetimeScope();
|
builder.RegisterType<StubCompositionStrategy>().As<ICompositionStrategy>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
||||||
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
|
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
|
||||||
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
|
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
|
||||||
@@ -52,7 +52,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
builder.RegisterInstance(new ViewEngineCollection { new WebFormViewEngine() });
|
builder.RegisterInstance(new ViewEngineCollection { new WebFormViewEngine() });
|
||||||
builder.RegisterInstance(new StuExtensionManager()).As<IExtensionManager>();
|
builder.RegisterInstance(new StuExtensionManager()).As<IExtensionManager>();
|
||||||
builder.RegisterInstance(new Mock<IHackInstallationGenerator>().Object);
|
builder.RegisterInstance(new Mock<IHackInstallationGenerator>().Object);
|
||||||
builder.RegisterInstance(new StubShellSettingsLoader()).As<ITenantManager>();
|
builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsManager>();
|
||||||
builder.RegisterInstance(new Mock<ITopologyDescriptorCache>().Object);
|
builder.RegisterInstance(new Mock<ITopologyDescriptorCache>().Object);
|
||||||
});
|
});
|
||||||
_lifetime = _container.BeginLifetimeScope();
|
_lifetime = _container.BeginLifetimeScope();
|
||||||
@@ -61,7 +61,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
updater.Update(_lifetime);
|
updater.Update(_lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StubShellSettingsLoader : ITenantManager {
|
public class StubShellSettingsLoader : IShellSettingsManager {
|
||||||
private readonly List<ShellSettings> _shellSettings = new List<ShellSettings>
|
private readonly List<ShellSettings> _shellSettings = new List<ShellSettings>
|
||||||
{new ShellSettings {Name = "testing"}};
|
{new ShellSettings {Name = "testing"}};
|
||||||
|
|
||||||
@@ -91,10 +91,6 @@ namespace Orchard.Tests.Environment {
|
|||||||
return Enumerable.Empty<ExtensionEntry>();
|
return Enumerable.Empty<ExtensionEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Feature LoadFeature(string featureName) {
|
public Feature LoadFeature(string featureName) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -117,11 +113,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
Assert.That(_controllerBuilder.GetControllerFactory(), Is.TypeOf<OrchardControllerFactory>());
|
Assert.That(_controllerBuilder.GetControllerFactory(), Is.TypeOf<OrchardControllerFactory>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StubCompositionStrategy : ICompositionStrategy_Obsolete, ICompositionStrategy {
|
public class StubCompositionStrategy : ICompositionStrategy {
|
||||||
public IEnumerable<RecordDescriptor_Obsolete> GetRecordDescriptors_Obsolete() {
|
|
||||||
return Enumerable.Empty<RecordDescriptor_Obsolete>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShellTopology Compose(ShellTopologyDescriptor descriptor) {
|
public ShellTopology Compose(ShellTopologyDescriptor descriptor) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ namespace Orchard.Tests.Environment.Topology {
|
|||||||
_appDataFolder.SetBasePath(_tempFolder);
|
_appDataFolder.SetBasePath(_tempFolder);
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterInstance(_appDataFolder).As<IAppDataFolder>();
|
builder.RegisterInstance(_appDataFolder).As<IAppDataFolder>();
|
||||||
builder.RegisterType<DefaultTopologyDescriptorCache>().As<ITopologyDescriptorCache>();
|
builder.RegisterType<TopologyDescriptorCache>().As<ITopologyDescriptorCache>();
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,10 +87,6 @@ namespace Orchard.Tests.Mvc.Routes {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Feature LoadFeature(string featureName) {
|
public Feature LoadFeature(string featureName) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<component instance-scope="single-instance"
|
<component instance-scope="single-instance"
|
||||||
type="Orchard.Environment.Configuration.AzureBlobTenantManager"
|
type="Orchard.Environment.Configuration.AzureBlobTenantManager"
|
||||||
service="Orchard.Environment.Configuration.ITenantManager">
|
service="Orchard.Environment.Configuration.IShellSettingsManager">
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter name="account" value="devstoreaccount1"/>
|
<parameter name="account" value="devstoreaccount1"/>
|
||||||
<parameter name="key" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>
|
<parameter name="key" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>
|
||||||
|
@@ -21,17 +21,17 @@ namespace Orchard.Setup.Controllers {
|
|||||||
public class SetupController : Controller {
|
public class SetupController : Controller {
|
||||||
private readonly INotifier _notifier;
|
private readonly INotifier _notifier;
|
||||||
private readonly IOrchardHost _orchardHost;
|
private readonly IOrchardHost _orchardHost;
|
||||||
private readonly ITenantManager _tenantManager;
|
private readonly IShellSettingsManager _shellSettingsManager;
|
||||||
private readonly IAppDataFolder _appDataFolder;
|
private readonly IAppDataFolder _appDataFolder;
|
||||||
|
|
||||||
public SetupController(
|
public SetupController(
|
||||||
INotifier notifier,
|
INotifier notifier,
|
||||||
IOrchardHost orchardHost,
|
IOrchardHost orchardHost,
|
||||||
ITenantManager tenantManager,
|
IShellSettingsManager shellSettingsManager,
|
||||||
IAppDataFolder appDataFolder) {
|
IAppDataFolder appDataFolder) {
|
||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
_orchardHost = orchardHost;
|
_orchardHost = orchardHost;
|
||||||
_tenantManager = tenantManager;
|
_shellSettingsManager = shellSettingsManager;
|
||||||
_appDataFolder = appDataFolder;
|
_appDataFolder = appDataFolder;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_tenantManager.SaveSettings(shellSettings);
|
_shellSettingsManager.SaveSettings(shellSettings);
|
||||||
|
|
||||||
_orchardHost.Reinitialize_Obsolete();
|
_orchardHost.Reinitialize_Obsolete();
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ namespace Orchard.Commands {
|
|||||||
|
|
||||||
// Find tenant (or default)
|
// Find tenant (or default)
|
||||||
tenant = tenant ?? "default";
|
tenant = tenant ?? "default";
|
||||||
var tenantManager = hostContainer.Resolve<ITenantManager>();
|
var tenantManager = hostContainer.Resolve<IShellSettingsManager>();
|
||||||
var tenantSettings = tenantManager.LoadSettings().Single(s => String.Equals(s.Name, tenant, StringComparison.OrdinalIgnoreCase));
|
var tenantSettings = tenantManager.LoadSettings().Single(s => String.Equals(s.Name, tenant, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
// Disptach command execution to ICommandManager
|
// Disptach command execution to ICommandManager
|
||||||
|
@@ -8,18 +8,19 @@ using System.Reflection.Emit;
|
|||||||
using FluentNHibernate.Automapping;
|
using FluentNHibernate.Automapping;
|
||||||
using FluentNHibernate.Automapping.Alterations;
|
using FluentNHibernate.Automapping.Alterations;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Records {
|
namespace Orchard.ContentManagement.Records {
|
||||||
class ContentItemAlteration : IAutoMappingAlteration {
|
class ContentItemAlteration : IAutoMappingAlteration {
|
||||||
private readonly IEnumerable<RecordDescriptor_Obsolete> _recordDescriptors;
|
private readonly IEnumerable<RecordTopology> _recordDescriptors;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public ContentItemAlteration() {
|
public ContentItemAlteration() {
|
||||||
_recordDescriptors = Enumerable.Empty<RecordDescriptor_Obsolete>();
|
_recordDescriptors = Enumerable.Empty<RecordTopology>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentItemAlteration(IEnumerable<RecordDescriptor_Obsolete> recordDescriptors) {
|
public ContentItemAlteration(IEnumerable<RecordTopology> recordDescriptors) {
|
||||||
_recordDescriptors = recordDescriptors;
|
_recordDescriptors = recordDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,8 @@ using NHibernate.Cfg;
|
|||||||
using NHibernate.Tool.hbm2ddl;
|
using NHibernate.Tool.hbm2ddl;
|
||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
using Orchard.Data.Conventions;
|
using Orchard.Data.Conventions;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
|
|
||||||
namespace Orchard.Data.Builders {
|
namespace Orchard.Data.Builders {
|
||||||
public abstract class AbstractBuilder {
|
public abstract class AbstractBuilder {
|
||||||
@@ -41,7 +42,7 @@ namespace Orchard.Data.Builders {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordDescriptor_Obsolete> recordDescriptors) {
|
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordTopology> recordDescriptors) {
|
||||||
return AutoMap.Source(new TypeSource(recordDescriptors))
|
return AutoMap.Source(new TypeSource(recordDescriptors))
|
||||||
// Ensure that namespaces of types are never auto-imported, so that
|
// Ensure that namespaces of types are never auto-imported, so that
|
||||||
// identical type names from different namespaces can be mapped without ambiguity
|
// identical type names from different namespaces can be mapped without ambiguity
|
||||||
@@ -58,9 +59,9 @@ namespace Orchard.Data.Builders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TypeSource : ITypeSource {
|
class TypeSource : ITypeSource {
|
||||||
private readonly IEnumerable<RecordDescriptor_Obsolete> _recordDescriptors;
|
private readonly IEnumerable<RecordTopology> _recordDescriptors;
|
||||||
|
|
||||||
public TypeSource(IEnumerable<RecordDescriptor_Obsolete> recordDescriptors) { _recordDescriptors = recordDescriptors; }
|
public TypeSource(IEnumerable<RecordTopology> recordDescriptors) { _recordDescriptors = recordDescriptors; }
|
||||||
|
|
||||||
public IEnumerable<Type> GetTypes() { return _recordDescriptors.Select(descriptor => descriptor.Type); }
|
public IEnumerable<Type> GetTypes() { return _recordDescriptors.Select(descriptor => descriptor.Type); }
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
|
|
||||||
namespace Orchard.Data.Builders {
|
namespace Orchard.Data.Builders {
|
||||||
|
|
||||||
@@ -16,6 +17,6 @@ namespace Orchard.Data.Builders {
|
|||||||
public bool CreateDatabase { get; set; }
|
public bool CreateDatabase { get; set; }
|
||||||
public bool UpdateSchema { get; set; }
|
public bool UpdateSchema { get; set; }
|
||||||
|
|
||||||
public IEnumerable<RecordDescriptor_Obsolete> RecordDescriptors { get; set; }
|
public IEnumerable<RecordTopology> RecordDescriptors { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,22 +2,21 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentNHibernate.Conventions;
|
using FluentNHibernate.Conventions;
|
||||||
using FluentNHibernate.Conventions.Instances;
|
using FluentNHibernate.Conventions.Instances;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
|
|
||||||
namespace Orchard.Data.Conventions {
|
namespace Orchard.Data.Conventions {
|
||||||
public class RecordTableNameConvention : IClassConvention {
|
public class RecordTableNameConvention : IClassConvention {
|
||||||
private readonly IEnumerable<RecordDescriptor_Obsolete> _descriptors;
|
private readonly IEnumerable<RecordTopology> _descriptors;
|
||||||
|
|
||||||
public RecordTableNameConvention(IEnumerable<RecordDescriptor_Obsolete> descriptors) {
|
public RecordTableNameConvention(IEnumerable<RecordTopology> descriptors) {
|
||||||
_descriptors = descriptors;
|
_descriptors = descriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(IClassInstance instance) {
|
public void Apply(IClassInstance instance) {
|
||||||
var desc = _descriptors.Where(d => d.Type == instance.EntityType).SingleOrDefault();
|
var desc = _descriptors.Where(d => d.Type == instance.EntityType).SingleOrDefault();
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
if (!string.IsNullOrEmpty(desc.Prefix)) {
|
instance.Table(desc.TableName);
|
||||||
instance.Table(desc.Prefix + "_" + desc.Type.Name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using Orchard.Data.Builders;
|
using Orchard.Data.Builders;
|
||||||
using Orchard.Environment;
|
|
||||||
using Orchard.Environment.Configuration;
|
using Orchard.Environment.Configuration;
|
||||||
|
using Orchard.Environment.Topology;
|
||||||
|
using Orchard.Environment.Topology.Models;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
|
||||||
namespace Orchard.Data {
|
namespace Orchard.Data {
|
||||||
@@ -15,7 +16,7 @@ namespace Orchard.Data {
|
|||||||
|
|
||||||
public class SessionFactoryHolder : ISessionFactoryHolder {
|
public class SessionFactoryHolder : ISessionFactoryHolder {
|
||||||
private readonly ShellSettings _shellSettings;
|
private readonly ShellSettings _shellSettings;
|
||||||
private readonly ICompositionStrategy_Obsolete _compositionStrategy;
|
private readonly ShellTopology _shellTopology;
|
||||||
private readonly ISessionFactoryBuilder _sessionFactoryBuilder;
|
private readonly ISessionFactoryBuilder _sessionFactoryBuilder;
|
||||||
private readonly IAppDataFolder _appDataFolder;
|
private readonly IAppDataFolder _appDataFolder;
|
||||||
|
|
||||||
@@ -23,11 +24,11 @@ namespace Orchard.Data {
|
|||||||
|
|
||||||
public SessionFactoryHolder(
|
public SessionFactoryHolder(
|
||||||
ShellSettings shellSettings,
|
ShellSettings shellSettings,
|
||||||
ICompositionStrategy_Obsolete compositionStrategy,
|
ShellTopology shellTopology,
|
||||||
ISessionFactoryBuilder sessionFactoryBuilder,
|
ISessionFactoryBuilder sessionFactoryBuilder,
|
||||||
IAppDataFolder appDataFolder) {
|
IAppDataFolder appDataFolder) {
|
||||||
_shellSettings = shellSettings;
|
_shellSettings = shellSettings;
|
||||||
_compositionStrategy = compositionStrategy;
|
_shellTopology = shellTopology;
|
||||||
_sessionFactoryBuilder = sessionFactoryBuilder;
|
_sessionFactoryBuilder = sessionFactoryBuilder;
|
||||||
_appDataFolder = appDataFolder;
|
_appDataFolder = appDataFolder;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
@@ -77,7 +78,7 @@ namespace Orchard.Data {
|
|||||||
ConnectionString = _shellSettings.DataConnectionString,
|
ConnectionString = _shellSettings.DataConnectionString,
|
||||||
CreateDatabase = createDatabase,
|
CreateDatabase = createDatabase,
|
||||||
UpdateSchema = updateSchema,
|
UpdateSchema = updateSchema,
|
||||||
RecordDescriptors = _compositionStrategy.GetRecordDescriptors_Obsolete(),
|
RecordDescriptors = _shellTopology.Records,
|
||||||
});
|
});
|
||||||
|
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Orchard.Environment.Configuration {
|
|
||||||
public class AzureBlobTenantManager : ITenantManager{
|
|
||||||
public AzureBlobTenantManager(string foo) {
|
|
||||||
int x = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Foo { get; set; }
|
|
||||||
|
|
||||||
public IEnumerable<ShellSettings> LoadSettings() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveSettings(ShellSettings settings) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,8 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Orchard.Environment.Configuration {
|
|
||||||
public interface ITenantManager {
|
|
||||||
IEnumerable<ShellSettings> LoadSettings();
|
|
||||||
void SaveSettings(ShellSettings settings);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,20 +6,25 @@ using System.Yaml.Serialization;
|
|||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.Environment.Configuration {
|
namespace Orchard.Environment.Configuration {
|
||||||
public class DefaultTenantManager : ITenantManager {
|
public interface IShellSettingsManager {
|
||||||
|
IEnumerable<ShellSettings> LoadSettings();
|
||||||
|
void SaveSettings(ShellSettings settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ShellSettingsManager : IShellSettingsManager {
|
||||||
private readonly IAppDataFolder _appDataFolder;
|
private readonly IAppDataFolder _appDataFolder;
|
||||||
Localizer T { get; set; }
|
Localizer T { get; set; }
|
||||||
|
|
||||||
public DefaultTenantManager(IAppDataFolder appDataFolder) {
|
public ShellSettingsManager(IAppDataFolder appDataFolder) {
|
||||||
_appDataFolder = appDataFolder;
|
_appDataFolder = appDataFolder;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<ShellSettings> ITenantManager.LoadSettings() {
|
IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings() {
|
||||||
return LoadSettings().ToArray();
|
return LoadSettings().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITenantManager.SaveSettings(ShellSettings settings) {
|
void IShellSettingsManager.SaveSettings(ShellSettings settings) {
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
throw new ArgumentException(T("There are no settings to save.").ToString());
|
throw new ArgumentException(T("There are no settings to save.").ToString());
|
||||||
if (string.IsNullOrEmpty(settings.Name))
|
if (string.IsNullOrEmpty(settings.Name))
|
@@ -16,18 +16,18 @@ namespace Orchard.Environment {
|
|||||||
//private readonly IContainerProvider _containerProvider;
|
//private readonly IContainerProvider _containerProvider;
|
||||||
private readonly ControllerBuilder _controllerBuilder;
|
private readonly ControllerBuilder _controllerBuilder;
|
||||||
|
|
||||||
private readonly ITenantManager _tenantManager;
|
private readonly IShellSettingsManager _shellSettingsManager;
|
||||||
private readonly IShellContextFactory _shellContextFactory;
|
private readonly IShellContextFactory _shellContextFactory;
|
||||||
|
|
||||||
private IEnumerable<ShellContext> _current;
|
private IEnumerable<ShellContext> _current;
|
||||||
|
|
||||||
public DefaultOrchardHost(
|
public DefaultOrchardHost(
|
||||||
//IContainerProvider containerProvider,
|
//IContainerProvider containerProvider,
|
||||||
ITenantManager tenantManager,
|
IShellSettingsManager shellSettingsManager,
|
||||||
IShellContextFactory shellContextFactory,
|
IShellContextFactory shellContextFactory,
|
||||||
ControllerBuilder controllerBuilder) {
|
ControllerBuilder controllerBuilder) {
|
||||||
//_containerProvider = containerProvider;
|
//_containerProvider = containerProvider;
|
||||||
_tenantManager = tenantManager;
|
_shellSettingsManager = shellSettingsManager;
|
||||||
_shellContextFactory = shellContextFactory;
|
_shellContextFactory = shellContextFactory;
|
||||||
_controllerBuilder = controllerBuilder;
|
_controllerBuilder = controllerBuilder;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
@@ -75,7 +75,7 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<ShellContext> CreateAndActivate() {
|
IEnumerable<ShellContext> CreateAndActivate() {
|
||||||
var allSettings = _tenantManager.LoadSettings();
|
var allSettings = _shellSettingsManager.LoadSettings();
|
||||||
if (allSettings.Any()) {
|
if (allSettings.Any()) {
|
||||||
return allSettings.Select(
|
return allSettings.Select(
|
||||||
settings => {
|
settings => {
|
||||||
|
@@ -112,12 +112,6 @@ namespace Orchard.Environment.Extensions {
|
|||||||
return featureDescriptors;
|
return featureDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
|
||||||
var types = ActiveExtensions_Obsolete().SelectMany(x => x.ExportedTypes);
|
|
||||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
|
||||||
return new ShellTopology_Obsolete { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
|
||||||
}
|
|
||||||
|
|
||||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||||
if (featureDescriptor.Name == "Orchard.Framework") {
|
if (featureDescriptor.Name == "Orchard.Framework") {
|
||||||
return new Feature {
|
return new Feature {
|
||||||
|
@@ -9,7 +9,6 @@ namespace Orchard.Environment.Extensions {
|
|||||||
Feature LoadFeature(FeatureDescriptor featureDescriptor);
|
Feature LoadFeature(FeatureDescriptor featureDescriptor);
|
||||||
|
|
||||||
IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete();
|
IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete();
|
||||||
ShellTopology_Obsolete GetExtensionsTopology();
|
|
||||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||||
void UninstallExtension(string extensionType, string extensionName);
|
void UninstallExtension(string extensionType, string extensionName);
|
||||||
}
|
}
|
||||||
|
@@ -13,29 +13,14 @@ namespace Orchard.Environment.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ExtensionManagerEvents : IExtensionManagerEvents {
|
public abstract class ExtensionManagerEvents : IExtensionManagerEvents {
|
||||||
public virtual void Enabling(ExtensionEventContext context) {
|
public virtual void Enabling(ExtensionEventContext context) { }
|
||||||
}
|
public virtual void Enabled(ExtensionEventContext context) { }
|
||||||
|
public virtual void Disabling(ExtensionEventContext context) {}
|
||||||
public virtual void Enabled(ExtensionEventContext context) {
|
public virtual void Disabled(ExtensionEventContext context) {}
|
||||||
}
|
public virtual void Activating(ExtensionEventContext context) {}
|
||||||
|
public virtual void Activated(ExtensionEventContext context) {}
|
||||||
public virtual void Disabling(ExtensionEventContext context) {
|
public virtual void Deactivating(ExtensionEventContext context) {}
|
||||||
}
|
public virtual void Deactivated(ExtensionEventContext context) {}
|
||||||
|
|
||||||
public virtual void Disabled(ExtensionEventContext context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Activating(ExtensionEventContext context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Activated(ExtensionEventContext context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Deactivating(ExtensionEventContext context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Deactivated(ExtensionEventContext context) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExtensionEventContext {
|
public class ExtensionEventContext {
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Integration.Web;
|
using Autofac.Integration.Web;
|
||||||
using Orchard.Environment.AutofacUtil;
|
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
namespace Orchard.Environment {
|
||||||
|
|
||||||
@@ -8,11 +7,11 @@ namespace Orchard.Environment {
|
|||||||
public FiniteContainerProvider(ILifetimeScope applicationContainer) {
|
public FiniteContainerProvider(ILifetimeScope applicationContainer) {
|
||||||
//ApplicationContainer = applicationContainer;
|
//ApplicationContainer = applicationContainer;
|
||||||
|
|
||||||
RequestLifetime = applicationContainer.BeginLifetimeScope();
|
RequestLifetime = applicationContainer.BeginLifetimeScope(
|
||||||
var builder = new ContainerUpdater();
|
builder=> {
|
||||||
// also inject this instance in case anyone asks for the container provider
|
// also inject this instance in case anyone asks for the container provider
|
||||||
builder.RegisterInstance(this).As<IContainerProvider>();
|
builder.Register(ctx => this).As<IContainerProvider>();
|
||||||
builder.Update(RequestLifetime);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndRequestLifetime() {
|
public void EndRequestLifetime() {
|
||||||
|
@@ -29,15 +29,14 @@ namespace Orchard.Environment {
|
|||||||
|
|
||||||
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
||||||
{
|
{
|
||||||
builder.RegisterType<DefaultTenantManager>().As<ITenantManager>().SingleInstance();
|
builder.RegisterType<ShellSettingsManager>().As<IShellSettingsManager>().SingleInstance();
|
||||||
|
|
||||||
builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>().SingleInstance();
|
builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>().SingleInstance();
|
||||||
{
|
{
|
||||||
builder.RegisterType<DefaultTopologyDescriptorCache>().As<ITopologyDescriptorCache>().SingleInstance();
|
builder.RegisterType<TopologyDescriptorCache>().As<ITopologyDescriptorCache>().SingleInstance();
|
||||||
|
|
||||||
builder.RegisterType<DefaultCompositionStrategy>()
|
builder.RegisterType<CompositionStrategy>()
|
||||||
.As<ICompositionStrategy>()
|
.As<ICompositionStrategy>()
|
||||||
.As<ICompositionStrategy_Obsolete>()
|
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
{
|
{
|
||||||
builder.RegisterType<ExtensionManager>().As<IExtensionManager>().SingleInstance();
|
builder.RegisterType<ExtensionManager>().As<IExtensionManager>().SingleInstance();
|
||||||
|
@@ -8,35 +8,33 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Environment.Topology;
|
|
||||||
using Orchard.Environment.Topology.Models;
|
using Orchard.Environment.Topology.Models;
|
||||||
using Orchard.Utility.Extensions;
|
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
namespace Orchard.Environment.Topology {
|
||||||
//TEMP: This will be replaced by packaging system
|
/// <summary>
|
||||||
|
/// Service at the host level to transform the cachable topology into the loadable topology.
|
||||||
public interface ICompositionStrategy_Obsolete {
|
/// </summary>
|
||||||
IEnumerable<RecordDescriptor_Obsolete> GetRecordDescriptors_Obsolete();
|
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.
|
||||||
|
/// </summary>
|
||||||
|
ShellTopology Compose(ShellTopologyDescriptor descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RecordDescriptor_Obsolete {
|
public class CompositionStrategy : ICompositionStrategy {
|
||||||
public Type Type { get; set; }
|
|
||||||
public string Prefix { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DefaultCompositionStrategy : ICompositionStrategy, ICompositionStrategy_Obsolete {
|
|
||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
|
|
||||||
public DefaultCompositionStrategy(IExtensionManager extensionManager) {
|
public CompositionStrategy(IExtensionManager extensionManager) {
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShellTopology Compose(ShellTopologyDescriptor topologyDescriptor) {
|
public ShellTopology Compose(ShellTopologyDescriptor topologyDescriptor) {
|
||||||
var featureDescriptors = _extensionManager.AvailableExtensions()
|
var enabledFeatures = _extensionManager.AvailableExtensions()
|
||||||
.SelectMany(extensionDescriptor => extensionDescriptor.Features)
|
.SelectMany(extensionDescriptor => extensionDescriptor.Features)
|
||||||
.Where(featureDescriptor => IsFeatureEnabledInTopology(featureDescriptor, topologyDescriptor));
|
.Where(featureDescriptor => IsFeatureEnabledInTopology(featureDescriptor, topologyDescriptor));
|
||||||
|
|
||||||
var features = _extensionManager.LoadFeatures(featureDescriptors);
|
var features = _extensionManager.LoadFeatures(enabledFeatures);
|
||||||
|
|
||||||
return new ShellTopology {
|
return new ShellTopology {
|
||||||
Modules = BuildTopology<ModuleTopology>(features, IsModule, BuildModule),
|
Modules = BuildTopology<ModuleTopology>(features, IsModule, BuildModule),
|
||||||
@@ -108,7 +106,7 @@ namespace Orchard.Environment {
|
|||||||
(type.GetProperty("Id").GetAccessors() ?? Enumerable.Empty<MethodInfo>()).All(x => x.IsVirtual) &&
|
(type.GetProperty("Id").GetAccessors() ?? Enumerable.Empty<MethodInfo>()).All(x => x.IsVirtual) &&
|
||||||
!type.IsSealed &&
|
!type.IsSealed &&
|
||||||
!type.IsAbstract &&
|
!type.IsAbstract &&
|
||||||
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type)); ;
|
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RecordTopology BuildRecord(Type type, Feature feature) {
|
private static RecordTopology BuildRecord(Type type, Feature feature) {
|
||||||
@@ -121,39 +119,5 @@ namespace Orchard.Environment {
|
|||||||
TableName = extensionName + '_' + type.Name,
|
TableName = extensionName + '_' + type.Name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<RecordDescriptor_Obsolete> GetRecordDescriptors_Obsolete() {
|
|
||||||
var descriptors = new List<RecordDescriptor_Obsolete>{
|
|
||||||
new RecordDescriptor_Obsolete { Prefix = "Core", Type = typeof (ContentTypeRecord)},
|
|
||||||
new RecordDescriptor_Obsolete { Prefix = "Core", Type = typeof (ContentItemRecord)},
|
|
||||||
new RecordDescriptor_Obsolete { Prefix = "Core", Type = typeof (ContentItemVersionRecord)},
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var extension in _extensionManager.ActiveExtensions_Obsolete()) {
|
|
||||||
var prefix = extension.Descriptor.Name
|
|
||||||
.Replace("Orchard.", "")
|
|
||||||
.Replace(".", "_");
|
|
||||||
|
|
||||||
var recordDescriptors = extension
|
|
||||||
.ExportedTypes
|
|
||||||
.Where(IsRecordType)
|
|
||||||
.Select(type => new RecordDescriptor_Obsolete { Prefix = prefix, Type = type });
|
|
||||||
|
|
||||||
descriptors.AddRange(recordDescriptors);
|
|
||||||
}
|
|
||||||
|
|
||||||
return descriptors.ToReadOnlyCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsRecordType(Type type) {
|
|
||||||
return ((type.Namespace ?? "").EndsWith(".Models") || (type.Namespace ?? "").EndsWith(".Records")) &&
|
|
||||||
type.GetProperty("Id") != null &&
|
|
||||||
(type.GetProperty("Id").GetAccessors() ?? Enumerable.Empty<MethodInfo>()).All(x => x.IsVirtual) &&
|
|
||||||
!type.IsSealed &&
|
|
||||||
!type.IsAbstract &&
|
|
||||||
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,14 +0,0 @@
|
|||||||
using Orchard.Environment.Topology.Models;
|
|
||||||
|
|
||||||
namespace Orchard.Environment.Topology {
|
|
||||||
/// <summary>
|
|
||||||
/// Service at the host level to transform the cachable topology into the loadable topology.
|
|
||||||
/// </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.
|
|
||||||
/// </summary>
|
|
||||||
ShellTopology Compose(ShellTopologyDescriptor descriptor);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
using Orchard.Environment.Topology.Models;
|
|
||||||
|
|
||||||
namespace Orchard.Environment.Topology {
|
|
||||||
/// <summary>
|
|
||||||
/// Single service instance registered at the host level. Provides storage
|
|
||||||
/// and recall of topology descriptor information. Default implementation uses
|
|
||||||
/// app_data, but configured replacements could use other per-host writable location.
|
|
||||||
/// </summary>
|
|
||||||
public interface ITopologyDescriptorCache {
|
|
||||||
/// <summary>
|
|
||||||
/// Recreate the named configuration information. Used at startup.
|
|
||||||
/// Returns null on cache-miss.
|
|
||||||
/// </summary>
|
|
||||||
ShellTopologyDescriptor Fetch(string name);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Commit named configuration to reasonable persistent storage.
|
|
||||||
/// This storage is scoped to the current-server and current-webapp.
|
|
||||||
/// Loss of storage is expected.
|
|
||||||
/// </summary>
|
|
||||||
void Store(string name, ShellTopologyDescriptor descriptor);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -8,11 +8,31 @@ using Orchard.Localization;
|
|||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
|
||||||
namespace Orchard.Environment.Topology {
|
namespace Orchard.Environment.Topology {
|
||||||
public class DefaultTopologyDescriptorCache : ITopologyDescriptorCache {
|
/// <summary>
|
||||||
|
/// Single service instance registered at the host level. Provides storage
|
||||||
|
/// and recall of topology descriptor information. Default implementation uses
|
||||||
|
/// app_data, but configured replacements could use other per-host writable location.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITopologyDescriptorCache {
|
||||||
|
/// <summary>
|
||||||
|
/// Recreate the named configuration information. Used at startup.
|
||||||
|
/// Returns null on cache-miss.
|
||||||
|
/// </summary>
|
||||||
|
ShellTopologyDescriptor Fetch(string name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commit named configuration to reasonable persistent storage.
|
||||||
|
/// This storage is scoped to the current-server and current-webapp.
|
||||||
|
/// Loss of storage is expected.
|
||||||
|
/// </summary>
|
||||||
|
void Store(string name, ShellTopologyDescriptor descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TopologyDescriptorCache : ITopologyDescriptorCache {
|
||||||
private readonly IAppDataFolder _appDataFolder;
|
private readonly IAppDataFolder _appDataFolder;
|
||||||
private const string TopologyCacheFileName = "cache.dat";
|
private const string TopologyCacheFileName = "cache.dat";
|
||||||
|
|
||||||
public DefaultTopologyDescriptorCache(IAppDataFolder appDataFolder) {
|
public TopologyDescriptorCache(IAppDataFolder appDataFolder) {
|
||||||
_appDataFolder = appDataFolder;
|
_appDataFolder = appDataFolder;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
@@ -123,7 +123,7 @@
|
|||||||
<Compile Include="Mvc\Routes\RoutePublisher.cs" />
|
<Compile Include="Mvc\Routes\RoutePublisher.cs" />
|
||||||
<Compile Include="Mvc\Routes\RouteDescriptor.cs" />
|
<Compile Include="Mvc\Routes\RouteDescriptor.cs" />
|
||||||
<Compile Include="Data\Repository.cs" />
|
<Compile Include="Data\Repository.cs" />
|
||||||
<Compile Include="Environment\DefaultCompositionStrategy.cs" />
|
<Compile Include="Environment\Topology\CompositionStrategy.cs" />
|
||||||
<Compile Include="Environment\DefaultOrchardHost.cs" />
|
<Compile Include="Environment\DefaultOrchardHost.cs" />
|
||||||
<Compile Include="Mvc\OrchardControllerFactory.cs" />
|
<Compile Include="Mvc\OrchardControllerFactory.cs" />
|
||||||
<Compile Include="Environment\IOrchardHost.cs" />
|
<Compile Include="Environment\IOrchardHost.cs" />
|
||||||
@@ -165,16 +165,12 @@
|
|||||||
<Compile Include="Environment\AutofacUtil\DynamicProxy2\DynamicProxyExtensions.cs" />
|
<Compile Include="Environment\AutofacUtil\DynamicProxy2\DynamicProxyExtensions.cs" />
|
||||||
<Compile Include="Environment\AutofacUtil\DynamicProxy2\ConstructorFinderWrapper.cs" />
|
<Compile Include="Environment\AutofacUtil\DynamicProxy2\ConstructorFinderWrapper.cs" />
|
||||||
<Compile Include="Environment\Configuration\AppDataFolder.cs" />
|
<Compile Include="Environment\Configuration\AppDataFolder.cs" />
|
||||||
<Compile Include="Environment\Configuration\AzureBlobTenantManager.cs" />
|
<Compile Include="Environment\Configuration\ShellSettingsManager.cs" />
|
||||||
<Compile Include="Environment\Configuration\DefaultTenantManager.cs" />
|
|
||||||
<Compile Include="Environment\Configuration\ITenantManager.cs" />
|
|
||||||
<Compile Include="Environment\AutofacUtil\ContainerUpdater.cs" />
|
<Compile Include="Environment\AutofacUtil\ContainerUpdater.cs" />
|
||||||
<Compile Include="Environment\ShellBuilders\ShellContextFactory.cs" />
|
<Compile Include="Environment\ShellBuilders\ShellContextFactory.cs" />
|
||||||
<Compile Include="Environment\ShellBuilders\ShellContext.cs" />
|
<Compile Include="Environment\ShellBuilders\ShellContext.cs" />
|
||||||
<Compile Include="Environment\Topology\DefaultTopologyDescriptorCache.cs" />
|
<Compile Include="Environment\Topology\TopologyDescriptorCache.cs" />
|
||||||
<Compile Include="Environment\Topology\ICompositionStrategy.cs" />
|
|
||||||
<Compile Include="Environment\Topology\ITopologyDescriptorManager.cs" />
|
<Compile Include="Environment\Topology\ITopologyDescriptorManager.cs" />
|
||||||
<Compile Include="Environment\Topology\ITopologyDescriptorCache.cs" />
|
|
||||||
<Compile Include="Environment\Topology\Models\ShellTopology.cs" />
|
<Compile Include="Environment\Topology\Models\ShellTopology.cs" />
|
||||||
<Compile Include="Environment\Topology\Models\ShellTopologyDescriptor.cs" />
|
<Compile Include="Environment\Topology\Models\ShellTopologyDescriptor.cs" />
|
||||||
<Compile Include="Environment\ShellBuilders\ShellContainerFactory.cs" />
|
<Compile Include="Environment\ShellBuilders\ShellContainerFactory.cs" />
|
||||||
|
Reference in New Issue
Block a user