mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 19:44:02 +08:00
Roughing in service interfaces and models for shell topology work
Some existing types refactored _Obsolete suffix to indicate it's replaced w/out breaking exising usage --HG-- branch : dev
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Orchard.Tests.Environment {
|
||||
builder => {
|
||||
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
||||
builder.RegisterType<StubContainerProvider>().As<IContainerProvider>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<StubCompositionStrategy>().As<ICompositionStrategy>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<StubCompositionStrategy>().As<ICompositionStrategy_Obsolete>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
||||
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
|
||||
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
|
||||
@@ -56,14 +56,14 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
public class StubShellSettingsLoader : ITenantManager {
|
||||
private readonly List<IShellSettings> _shellSettings = new List<IShellSettings>
|
||||
private readonly List<ShellSettings> _shellSettings = new List<ShellSettings>
|
||||
{new ShellSettings {Name = "testing"}};
|
||||
|
||||
public IEnumerable<IShellSettings> LoadSettings() {
|
||||
public IEnumerable<ShellSettings> LoadSettings() {
|
||||
return _shellSettings.AsEnumerable();
|
||||
}
|
||||
|
||||
public void SaveSettings(IShellSettings settings) {
|
||||
public void SaveSettings(ShellSettings settings) {
|
||||
_shellSettings.Add(settings);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace Orchard.Tests.Environment {
|
||||
return Enumerable.Empty<ExtensionEntry>();
|
||||
}
|
||||
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Orchard.Tests.Environment {
|
||||
Assert.That(_controllerBuilder.GetControllerFactory(), Is.TypeOf<OrchardControllerFactory>());
|
||||
}
|
||||
|
||||
public class StubCompositionStrategy : ICompositionStrategy {
|
||||
public class StubCompositionStrategy : ICompositionStrategy_Obsolete {
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
};
|
||||
}
|
||||
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,16 +14,16 @@ namespace Orchard.Data {
|
||||
}
|
||||
|
||||
public class SessionFactoryHolder : ISessionFactoryHolder {
|
||||
private readonly IShellSettings _shellSettings;
|
||||
private readonly ICompositionStrategy _compositionStrategy;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ICompositionStrategy_Obsolete _compositionStrategy;
|
||||
private readonly ISessionFactoryBuilder _sessionFactoryBuilder;
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
|
||||
private ISessionFactory _sessionFactory;
|
||||
|
||||
public SessionFactoryHolder(
|
||||
IShellSettings shellSettings,
|
||||
ICompositionStrategy compositionStrategy,
|
||||
ShellSettings shellSettings,
|
||||
ICompositionStrategy_Obsolete compositionStrategy,
|
||||
ISessionFactoryBuilder sessionFactoryBuilder,
|
||||
IAppDataFolder appDataFolder) {
|
||||
_shellSettings = shellSettings;
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Orchard.Environment.Configuration {
|
||||
|
||||
public string Foo { get; set; }
|
||||
|
||||
public IEnumerable<IShellSettings> LoadSettings() {
|
||||
public IEnumerable<ShellSettings> LoadSettings() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveSettings(IShellSettings settings) {
|
||||
public void SaveSettings(ShellSettings settings) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Orchard.Environment.Configuration {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> ITenantManager.LoadSettings() {
|
||||
IEnumerable<ShellSettings> ITenantManager.LoadSettings() {
|
||||
return LoadSettings().ToArray();
|
||||
}
|
||||
|
||||
void ITenantManager.SaveSettings(IShellSettings settings) {
|
||||
void ITenantManager.SaveSettings(ShellSettings settings) {
|
||||
if (settings == null)
|
||||
throw new ArgumentException(T("There are no settings to save.").ToString());
|
||||
if (string.IsNullOrEmpty(settings.Name))
|
||||
@@ -29,7 +29,7 @@ namespace Orchard.Environment.Configuration {
|
||||
_appDataFolder.CreateFile(filePath, ComposeSettings(settings));
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> LoadSettings() {
|
||||
IEnumerable<ShellSettings> LoadSettings() {
|
||||
var filePaths = _appDataFolder
|
||||
.ListDirectories("Sites")
|
||||
.SelectMany(path => _appDataFolder.ListFiles(path))
|
||||
@@ -47,7 +47,7 @@ namespace Orchard.Environment.Configuration {
|
||||
public string DataPrefix { get; set; }
|
||||
}
|
||||
|
||||
static IShellSettings ParseSettings(string text) {
|
||||
static ShellSettings ParseSettings(string text) {
|
||||
var ser = new YamlSerializer();
|
||||
var content = ser.Deserialize(text, typeof(Content)).Cast<Content>().Single();
|
||||
return new ShellSettings {
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Environment.Configuration {
|
||||
};
|
||||
}
|
||||
|
||||
static string ComposeSettings(IShellSettings settings) {
|
||||
static string ComposeSettings(ShellSettings settings) {
|
||||
if (settings == null)
|
||||
return "";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public interface ITenantManager {
|
||||
IEnumerable<IShellSettings> LoadSettings();
|
||||
void SaveSettings(IShellSettings settings);
|
||||
IEnumerable<ShellSettings> LoadSettings();
|
||||
void SaveSettings(ShellSettings settings);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public interface IShellSettings {
|
||||
string Name { get; }
|
||||
string DataProvider { get; }
|
||||
string DataConnectionString { get; }
|
||||
string DataPrefix { get; }
|
||||
}
|
||||
|
||||
public class ShellSettings : IShellSettings {
|
||||
public class ShellSettings {
|
||||
public string Name { get; set; }
|
||||
public string DataProvider { get; set; }
|
||||
public string DataConnectionString { get; set; }
|
||||
|
||||
@@ -12,7 +12,7 @@ using Orchard.Extensions.Records;
|
||||
namespace Orchard.Environment {
|
||||
//TEMP: This will be replaced by packaging system
|
||||
|
||||
public interface ICompositionStrategy {
|
||||
public interface ICompositionStrategy_Obsolete {
|
||||
IEnumerable<Type> GetModuleTypes();
|
||||
IEnumerable<Type> GetDependencyTypes();
|
||||
IEnumerable<RecordDescriptor> GetRecordDescriptors();
|
||||
@@ -23,7 +23,7 @@ namespace Orchard.Environment {
|
||||
public string Prefix { get; set; }
|
||||
}
|
||||
|
||||
public class DefaultCompositionStrategy : ICompositionStrategy {
|
||||
public class DefaultCompositionStrategy : ICompositionStrategy_Obsolete {
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
|
||||
public DefaultCompositionStrategy(IExtensionManager extensionManager) {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Orchard.Environment {
|
||||
public class DefaultOrchardHost : IOrchardHost {
|
||||
private readonly IContainerProvider _containerProvider;
|
||||
private readonly ControllerBuilder _controllerBuilder;
|
||||
private readonly IEnumerable<IShellContainerFactory> _shellContainerFactories;
|
||||
private readonly IEnumerable<IShellContainerFactory_Obsolete> _shellContainerFactories;
|
||||
|
||||
private readonly ITenantManager _tenantManager;
|
||||
private IOrchardShell _current;
|
||||
@@ -23,7 +23,7 @@ namespace Orchard.Environment {
|
||||
IContainerProvider containerProvider,
|
||||
ITenantManager tenantManager,
|
||||
ControllerBuilder controllerBuilder,
|
||||
IEnumerable<IShellContainerFactory> shellContainerFactories) {
|
||||
IEnumerable<IShellContainerFactory_Obsolete> shellContainerFactories) {
|
||||
_containerProvider = containerProvider;
|
||||
_tenantManager = tenantManager;
|
||||
_controllerBuilder = controllerBuilder;
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Environment {
|
||||
EndRequest();
|
||||
}
|
||||
|
||||
IStandaloneEnvironment IOrchardHost.CreateStandaloneEnvironment(IShellSettings shellSettings) {
|
||||
IStandaloneEnvironment IOrchardHost.CreateStandaloneEnvironment(ShellSettings shellSettings) {
|
||||
var shellContainer = CreateShellContainer(shellSettings);
|
||||
return new StandaloneEnvironment(shellContainer);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace Orchard.Environment {
|
||||
return CreateShellContainer(null);
|
||||
}
|
||||
|
||||
private ILifetimeScope CreateShellContainer(IShellSettings shellSettings) {
|
||||
private ILifetimeScope CreateShellContainer(ShellSettings shellSettings) {
|
||||
foreach (var factory in _shellContainerFactories) {
|
||||
var container = factory.CreateContainer(shellSettings);
|
||||
if (container != null) {
|
||||
|
||||
@@ -26,6 +26,6 @@ namespace Orchard.Environment {
|
||||
/// Can be used to build an temporary self-contained instance of a shell's configured code.
|
||||
/// Services may be resolved from within this instance to configure and initialize it's storage.
|
||||
/// </summary>
|
||||
IStandaloneEnvironment CreateStandaloneEnvironment(IShellSettings shellSettings);
|
||||
IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace Orchard.Environment {
|
||||
|
||||
// a single default host implementation is needed for bootstrapping a web app domain
|
||||
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
|
||||
builder.RegisterType<DefaultCompositionStrategy>().As<ICompositionStrategy>().SingleInstance();
|
||||
builder.RegisterType<DefaultShellContainerFactory>().As<IShellContainerFactory>().SingleInstance();
|
||||
builder.RegisterType<DefaultCompositionStrategy>().As<ICompositionStrategy_Obsolete>().SingleInstance();
|
||||
builder.RegisterType<DefaultShellContainerFactory>().As<IShellContainerFactory_Obsolete>().SingleInstance();
|
||||
builder.RegisterType<AppDataFolder>().As<IAppDataFolder>().SingleInstance();
|
||||
builder.RegisterType<DefaultTenantManager>().As<ITenantManager>().SingleInstance();
|
||||
builder.RegisterType<SafeModeShellContainerFactory>().As<IShellContainerFactory>().SingleInstance();
|
||||
builder.RegisterType<SafeModeShellContainerFactory>().As<IShellContainerFactory_Obsolete>().SingleInstance();
|
||||
|
||||
// The container provider gives you access to the lowest container at the time,
|
||||
// and dynamically creates a per-request container. The EndRequestLifetime method
|
||||
|
||||
@@ -6,16 +6,16 @@ using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
public class DefaultShellContainerFactory : IShellContainerFactory {
|
||||
public class DefaultShellContainerFactory : IShellContainerFactory_Obsolete {
|
||||
private readonly IContainer _container;
|
||||
private readonly ICompositionStrategy _compositionStrategy;
|
||||
private readonly ICompositionStrategy_Obsolete _compositionStrategy;
|
||||
|
||||
public DefaultShellContainerFactory(IContainer container, ICompositionStrategy compositionStrategy) {
|
||||
public DefaultShellContainerFactory(IContainer container, ICompositionStrategy_Obsolete compositionStrategy) {
|
||||
_container = container;
|
||||
_compositionStrategy = compositionStrategy;
|
||||
}
|
||||
|
||||
public virtual ILifetimeScope CreateContainer(IShellSettings settings) {
|
||||
public virtual ILifetimeScope CreateContainer(ShellSettings settings) {
|
||||
// null settings means we need to defer to the setup container factory
|
||||
if (settings == null) {
|
||||
return null;
|
||||
@@ -25,7 +25,7 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
|
||||
// add module types to container being built
|
||||
var addingModulesAndServices = new ContainerUpdater();
|
||||
addingModulesAndServices.RegisterInstance(settings).As<IShellSettings>();
|
||||
addingModulesAndServices.RegisterInstance(settings).As<ShellSettings>();
|
||||
addingModulesAndServices.RegisterInstance(dynamicProxyContext);
|
||||
addingModulesAndServices.RegisterType<DefaultOrchardShell>().As<IOrchardShell>().SingleInstance();
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
using Autofac;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
public interface IShellContainerFactory {
|
||||
ILifetimeScope CreateContainer(IShellSettings settings);
|
||||
ILifetimeScope CreateContainer(ShellTopology topology);
|
||||
}
|
||||
|
||||
public interface IShellContainerFactory_Obsolete {
|
||||
ILifetimeScope CreateContainer(ShellSettings settings);
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,14 @@ using Orchard.UI.PageTitle;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.Environment.ShellBuilders {
|
||||
public class SafeModeShellContainerFactory : IShellContainerFactory {
|
||||
public class SafeModeShellContainerFactory : IShellContainerFactory_Obsolete {
|
||||
private readonly IContainer _container;
|
||||
|
||||
public SafeModeShellContainerFactory(IContainer container) {
|
||||
_container = container;
|
||||
}
|
||||
|
||||
public ILifetimeScope CreateContainer(IShellSettings settings) {
|
||||
public ILifetimeScope CreateContainer(ShellSettings settings) {
|
||||
// when you have settings the setup container factory is not in effect
|
||||
if (settings != null) {
|
||||
return null;
|
||||
|
||||
7
src/Orchard/Environment/Topology/ICompositionStrategy.cs
Normal file
7
src/Orchard/Environment/Topology/ICompositionStrategy.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Orchard.Environment.Topology.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
public interface ICompositionStrategy {
|
||||
ShellTopology Compose(ShellTopologyDescriptor descriptor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Orchard.Environment.Topology.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
public interface ITopologyDescriptorCache {
|
||||
ShellTopologyDescriptor Fetch(string name);
|
||||
void Store(string name, ShellTopologyDescriptor descriptor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using Orchard.Environment.Topology.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology {
|
||||
public interface ITopologyDescriptorProvider {
|
||||
ShellTopologyDescriptor GetTopologyDescriptor();
|
||||
}
|
||||
}
|
||||
35
src/Orchard/Environment/Topology/Models/ShellTopology.cs
Normal file
35
src/Orchard/Environment/Topology/Models/ShellTopology.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Extensions;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
public class ShellTopology {
|
||||
public IEnumerable<ModuleTopology> Modules { get; set; }
|
||||
public IEnumerable<DependencyTopology> Dependencies { get; set; }
|
||||
public IEnumerable<ControllerTopology> Controllers { get; set; }
|
||||
public IEnumerable<RecordTopology> Records { get; set; }
|
||||
}
|
||||
|
||||
public class ShellTopologyItem {
|
||||
public Type Type { get; set; }
|
||||
public ExtensionDescriptor ExtensionDescriptor { get; set; }
|
||||
public FeatureDescriptor FeatureDescriptor { get; set; }
|
||||
public ExtensionEntry ExtensionEntry { get; set; }
|
||||
}
|
||||
|
||||
public class ModuleTopology : ShellTopologyItem {
|
||||
}
|
||||
|
||||
public class DependencyTopology : ShellTopologyItem {
|
||||
public IEnumerable<TopologyParameter> Parameters { get; set; }
|
||||
}
|
||||
|
||||
public class ControllerTopology : ShellTopologyItem {
|
||||
public string AreaName { get; set; }
|
||||
public string ControllerName { get; set; }
|
||||
}
|
||||
|
||||
public class RecordTopology : ShellTopologyItem {
|
||||
public string TableName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
public class ShellTopologyDescriptor {
|
||||
public int SerialNumber { get; set; }
|
||||
public ShellSettings Settings { get; set; }
|
||||
public IEnumerable<TopologyFeature> EnabledFeatures { get; set; }
|
||||
public IEnumerable<TopologyParameter> Parameters { get; set; }
|
||||
}
|
||||
|
||||
public class TopologyFeature {
|
||||
public string ExtensionName { get; set; }
|
||||
public string FeatureName { get; set; }
|
||||
}
|
||||
|
||||
public class TopologyParameter {
|
||||
public string Component { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -101,10 +101,10 @@ namespace Orchard.Extensions {
|
||||
return _activeExtensions;
|
||||
}
|
||||
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
||||
var types = ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
||||
return new ShellTopology { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
||||
return new ShellTopology_Obsolete { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Orchard.Extensions {
|
||||
public interface IExtensionManager {
|
||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions();
|
||||
ShellTopology GetExtensionsTopology();
|
||||
ShellTopology_Obsolete GetExtensionsTopology();
|
||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||
void UninstallExtension(string extensionType, string extensionName);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
public class ShellTopology {
|
||||
public class ShellTopology_Obsolete {
|
||||
public IEnumerable<Type> Types { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Abstractions">
|
||||
@@ -91,6 +92,7 @@
|
||||
<Reference Include="System.Web.Routing">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Yaml, Version=1.0.3370.39839, Culture=neutral, PublicKeyToken=187a3d240e44a135, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\yaml\Yaml.dll</HintPath>
|
||||
@@ -165,6 +167,11 @@
|
||||
<Compile Include="Environment\Configuration\DefaultTenantManager.cs" />
|
||||
<Compile Include="Environment\Configuration\ITenantManager.cs" />
|
||||
<Compile Include="Environment\AutofacUtil\ContainerUpdater.cs" />
|
||||
<Compile Include="Environment\Topology\ICompositionStrategy.cs" />
|
||||
<Compile Include="Environment\Topology\ITopologyDescriptorProvider.cs" />
|
||||
<Compile Include="Environment\Topology\ITopologyDescriptorCache.cs" />
|
||||
<Compile Include="Environment\Topology\Models\ShellTopology.cs" />
|
||||
<Compile Include="Environment\Topology\Models\ShellTopologyDescriptor.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\DefaultShellContainerFactory.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\IShellContainerFactory.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\SafeModeShellContainerFactory.cs" />
|
||||
@@ -400,6 +407,9 @@
|
||||
<None Include="app.config" />
|
||||
<None Include="ContentManagement\Diagram.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Environment\Models\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in New Issue
Block a user