--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-04-16 20:58:47 -07:00
9 changed files with 53 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ using Orchard.Mvc.Routes;
using Orchard.Extensions; using Orchard.Extensions;
using Orchard.Tests.Environment.TestDependencies; using Orchard.Tests.Environment.TestDependencies;
using Orchard.Tests.Stubs; using Orchard.Tests.Stubs;
using Orchard.Extensions.Models;
namespace Orchard.Tests.Environment { namespace Orchard.Tests.Environment {
[TestFixture] [TestFixture]
@@ -91,7 +92,7 @@ namespace Orchard.Tests.Environment {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public IEnumerable<Type> LoadFeature(string featureName) { public Feature LoadFeature(string featureName) {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -15,6 +15,7 @@ using Orchard.Environment.Configuration;
using Orchard.Environment.ShellBuilders; using Orchard.Environment.ShellBuilders;
using Orchard.Environment.Topology.Models; using Orchard.Environment.Topology.Models;
using Orchard.Extensions; using Orchard.Extensions;
using Orchard.Extensions.Models;
namespace Orchard.Tests.Environment.ShellBuilders { namespace Orchard.Tests.Environment.ShellBuilders {
[TestFixture] [TestFixture]

View File

@@ -8,6 +8,7 @@ using Orchard.Extensions.Loaders;
using Orchard.Extensions.Models; using Orchard.Extensions.Models;
using Orchard.Tests.Extensions.ExtensionTypes; using Orchard.Tests.Extensions.ExtensionTypes;
using Yaml.Grammar; using Yaml.Grammar;
using Orchard.Extensions.Models;
namespace Orchard.Tests.Extensions { namespace Orchard.Tests.Extensions {
[TestFixture] [TestFixture]
@@ -253,7 +254,7 @@ features:
ExtensionManager extensionManager = new ExtensionManager(new []{extensionFolder}, new [] {extensionLoader}); 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)); Assert.That(type == typeof(Phi));
} }
} }
@@ -276,7 +277,7 @@ features:
ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }); 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(Phi));
Assert.That((type == typeof(Alpha) || (type == typeof(Beta)))); Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
} }

View File

@@ -7,6 +7,7 @@ using NUnit.Framework;
using Orchard.Extensions.Models; using Orchard.Extensions.Models;
using Orchard.Mvc.Routes; using Orchard.Mvc.Routes;
using Orchard.Extensions; using Orchard.Extensions;
using Orchard.Extensions.Models;
namespace Orchard.Tests.Mvc.Routes { namespace Orchard.Tests.Mvc.Routes {
[TestFixture] [TestFixture]
@@ -63,7 +64,7 @@ namespace Orchard.Tests.Mvc.Routes {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public IEnumerable<Type> LoadFeature(string featureName) { public Feature LoadFeature(string featureName) {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using Orchard.Extensions.Models;
namespace Orchard.Extensions {
public class ExtensionDescriptor {
/// <summary>
/// Virtual path base, "~/Themes", "~/Modules", or "~/Core"
/// </summary>
public string Location { get; set; }
/// <summary>
/// Folder name under virtual path base
/// </summary>
public string Name { get; set; }
/// <summary>
/// "Theme" or "Module"
/// </summary>
public string ExtensionType { get; set; }
// extension metadata
public string DisplayName { get; set; }
public string Description { get; set; }
public string Version { get; set; }
public string OrchardVersion { get; set; }
public string Author { get; set; }
public string WebSite { get; set; }
public string Tags { get; set; }
public string AntiForgery { get; set; }
public IEnumerable<FeatureDescriptor> Features { get; set; }
}
}

View File

@@ -115,7 +115,7 @@ namespace Orchard.Extensions {
return new ShellTopology_Obsolete { Types = types.Where(t => t.IsClass && !t.IsAbstract) }; 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); string extensionName = GetExtensionForFeature(featureName);
if (extensionName == null) throw new ArgumentException(T("Feature ") + featureName + T(" was not found in any of the installed extensions")); 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(); var extension = ActiveExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault();
@@ -131,7 +131,11 @@ namespace Orchard.Extensions {
} }
} }
return featureTypes; return new Feature {
ExtensionName = extensionName,
Name = featureName,
Types = featureTypes
};
} }
private static string GetSourceFeatureNameForType(Type type, string extensionName) { private static string GetSourceFeatureNameForType(Type type, string extensionName) {

View File

@@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Web; using System.Web;
using Orchard.Extensions.Models; using Orchard.Extensions.Models;
@@ -11,7 +10,7 @@ namespace Orchard.Extensions {
IEnumerable<ExtensionEntry> ActiveExtensions(); IEnumerable<ExtensionEntry> ActiveExtensions();
ShellTopology_Obsolete GetExtensionsTopology(); ShellTopology_Obsolete GetExtensionsTopology();
Feature LoadFeature(string featureName);
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle); void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
void UninstallExtension(string extensionType, string extensionName); void UninstallExtension(string extensionType, string extensionName);
} }

View File

@@ -3,6 +3,9 @@ using System.Collections.Generic;
namespace Orchard.Extensions.Models { namespace Orchard.Extensions.Models {
public class Feature { public class Feature {
public string ExtensionName { get; set; }
public string Name { get; set; }
public IEnumerable<Type> Types { get; set; }
public FeatureDescriptor FeatureDescriptor { get; set; } public FeatureDescriptor FeatureDescriptor { get; set; }
public Extension Extension { get; set; } public Extension Extension { get; set; }
public IEnumerable<Type> ExportedTypes { get; set; } public IEnumerable<Type> ExportedTypes { get; set; }

View File

@@ -193,6 +193,7 @@
<Compile Include="Extensions\Models\FeatureDescriptor.cs" /> <Compile Include="Extensions\Models\FeatureDescriptor.cs" />
<Compile Include="Extensions\Loaders\AreaExtensionLoader.cs" /> <Compile Include="Extensions\Loaders\AreaExtensionLoader.cs" />
<Compile Include="Extensions\Models\Feature.cs" /> <Compile Include="Extensions\Models\Feature.cs" />
<Compile Include="Extensions\Models\FeatureDescriptor.cs" />
<Compile Include="Extensions\OrchardFeatureAttribute.cs" /> <Compile Include="Extensions\OrchardFeatureAttribute.cs" />
<Compile Include="Extensions\Records\ExtensionRecord.cs" /> <Compile Include="Extensions\Records\ExtensionRecord.cs" />
<Compile Include="Extensions\ShellTopology.cs" /> <Compile Include="Extensions\ShellTopology.cs" />