mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
- Adding Feature model and refactoring ExtensionManager to return it instead of Types array from LoadFeature().
- Updating tests. --HG-- branch : dev
This commit is contained in:
@@ -20,6 +20,7 @@ using Orchard.Mvc.Routes;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Tests.Environment.TestDependencies;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Environment {
|
||||
[TestFixture]
|
||||
@@ -86,7 +87,7 @@ namespace Orchard.Tests.Environment {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> LoadFeature(string featureName) {
|
||||
public Feature LoadFeature(string featureName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[TestFixture]
|
||||
|
||||
@@ -7,6 +7,7 @@ using Orchard.Extensions;
|
||||
using Orchard.Extensions.Loaders;
|
||||
using Orchard.Tests.Extensions.ExtensionTypes;
|
||||
using Yaml.Grammar;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Extensions {
|
||||
[TestFixture]
|
||||
@@ -252,7 +253,7 @@ features:
|
||||
|
||||
ExtensionManager extensionManager = new ExtensionManager(new []{extensionFolder}, new [] {extensionLoader});
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature("TestFeature")) {
|
||||
foreach (var type in extensionManager.LoadFeature("TestFeature").Types) {
|
||||
Assert.That(type == typeof(Phi));
|
||||
}
|
||||
}
|
||||
@@ -275,7 +276,7 @@ features:
|
||||
|
||||
ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature("TestModule")) {
|
||||
foreach (var type in extensionManager.LoadFeature("TestModule").Types) {
|
||||
Assert.That(type != typeof(Phi));
|
||||
Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Mvc.Routes;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Mvc.Routes {
|
||||
[TestFixture]
|
||||
@@ -58,7 +59,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> LoadFeature(string featureName) {
|
||||
public Feature LoadFeature(string featureName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
public class ShellTopology {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
public class ExtensionDescriptor {
|
||||
|
||||
@@ -6,6 +6,7 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Extensions.Helpers;
|
||||
using Orchard.Extensions.Loaders;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Yaml.Grammar;
|
||||
@@ -109,7 +110,7 @@ namespace Orchard.Extensions {
|
||||
return new ShellTopology_Obsolete { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
||||
}
|
||||
|
||||
public IEnumerable<Type> LoadFeature(string featureName) {
|
||||
public Feature LoadFeature(string featureName) {
|
||||
string extensionName = GetExtensionForFeature(featureName);
|
||||
if (extensionName == null) throw new ArgumentException(T("Feature ") + featureName + T(" was not found in any of the installed extensions"));
|
||||
var extension = ActiveExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault();
|
||||
@@ -125,7 +126,11 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
}
|
||||
|
||||
return featureTypes;
|
||||
return new Feature {
|
||||
ExtensionName = extensionName,
|
||||
Name = featureName,
|
||||
Types = featureTypes
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetSourceFeatureNameForType(Type type, string extensionName) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
public interface IExtensionManager {
|
||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions();
|
||||
ShellTopology_Obsolete GetExtensionsTopology();
|
||||
IEnumerable<Type> LoadFeature(string featureName);
|
||||
Feature LoadFeature(string featureName);
|
||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||
void UninstallExtension(string extensionType, string extensionName);
|
||||
}
|
||||
|
||||
10
src/Orchard/Extensions/Models/Feature.cs
Normal file
10
src/Orchard/Extensions/Models/Feature.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions.Models {
|
||||
public class Feature {
|
||||
public string ExtensionName { get; set; }
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<Type> Types { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Extensions.Models {
|
||||
public class FeatureDescriptor {
|
||||
public string ExtensionName { get; set; }
|
||||
public string Name { get; set; }
|
||||
@@ -189,8 +189,9 @@
|
||||
<Compile Include="Events\IEventBusHandler.cs" />
|
||||
<Compile Include="Extensions\AreaFolders.cs" />
|
||||
<Compile Include="Extensions\ExtensionFolders.cs" />
|
||||
<Compile Include="Extensions\FeatureDescriptor.cs" />
|
||||
<Compile Include="Extensions\Loaders\AreaExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Models\Feature.cs" />
|
||||
<Compile Include="Extensions\Models\FeatureDescriptor.cs" />
|
||||
<Compile Include="Extensions\OrchardFeatureAttribute.cs" />
|
||||
<Compile Include="Extensions\Records\ExtensionRecord.cs" />
|
||||
<Compile Include="Extensions\ShellTopology.cs" />
|
||||
|
||||
Reference in New Issue
Block a user