- 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:
Suha Can
2010-04-07 14:21:16 -07:00
parent 16782bd359
commit c2dbe346ca
6 changed files with 36 additions and 12 deletions

View File

@@ -77,6 +77,10 @@ namespace Orchard.Tests.Environment {
return Enumerable.Empty<ExtensionEntry>();
}
public IEnumerable<Type> GetExtensionsTopology() {
throw new NotImplementedException();
}
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
throw new NotImplementedException();
}

View File

@@ -16,7 +16,6 @@ namespace Orchard.Tests.Extensions {
public void Init() {
var builder = new ContainerBuilder();
_folders = new StubFolders();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
_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);
}
}
}
}

View File

@@ -54,6 +54,10 @@ namespace Orchard.Tests.Mvc.Routes {
};
}
public IEnumerable<Type> GetExtensionsTopology() {
throw new NotImplementedException();
}
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
throw new NotImplementedException();
}

View File

@@ -30,19 +30,11 @@ namespace Orchard.Environment {
}
public IEnumerable<Type> GetModuleTypes() {
var types = _extensionManager.ActiveExtensions().SelectMany(x => x.ExportedTypes);
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;
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IModule).IsAssignableFrom(t));
}
public IEnumerable<Type> GetDependencyTypes() {
var types = _extensionManager.ActiveExtensions().SelectMany(x => x.ExportedTypes);
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;
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IDependency).IsAssignableFrom(t));
}
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.SharpZipLib.Zip;
using Orchard.Environment;
using Orchard.Extensions.Helpers;
using Orchard.Extensions.Loaders;
using Orchard.Localization;
@@ -96,6 +97,12 @@ namespace Orchard.Extensions {
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) {
if (String.IsNullOrEmpty(extensionType)) {
throw new ArgumentException(T("extensionType was null or empty").ToString());

View File

@@ -1,10 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Web;
namespace Orchard.Extensions {
public interface IExtensionManager {
IEnumerable<ExtensionDescriptor> AvailableExtensions();
IEnumerable<ExtensionEntry> ActiveExtensions();
IEnumerable<Type> GetExtensionsTopology();
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
void UninstallExtension(string extensionType, string extensionName);
}