- 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:
Suha Can
2010-04-16 16:15:23 -07:00
parent 21f5d0f32a
commit 5ea422c11b
11 changed files with 33 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -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]

View File

@@ -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))));
}

View File

@@ -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();
}

View File

@@ -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 {

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Orchard.Extensions.Models;
namespace Orchard.Extensions {
public class ExtensionDescriptor {

View File

@@ -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) {

View File

@@ -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);
}

View 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; }
}
}

View File

@@ -1,4 +1,4 @@
namespace Orchard.Extensions {
namespace Orchard.Extensions.Models {
public class FeatureDescriptor {
public string ExtensionName { get; set; }
public string Name { get; set; }

View File

@@ -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" />