mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
- Adding GetExtensionsTopology to ExtensionManager. This returns the topology for the currently active extensions.
- DefaultCompositionStrategy has GetModules/Dependencies for the host to call when spinning up shells for the tenants. - Unit tests. --HG-- branch : dev
This commit is contained in:
@@ -77,6 +77,10 @@ namespace Orchard.Tests.Environment {
|
|||||||
return Enumerable.Empty<ExtensionEntry>();
|
return Enumerable.Empty<ExtensionEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> GetExtensionsTopology() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace Orchard.Tests.Extensions {
|
|||||||
public void Init() {
|
public void Init() {
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
_folders = new StubFolders();
|
_folders = new StubFolders();
|
||||||
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
|
||||||
builder.RegisterInstance(_folders).As<IExtensionFolders>();
|
builder.RegisterInstance(_folders).As<IExtensionFolders>();
|
||||||
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
|
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
@@ -175,5 +174,21 @@ features:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ExtensionManagerShouldReturnTopology() {
|
||||||
|
var topology = _manager.GetExtensionsTopology();
|
||||||
|
|
||||||
|
Assert.That(topology.Count(), Is.Not.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ExtensionManagerTopologyShouldContainNonAbstractClasses() {
|
||||||
|
var topology = _manager.GetExtensionsTopology();
|
||||||
|
|
||||||
|
foreach (var type in topology) {
|
||||||
|
Assert.That(type.IsClass);
|
||||||
|
Assert.That(!type.IsAbstract);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ namespace Orchard.Tests.Mvc.Routes {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> GetExtensionsTopology() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,19 +30,11 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> GetModuleTypes() {
|
public IEnumerable<Type> GetModuleTypes() {
|
||||||
var types = _extensionManager.ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IModule).IsAssignableFrom(t));
|
||||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
|
||||||
var nonAbstractClasses = types.Where(t => t.IsClass && !t.IsAbstract);
|
|
||||||
var modules = nonAbstractClasses.Where(t => typeof(IModule).IsAssignableFrom(t));
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> GetDependencyTypes() {
|
public IEnumerable<Type> GetDependencyTypes() {
|
||||||
var types = _extensionManager.ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IDependency).IsAssignableFrom(t));
|
||||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
|
||||||
var nonAbstractClasses = types.Where(t => t.IsClass && !t.IsAbstract);
|
|
||||||
var modules = nonAbstractClasses.Where(t => typeof(IDependency).IsAssignableFrom(t));
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {
|
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using Orchard.Environment;
|
||||||
using Orchard.Extensions.Helpers;
|
using Orchard.Extensions.Helpers;
|
||||||
using Orchard.Extensions.Loaders;
|
using Orchard.Extensions.Loaders;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -96,6 +97,12 @@ namespace Orchard.Extensions {
|
|||||||
return _activeExtensions;
|
return _activeExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> GetExtensionsTopology() {
|
||||||
|
var types = ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
||||||
|
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
||||||
|
return types.Where(t => t.IsClass && !t.IsAbstract);
|
||||||
|
}
|
||||||
|
|
||||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||||
if (String.IsNullOrEmpty(extensionType)) {
|
if (String.IsNullOrEmpty(extensionType)) {
|
||||||
throw new ArgumentException(T("extensionType was null or empty").ToString());
|
throw new ArgumentException(T("extensionType was null or empty").ToString());
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
||||||
namespace Orchard.Extensions {
|
namespace Orchard.Extensions {
|
||||||
public interface IExtensionManager {
|
public interface IExtensionManager {
|
||||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||||
IEnumerable<ExtensionEntry> ActiveExtensions();
|
IEnumerable<ExtensionEntry> ActiveExtensions();
|
||||||
|
IEnumerable<Type> 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user