mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Relocating extensions to environment namespace
--HG-- branch : dev
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using Autofac.Core;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Tests.Utility;
|
||||
|
||||
namespace Orchard.Tests.Environment {
|
||||
@@ -75,7 +78,7 @@ namespace Orchard.Tests.Environment {
|
||||
Assert.That(topology, Is.Not.Null);
|
||||
Assert.That(topology.Dependencies.Count(), Is.EqualTo(2));
|
||||
|
||||
var foo = topology.Dependencies.SingleOrDefault(t => t.Type == typeof (FooService1));
|
||||
var foo = topology.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
Assert.That(foo, Is.Not.Null);
|
||||
Assert.That(foo.Feature.FeatureDescriptor.Name, Is.EqualTo("Foo"));
|
||||
|
||||
@@ -95,6 +98,111 @@ namespace Orchard.Tests.Environment {
|
||||
|
||||
public class BarService1 : IBarService {
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DependenciesAreGivenParameters() {
|
||||
var descriptor = Build.TopologyDescriptor()
|
||||
.WithFeatures("Foo")
|
||||
.WithParameter<FooService1>("one", "two")
|
||||
.WithParameter<FooService1>("three", "four");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("Foo").WithFeatures("Foo"),
|
||||
};
|
||||
|
||||
_featureTypes["Foo"] = new[] { typeof(FooService1) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(descriptor);
|
||||
|
||||
var foo = topology.Dependencies.SingleOrDefault(t => t.Type == typeof(FooService1));
|
||||
Assert.That(foo, Is.Not.Null);
|
||||
Assert.That(foo.Parameters.Count(), Is.EqualTo(2));
|
||||
Assert.That(foo.Parameters.Single(x => x.Name == "one").Value, Is.EqualTo("two"));
|
||||
Assert.That(foo.Parameters.Single(x => x.Name == "three").Value, Is.EqualTo("four"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ModulesArePutIntoTopology() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo", "Bar");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("Foo").WithFeatures("Foo"),
|
||||
Build.ExtensionDescriptor("Bar").WithFeatures("Bar"),
|
||||
};
|
||||
|
||||
_featureTypes["Foo"] = new[] { typeof(AlphaModule) };
|
||||
_featureTypes["Bar"] = new[] { typeof(BetaModule) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(descriptor);
|
||||
|
||||
var alpha = topology.Modules.Single(x => x.Type == typeof (AlphaModule));
|
||||
var beta = topology.Modules.Single(x => x.Type == typeof (BetaModule));
|
||||
|
||||
Assert.That(alpha.Feature.FeatureDescriptor.Name, Is.EqualTo("Foo"));
|
||||
Assert.That(beta.Feature.FeatureDescriptor.Name, Is.EqualTo("Bar"));
|
||||
}
|
||||
|
||||
public class AlphaModule : Module {
|
||||
}
|
||||
|
||||
public class BetaModule : IModule {
|
||||
public void Configure(IComponentRegistry componentRegistry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ControllersArePutIntoTopology() {
|
||||
var descriptor = Build.TopologyDescriptor().WithFeatures("Foo Plus", "Bar Minus");
|
||||
|
||||
_extensionDescriptors = new[] {
|
||||
Build.ExtensionDescriptor("Foo").WithFeatures("Foo", "Foo Plus"),
|
||||
Build.ExtensionDescriptor("Bar").WithFeatures("Bar", "Bar Minus"),
|
||||
};
|
||||
|
||||
_featureTypes["Foo"] = Enumerable.Empty<Type>();
|
||||
_featureTypes["Foo Plus"] = new[] { typeof(GammaController) };
|
||||
_featureTypes["Bar"] = Enumerable.Empty<Type>();
|
||||
_featureTypes["Bar Minus"] = new[] { typeof(DeltaController), typeof(EpsilonController) };
|
||||
|
||||
var compositionStrategy = _container.Resolve<ICompositionStrategy>();
|
||||
var topology = compositionStrategy.Compose(descriptor);
|
||||
|
||||
var gamma = topology.Controllers.Single(x => x.Type == typeof (GammaController));
|
||||
var delta = topology.Controllers.Single(x => x.Type == typeof (DeltaController));
|
||||
var epsilon = topology.Controllers.Single(x => x.Type == typeof (EpsilonController));
|
||||
|
||||
Assert.That(gamma.Feature.FeatureDescriptor.Name, Is.EqualTo("Foo Plus"));
|
||||
Assert.That(gamma.AreaName, Is.EqualTo("Foo"));
|
||||
Assert.That(gamma.ControllerName, Is.EqualTo("Gamma"));
|
||||
|
||||
Assert.That(delta.Feature.FeatureDescriptor.Name, Is.EqualTo("Bar Minus"));
|
||||
Assert.That(delta.AreaName, Is.EqualTo("Bar"));
|
||||
Assert.That(delta.ControllerName, Is.EqualTo("Delta"));
|
||||
|
||||
Assert.That(epsilon.Feature.FeatureDescriptor.Name, Is.EqualTo("Bar Minus"));
|
||||
Assert.That(epsilon.AreaName, Is.EqualTo("Bar"));
|
||||
Assert.That(epsilon.ControllerName, Is.EqualTo("Epsilon"));
|
||||
}
|
||||
|
||||
|
||||
public class GammaController : Controller {
|
||||
}
|
||||
|
||||
public class DeltaController : ControllerBase {
|
||||
protected override void ExecuteCore() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class EpsilonController : IController {
|
||||
public void Execute(RequestContext requestContext) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +211,7 @@ namespace Orchard.Tests.Environment {
|
||||
public static ShellTopologyDescriptor TopologyDescriptor() {
|
||||
var descriptor = new ShellTopologyDescriptor {
|
||||
EnabledFeatures = Enumerable.Empty<TopologyFeature>(),
|
||||
Parameters = Enumerable.Empty<TopologyParameter>(),
|
||||
};
|
||||
return descriptor;
|
||||
}
|
||||
@@ -114,6 +223,13 @@ namespace Orchard.Tests.Environment {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public static ShellTopologyDescriptor WithParameter<TComponent>(this ShellTopologyDescriptor descriptor, string name, string value) {
|
||||
descriptor.Parameters = descriptor.Parameters.Concat(
|
||||
new[] { new TopologyParameter { Component = typeof(TComponent).FullName, Name = name, Value = value } });
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public static ExtensionDescriptor ExtensionDescriptor(string name) {
|
||||
var descriptor = new ExtensionDescriptor {
|
||||
Name = name,
|
||||
|
@@ -11,17 +11,16 @@ using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.AutofacUtil;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ModelBinders;
|
||||
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]
|
||||
@@ -84,7 +83,11 @@ namespace Orchard.Tests.Environment {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions() {
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
|
||||
return Enumerable.Empty<ExtensionEntry>();
|
||||
}
|
||||
|
||||
@@ -115,18 +118,6 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
public class StubCompositionStrategy : ICompositionStrategy_Obsolete, ICompositionStrategy {
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetDependencyTypes() {
|
||||
return new[] {
|
||||
typeof (TestDependency),
|
||||
typeof (TestSingletonDependency),
|
||||
typeof(TestTransientDependency)
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {
|
||||
return Enumerable.Empty<RecordDescriptor>();
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Mvc.ModelBinders;
|
||||
using Orchard.Mvc.Routes;
|
||||
using Orchard.Extensions;
|
||||
|
||||
namespace Orchard.Tests.Environment {
|
||||
[TestFixture]
|
||||
|
@@ -1,13 +1,13 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Yaml.Grammar;
|
||||
|
||||
namespace Orchard.Tests.Extensions {
|
||||
namespace Orchard.Tests.Environment.Extensions {
|
||||
[TestFixture]
|
||||
public class ExtensionFoldersTests {
|
||||
private const string DataPrefix = "Orchard.Tests.Extensions.FoldersData.";
|
||||
private const string DataPrefix = "Orchard.Tests.Environment.Extensions.FoldersData.";
|
||||
private string _tempFolderName;
|
||||
|
||||
[SetUp]
|
||||
@@ -68,4 +68,4 @@ namespace Orchard.Tests.Extensions {
|
||||
Assert.That(entities.Keys, Has.Some.EqualTo("author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Loaders;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Loaders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Tests.Extensions.ExtensionTypes;
|
||||
using Yaml.Grammar;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Extensions {
|
||||
namespace Orchard.Tests.Environment.Extensions {
|
||||
[TestFixture]
|
||||
public class ExtensionManagerTests {
|
||||
private IContainer _container;
|
||||
@@ -44,10 +44,10 @@ namespace Orchard.Tests.Extensions {
|
||||
var stream = parser.ParseYamlStream(new TextInput(Manifests[name]), out success);
|
||||
if (success) {
|
||||
return new ParseResult {
|
||||
Location = "~/InMemory",
|
||||
Name = name,
|
||||
YamlDocument = stream.Documents.Single()
|
||||
};
|
||||
Location = "~/InMemory",
|
||||
Name = name,
|
||||
YamlDocument = stream.Documents.Single()
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -194,17 +194,21 @@ features:
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionManagerShouldReturnTopology() {
|
||||
var topology = _manager.GetExtensionsTopology();
|
||||
public void ExtensionManagerShouldLoadFeatures() {
|
||||
var descriptors = _manager.AvailableExtensions().SelectMany(x => x.Features);
|
||||
var features = _manager.LoadFeatures(descriptors);
|
||||
var types = features.SelectMany(x => x.ExportedTypes);
|
||||
|
||||
Assert.That(topology.Types.Count(), Is.Not.EqualTo(0));
|
||||
Assert.That(types.Count(), Is.Not.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionManagerTopologyShouldContainNonAbstractClasses() {
|
||||
var topology = _manager.GetExtensionsTopology();
|
||||
public void ExtensionManagerFeaturesContainNonAbstractClasses() {
|
||||
var descriptors = _manager.AvailableExtensions().SelectMany(x => x.Features);
|
||||
var features = _manager.LoadFeatures(descriptors);
|
||||
var types = features.SelectMany(x => x.ExportedTypes);
|
||||
|
||||
foreach (var type in topology.Types) {
|
||||
foreach (var type in types) {
|
||||
Assert.That(type.IsClass);
|
||||
Assert.That(!type.IsAbstract);
|
||||
}
|
||||
@@ -212,24 +216,25 @@ features:
|
||||
|
||||
[Test]
|
||||
public void ExtensionManagerShouldThrowIfFeatureDoesNotExist() {
|
||||
Assert.Throws<ArgumentException>(() => _manager.LoadFeature("NoSuchFeature"));
|
||||
var featureDescriptor = new FeatureDescriptor { Name = "NoSuchFeature" };
|
||||
Assert.Throws<ArgumentException>(() => _manager.LoadFeature(featureDescriptor));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionManagerTestFeatureAttribute() {
|
||||
var extensionManager = new Moq.Mock<IExtensionManager>();
|
||||
extensionManager.Setup(x => x.ActiveExtensions()).Returns(new[] {
|
||||
new ExtensionEntry {
|
||||
Descriptor = new ExtensionDescriptor {
|
||||
Name = "Module",
|
||||
Features = new[] {
|
||||
new FeatureDescriptor { Name = "Module", ExtensionName = "Module" },
|
||||
new FeatureDescriptor { Name = "TestFeature", ExtensionName = "Module" }
|
||||
}},
|
||||
ExportedTypes = new[] { typeof(Alpha), typeof(Beta), typeof(Phi) }
|
||||
}});
|
||||
extensionManager.Setup(x => x.ActiveExtensions_Obsolete()).Returns(new[] {
|
||||
new ExtensionEntry {
|
||||
Descriptor = new ExtensionDescriptor {
|
||||
Name = "Module",
|
||||
Features = new[] {
|
||||
new FeatureDescriptor { Name = "Module", ExtensionName = "Module" },
|
||||
new FeatureDescriptor { Name = "TestFeature", ExtensionName = "Module" }
|
||||
}},
|
||||
ExportedTypes = new[] { typeof(Alpha), typeof(Beta), typeof(Phi) }
|
||||
}});
|
||||
|
||||
foreach (var type in extensionManager.Object.ActiveExtensions().SelectMany(x => x.ExportedTypes)) {
|
||||
foreach (var type in extensionManager.Object.ActiveExtensions_Obsolete().SelectMany(x => x.ExportedTypes)) {
|
||||
foreach (OrchardFeatureAttribute featureAttribute in type.GetCustomAttributes(typeof(OrchardFeatureAttribute), false)) {
|
||||
Assert.That(featureAttribute.FeatureName, Is.EqualTo("TestFeature"));
|
||||
}
|
||||
@@ -252,9 +257,12 @@ features:
|
||||
Description: Contains the Phi type.
|
||||
");
|
||||
|
||||
ExtensionManager extensionManager = new ExtensionManager(new []{extensionFolder}, new [] {extensionLoader});
|
||||
ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
|
||||
var testFeature = extensionManager.AvailableExtensions()
|
||||
.SelectMany(x => x.Features)
|
||||
.Single(x => x.Name == "TestFeature");
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature("TestFeature").Types) {
|
||||
foreach (var type in extensionManager.LoadFeature(testFeature).ExportedTypes) {
|
||||
Assert.That(type == typeof(Phi));
|
||||
}
|
||||
}
|
||||
@@ -276,11 +284,14 @@ features:
|
||||
");
|
||||
|
||||
ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
|
||||
var testModule = extensionManager.AvailableExtensions()
|
||||
.SelectMany(x => x.Features)
|
||||
.Single(x => x.Name == "TestModule");
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature("TestModule").Types) {
|
||||
foreach (var type in extensionManager.LoadFeature(testModule).ExportedTypes) {
|
||||
Assert.That(type != typeof(Phi));
|
||||
Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
|
||||
namespace Orchard.Tests.Extensions.ExtensionTypes {
|
||||
public class Alpha {
|
@@ -12,10 +12,9 @@ using Castle.Core.Interceptor;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
[TestFixture]
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Extensions;
|
||||
using Autofac.Core;
|
||||
|
||||
namespace Orchard.Tests.Mvc {
|
||||
|
@@ -4,10 +4,9 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Mvc.Routes;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Mvc.Routes {
|
||||
[TestFixture]
|
||||
@@ -45,7 +44,11 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions() {
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
|
||||
yield return new ExtensionEntry {
|
||||
Descriptor = new ExtensionDescriptor {
|
||||
Name = "Long.Name.Foo",
|
||||
|
@@ -171,9 +171,9 @@
|
||||
<Compile Include="Environment\Topology\DefaultTopologyDescriptorCacheTests.cs" />
|
||||
<Compile Include="EventsTests.cs" />
|
||||
<Compile Include="Events\EventTests.cs" />
|
||||
<Compile Include="Extensions\ExtensionFoldersTests.cs" />
|
||||
<Compile Include="Extensions\ExtensionManagerTests.cs" />
|
||||
<Compile Include="Extensions\ExtensionTypes\StubTypes.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionFoldersTests.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionManagerTests.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionTypes\StubTypes.cs" />
|
||||
<Compile Include="Localization\NullLocalizerTests.cs" />
|
||||
<Compile Include="Logging\LoggingModuleTests.cs" />
|
||||
<Compile Include="Mvc\ModelBinders\KeyedListModelBinderTests.cs" />
|
||||
@@ -215,9 +215,9 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Extensions\FoldersData\Sample1\Module.txt" />
|
||||
<EmbeddedResource Include="Extensions\FoldersData\Sample2\Two.txt" />
|
||||
<EmbeddedResource Include="Extensions\FoldersData\Sample3\Module.txt" />
|
||||
<EmbeddedResource Include="Environment\Extensions\FoldersData\Sample1\Module.txt" />
|
||||
<EmbeddedResource Include="Environment\Extensions\FoldersData\Sample2\Two.txt" />
|
||||
<EmbeddedResource Include="Environment\Extensions\FoldersData\Sample3\Module.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ThemesIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Themes"%>
|
||||
<%@ Import Namespace="Orchard.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("Manage Themes").ToString()) %></h1>
|
||||
<% if (Model.CurrentTheme == null) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Tasks;
|
||||
|
||||
namespace Orchard.Blogs.Routing {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Pages.Services;
|
||||
using Orchard.Tasks;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Security.Permissions;
|
||||
|
@@ -8,7 +8,7 @@ using Orchard.Core.Settings.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Setup.ViewModels;
|
||||
|
@@ -6,19 +6,17 @@ using System.Web.Mvc;
|
||||
using Autofac.Core;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Records;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Extensions.Records;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
//TEMP: This will be replaced by packaging system
|
||||
|
||||
public interface ICompositionStrategy_Obsolete {
|
||||
IEnumerable<Type> GetModuleTypes();
|
||||
IEnumerable<Type> GetDependencyTypes();
|
||||
IEnumerable<RecordDescriptor> GetRecordDescriptors();
|
||||
}
|
||||
|
||||
@@ -44,7 +42,7 @@ namespace Orchard.Environment {
|
||||
|
||||
return new ShellTopology {
|
||||
Modules = BuildTopology<ModuleTopology>(features, IsModule, BuildModule),
|
||||
Dependencies = BuildTopology<DependencyTopology>(features, IsDependency, BuildDependency),
|
||||
Dependencies = BuildTopology<DependencyTopology>(features, IsDependency, (t, f) => BuildDependency(t, f, topologyDescriptor)),
|
||||
Controllers = BuildTopology<ControllerTopology>(features, IsController, BuildController),
|
||||
Records = BuildTopology<RecordTopology>(features, IsRecord, BuildRecord),
|
||||
};
|
||||
@@ -78,8 +76,12 @@ namespace Orchard.Environment {
|
||||
return typeof(IDependency).IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
private static DependencyTopology BuildDependency(Type type, Feature feature) {
|
||||
return new DependencyTopology {Type = type, Feature = feature};
|
||||
private static DependencyTopology BuildDependency(Type type, Feature feature, ShellTopologyDescriptor topologyDescriptor) {
|
||||
return new DependencyTopology {
|
||||
Type = type,
|
||||
Feature = feature,
|
||||
Parameters = topologyDescriptor.Parameters.Where(x => x.Component == type.FullName).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsController(Type type) {
|
||||
@@ -87,7 +89,18 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
private static ControllerTopology BuildController(Type type, Feature feature) {
|
||||
return new ControllerTopology { Type = type, Feature = feature };
|
||||
var areaName = feature.FeatureDescriptor.ExtensionName;
|
||||
|
||||
var controllerName = type.Name;
|
||||
if (controllerName.EndsWith("Controller"))
|
||||
controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
|
||||
|
||||
return new ControllerTopology {
|
||||
Type = type,
|
||||
Feature = feature,
|
||||
AreaName = areaName,
|
||||
ControllerName = controllerName,
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsRecord(Type type) {
|
||||
@@ -96,7 +109,7 @@ namespace Orchard.Environment {
|
||||
(type.GetProperty("Id").GetAccessors() ?? Enumerable.Empty<MethodInfo>()).All(x => x.IsVirtual) &&
|
||||
!type.IsSealed &&
|
||||
!type.IsAbstract &&
|
||||
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type));;
|
||||
(!typeof(IContent).IsAssignableFrom(type) || typeof(ContentPartRecord).IsAssignableFrom(type)); ;
|
||||
}
|
||||
|
||||
private static RecordTopology BuildRecord(Type type, Feature feature) {
|
||||
@@ -104,14 +117,6 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
return _extensionManager.GetExtensionsTopology().Types.Where(t => typeof(IModule).IsAssignableFrom(t));
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetDependencyTypes() {
|
||||
return _extensionManager.GetExtensionsTopology().Types.Where(t => typeof(IDependency).IsAssignableFrom(t));
|
||||
}
|
||||
|
||||
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {
|
||||
var descriptors = new List<RecordDescriptor>{
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ContentTypeRecord)},
|
||||
@@ -120,7 +125,7 @@ namespace Orchard.Environment {
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ExtensionRecord)},
|
||||
};
|
||||
|
||||
foreach (var extension in _extensionManager.ActiveExtensions()) {
|
||||
foreach (var extension in _extensionManager.ActiveExtensions_Obsolete()) {
|
||||
var prefix = extension.Descriptor.Name
|
||||
.Replace("Orchard.", "")
|
||||
.Replace(".", "_");
|
||||
|
@@ -5,10 +5,10 @@ using Autofac;
|
||||
using Autofac.Integration.Web;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc.ModelBinders;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public class ExtensionEntry {
|
||||
public ExtensionDescriptor Descriptor { get; set; }
|
||||
public Assembly Assembly { get; set; }
|
||||
public IEnumerable<Type> ExportedTypes { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,16 +3,16 @@ 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.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Helpers;
|
||||
using Orchard.Environment.Extensions.Loaders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Yaml.Grammar;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public class ExtensionManager : IExtensionManager {
|
||||
private readonly IEnumerable<IExtensionFolders> _folders;
|
||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||
@@ -46,18 +46,20 @@ namespace Orchard.Extensions {
|
||||
return availableExtensions;
|
||||
}
|
||||
|
||||
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> features) {
|
||||
throw new NotImplementedException();
|
||||
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
|
||||
return featureDescriptors
|
||||
.Select(featureDescriptor => LoadFeature(featureDescriptor))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
// This method loads types from extensions into the ExtensionEntry array.
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions() {
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
|
||||
if (_activeExtensions == null) {
|
||||
_activeExtensions = BuildActiveExtensions().ToList();
|
||||
}
|
||||
return _activeExtensions;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static ExtensionDescriptor GetDescriptorForExtension(string name, IExtensionFolders folder) {
|
||||
string extensionType = folder is ThemeFolders ? "Theme" : "Module";
|
||||
@@ -68,19 +70,19 @@ namespace Orchard.Extensions {
|
||||
.ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
|
||||
|
||||
return new ExtensionDescriptor {
|
||||
Location = parseResult.Location,
|
||||
Name = name,
|
||||
ExtensionType = extensionType,
|
||||
DisplayName = GetValue(fields, "name"),
|
||||
Description = GetValue(fields, "description"),
|
||||
Version = GetValue(fields, "version"),
|
||||
OrchardVersion = GetValue(fields, "orchardversion"),
|
||||
Author = GetValue(fields, "author"),
|
||||
WebSite = GetValue(fields, "website"),
|
||||
Tags = GetValue(fields, "tags"),
|
||||
AntiForgery = GetValue(fields, "antiforgery"),
|
||||
Features = GetFeaturesForExtension(GetMapping(fields, "features"), name),
|
||||
};
|
||||
Location = parseResult.Location,
|
||||
Name = name,
|
||||
ExtensionType = extensionType,
|
||||
DisplayName = GetValue(fields, "name"),
|
||||
Description = GetValue(fields, "description"),
|
||||
Version = GetValue(fields, "version"),
|
||||
OrchardVersion = GetValue(fields, "orchardversion"),
|
||||
Author = GetValue(fields, "author"),
|
||||
WebSite = GetValue(fields, "website"),
|
||||
Tags = GetValue(fields, "tags"),
|
||||
AntiForgery = GetValue(fields, "antiforgery"),
|
||||
Features = GetFeaturesForExtension(GetMapping(fields, "features"), name),
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(Mapping features, string name) {
|
||||
@@ -88,10 +90,10 @@ namespace Orchard.Extensions {
|
||||
if (features == null) return featureDescriptors;
|
||||
foreach (var entity in features.Entities) {
|
||||
FeatureDescriptor featureDescriptor = new FeatureDescriptor {
|
||||
ExtensionName = name,
|
||||
Name = entity.Key.ToString(),
|
||||
};
|
||||
Mapping featureMapping = (Mapping) entity.Value;
|
||||
ExtensionName = name,
|
||||
Name = entity.Key.ToString(),
|
||||
};
|
||||
Mapping featureMapping = (Mapping)entity.Value;
|
||||
foreach (var featureEntity in featureMapping.Entities) {
|
||||
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Description = featureEntity.Value.ToString();
|
||||
@@ -104,21 +106,22 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
}
|
||||
featureDescriptors.Add(featureDescriptor);
|
||||
|
||||
|
||||
}
|
||||
return featureDescriptors;
|
||||
}
|
||||
|
||||
public ShellTopology_Obsolete GetExtensionsTopology() {
|
||||
var types = ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
||||
var types = ActiveExtensions_Obsolete().SelectMany(x => x.ExportedTypes);
|
||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
||||
return new ShellTopology_Obsolete { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
||||
}
|
||||
|
||||
public Feature LoadFeature(string featureName) {
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
var featureName = featureDescriptor.Name;
|
||||
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();
|
||||
var extension = ActiveExtensions_Obsolete().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault();
|
||||
if (extension == null) throw new InvalidOperationException(T("Extension ") + extensionName + T(" is not active"));
|
||||
|
||||
var extensionTypes = extension.ExportedTypes.Where(t => t.IsClass && !t.IsAbstract);
|
||||
@@ -131,11 +134,10 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
}
|
||||
|
||||
return new Feature {
|
||||
ExtensionName = extensionName,
|
||||
Name = featureName,
|
||||
Types = featureTypes
|
||||
};
|
||||
return new Feature {
|
||||
FeatureDescriptor = featureDescriptor,
|
||||
ExportedTypes = featureTypes
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetSourceFeatureNameForType(Type type, string extensionName) {
|
||||
@@ -236,7 +238,7 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
|
||||
private ExtensionEntry BuildEntry(ExtensionDescriptor descriptor) {
|
||||
if (!IsExtensionEnabled(descriptor.Name)) return null;
|
||||
if (!IsExtensionEnabled(descriptor.Name)) return null;
|
||||
foreach (var loader in _loaders) {
|
||||
var entry = loader.Load(descriptor);
|
||||
if (entry != null)
|
||||
@@ -269,4 +271,4 @@ namespace Orchard.Extensions {
|
||||
return fields.TryGetValue(key, out value) ? value.ToString() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Folders {
|
||||
public class AreaFolders : ExtensionFolders {
|
||||
public AreaFolders(IEnumerable<string> paths) :
|
||||
base(paths, "Module.txt", true/*isManifestOptional*/) {
|
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Orchard.Extensions.Helpers;
|
||||
using Orchard.Environment.Extensions.Helpers;
|
||||
using Yaml.Grammar;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Folders {
|
||||
public class ExtensionFolders : IExtensionFolders {
|
||||
private readonly IEnumerable<string> _paths;
|
||||
private readonly string _manifestName;
|
||||
@@ -43,10 +43,10 @@ namespace Orchard.Extensions {
|
||||
if (File.Exists(extensionManifestPath)) {
|
||||
var yamlStream = YamlParser.Load(extensionManifestPath);
|
||||
return new ParseResult {
|
||||
Location = path,
|
||||
Name = name,
|
||||
YamlDocument = yamlStream.Documents.Single()
|
||||
};
|
||||
Location = path,
|
||||
Name = name,
|
||||
YamlDocument = yamlStream.Documents.Single()
|
||||
};
|
||||
}
|
||||
|
||||
if (_manifestIsOptional) {
|
||||
@@ -55,10 +55,10 @@ namespace Orchard.Extensions {
|
||||
bool success;
|
||||
var yamlStream = parser.ParseYamlStream(yamlInput, out success);
|
||||
return new ParseResult {
|
||||
Location = path,
|
||||
Name = name,
|
||||
YamlDocument = yamlStream.Documents.Single()
|
||||
};
|
||||
Location = path,
|
||||
Name = name,
|
||||
YamlDocument = yamlStream.Documents.Single()
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Yaml.Grammar;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Folders {
|
||||
public interface IExtensionFolders {
|
||||
IEnumerable<string> ListNames();
|
||||
ParseResult ParseManifest(string name);
|
@@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Folders {
|
||||
public class ModuleFolders : ExtensionFolders {
|
||||
public ModuleFolders(IEnumerable<string> paths) :
|
||||
base(paths, "Module.txt", false/*isManifestOptional*/) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Folders {
|
||||
public class ThemeFolders : ExtensionFolders {
|
||||
public ThemeFolders(IEnumerable<string> paths) :
|
||||
base(paths, "Theme.txt", false/*manifestIsOptional*/) {
|
@@ -2,7 +2,7 @@
|
||||
using Orchard.Logging;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public interface IHackInstallationGenerator : IDependency {
|
||||
void GenerateInstallEvents();
|
||||
void GenerateActivateEvents();
|
||||
@@ -26,11 +26,11 @@ namespace Orchard.Extensions {
|
||||
//TEMP: this is really part of the extension manager's job. an extension
|
||||
// install event is being simulated here on each web app startup
|
||||
var enabled = new List<ExtensionEntry>();
|
||||
foreach (var extension in _extensionManager.ActiveExtensions()) {
|
||||
foreach (var extension in _extensionManager.ActiveExtensions_Obsolete()) {
|
||||
var context = new ExtensionEventContext {
|
||||
Extension = extension,
|
||||
EnabledExtensions = enabled.ToReadOnlyCollection(),
|
||||
};
|
||||
Extension = extension,
|
||||
EnabledExtensions = enabled.ToReadOnlyCollection(),
|
||||
};
|
||||
_extensionEvents.Invoke(x => x.Enabling(context), Logger);
|
||||
enabled.Add(extension);
|
||||
context.EnabledExtensions = enabled.ToReadOnlyCollection();
|
||||
@@ -40,15 +40,15 @@ namespace Orchard.Extensions {
|
||||
|
||||
public void GenerateActivateEvents() {
|
||||
//TEMP: This is really part of the extension manager's job.
|
||||
var extensions = _extensionManager.ActiveExtensions().ToReadOnlyCollection();
|
||||
var extensions = _extensionManager.ActiveExtensions_Obsolete().ToReadOnlyCollection();
|
||||
foreach (var extension in extensions) {
|
||||
var context = new ExtensionEventContext {
|
||||
Extension = extension,
|
||||
EnabledExtensions = extensions,
|
||||
};
|
||||
Extension = extension,
|
||||
EnabledExtensions = extensions,
|
||||
};
|
||||
_extensionEvents.Invoke(x => x.Activating(context), Logger);
|
||||
_extensionEvents.Invoke(x => x.Activated(context), Logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System.Web.Hosting;
|
||||
|
||||
namespace Orchard.Extensions.Helpers {
|
||||
namespace Orchard.Environment.Extensions.Helpers {
|
||||
public static class PathHelpers {
|
||||
public static string GetPhysicalPath(string path) {
|
||||
if (path.StartsWith("~") && HostingEnvironment.IsHosted) {
|
||||
@@ -9,4 +9,4 @@ namespace Orchard.Extensions.Helpers {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public interface IExtensionManager {
|
||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||
IEnumerable<Type> LoadFeature(string featureName);
|
||||
IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> features);
|
||||
IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors);
|
||||
Feature LoadFeature(FeatureDescriptor featureDescriptor);
|
||||
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions();
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete();
|
||||
ShellTopology_Obsolete GetExtensionsTopology();
|
||||
Feature LoadFeature(string featureName);
|
||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||
void UninstallExtension(string extensionType, string extensionName);
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public interface IExtensionManagerEvents : IEvents {
|
||||
void Enabling(ExtensionEventContext context);
|
||||
void Enabled(ExtensionEventContext context);
|
||||
@@ -42,4 +42,4 @@ namespace Orchard.Extensions {
|
||||
public ExtensionEntry Extension { get; set; }
|
||||
public IEnumerable<ExtensionEntry> EnabledExtensions { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public class AreaExtensionLoader : IExtensionLoader {
|
||||
public int Order { get { return 5; } }
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Orchard.Extensions.Loaders {
|
||||
|
||||
var assembly = Assembly.Load("Orchard.Web");
|
||||
return new ExtensionEntry {
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes().Where(x => IsTypeFromModule(x, descriptor))
|
||||
};
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes().Where(x => IsTypeFromModule(x, descriptor))
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -24,4 +24,4 @@ namespace Orchard.Extensions.Loaders {
|
||||
return (type.Namespace + ".").StartsWith("Orchard.Web.Areas." + descriptor.Name + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public class CoreExtensionLoader : IExtensionLoader {
|
||||
public int Order { get { return 1; } }
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Orchard.Extensions.Loaders {
|
||||
|
||||
var assembly = Assembly.Load("Orchard.Core");
|
||||
return new ExtensionEntry {
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes().Where(x => IsTypeFromModule(x, descriptor))
|
||||
};
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes().Where(x => IsTypeFromModule(x, descriptor))
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -24,4 +24,4 @@ namespace Orchard.Extensions.Loaders {
|
||||
return (type.Namespace + ".").StartsWith("Orchard.Core." + descriptor.Name + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,9 +5,9 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public class DynamicExtensionLoader : IExtensionLoader {
|
||||
public int Order { get { return 10; } }
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace Orchard.Extensions.Loaders {
|
||||
var results = codeProvider.CompileAssemblyFromFile(options, fileNames.ToArray());
|
||||
|
||||
return new ExtensionEntry {
|
||||
Descriptor = descriptor,
|
||||
Assembly = results.CompiledAssembly,
|
||||
ExportedTypes = results.CompiledAssembly.GetExportedTypes(),
|
||||
};
|
||||
Descriptor = descriptor,
|
||||
Assembly = results.CompiledAssembly,
|
||||
ExportedTypes = results.CompiledAssembly.GetExportedTypes(),
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetAssemblyReferenceNames() {
|
||||
@@ -56,4 +56,4 @@ namespace Orchard.Extensions.Loaders {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public interface IExtensionLoader {
|
||||
int Order { get; }
|
||||
ExtensionEntry Load(ExtensionDescriptor descriptor);
|
@@ -1,6 +1,6 @@
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public class PrecompiledExtensionLoader : IExtensionLoader {
|
||||
public int Order { get { return 3; } }
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace Orchard.Extensions.Loaders {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,9 +2,9 @@
|
||||
using System.Reflection;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Extensions.Loaders {
|
||||
namespace Orchard.Environment.Extensions.Loaders {
|
||||
public class ReferencedExtensionLoader : IExtensionLoader {
|
||||
public int Order { get { return 2; } }
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace Orchard.Extensions.Loaders {
|
||||
return null;
|
||||
|
||||
return new ExtensionEntry {
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes()
|
||||
};
|
||||
Descriptor = descriptor,
|
||||
Assembly = assembly,
|
||||
ExportedTypes = assembly.GetExportedTypes()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
src/Orchard/Environment/Extensions/Models/Extension.cs
Normal file
4
src/Orchard/Environment/Extensions/Models/Extension.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
public class Extension {
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions.Models {
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
public class ExtensionDescriptor {
|
||||
/// <summary>
|
||||
/// Virtual path base, "~/Themes", "~/Modules", or "~/Core"
|
9
src/Orchard/Environment/Extensions/Models/Feature.cs
Normal file
9
src/Orchard/Environment/Extensions/Models/Feature.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
public class Feature {
|
||||
public FeatureDescriptor FeatureDescriptor { get; set; }
|
||||
public IEnumerable<Type> ExportedTypes { get; set; }
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
public class FeatureDescriptor {
|
||||
public string ExtensionName { get; set; }
|
||||
public string Name { get; set; }
|
||||
@@ -6,4 +6,4 @@
|
||||
public string Category { get; set; }
|
||||
public string[] Dependencies { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class OrchardFeatureAttribute : Attribute {
|
||||
public OrchardFeatureAttribute(string text) {
|
||||
@@ -9,4 +9,4 @@ namespace Orchard.Extensions {
|
||||
|
||||
public string FeatureName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.Extensions.Records {
|
||||
namespace Orchard.Environment.Extensions.Records {
|
||||
public class ExtensionRecord {
|
||||
public ExtensionRecord() {
|
||||
// ReSharper disable DoNotCallOverridableMethodsInConstructor
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
namespace Orchard.Environment.Extensions {
|
||||
public class ShellTopology_Obsolete {
|
||||
public IEnumerable<Type> Types { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,11 +7,12 @@ using Autofac.Configuration;
|
||||
using Autofac.Integration.Web;
|
||||
using Orchard.Environment.AutofacUtil;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Loaders;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Events;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Loaders;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public static class OrchardStarter {
|
||||
|
@@ -13,7 +13,7 @@ using Orchard.Data.Builders;
|
||||
using Orchard.Environment.AutofacUtil;
|
||||
using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Filters;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Environment.Topology.Models {
|
||||
public class ShellTopology {
|
||||
|
@@ -1,4 +0,0 @@
|
||||
namespace Orchard.Extensions.Models {
|
||||
public class Extension {
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
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; }
|
||||
public FeatureDescriptor FeatureDescriptor { get; set; }
|
||||
public Extension Extension { get; set; }
|
||||
public IEnumerable<Type> ExportedTypes { get; set; }
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ using System.Collections.Specialized;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.UI;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Validation;
|
||||
|
||||
|
@@ -7,8 +7,8 @@ using Autofac;
|
||||
using Autofac.Integration.Web;
|
||||
using Autofac.Integration.Web.Mvc;
|
||||
using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Extensions;
|
||||
using Autofac.Core;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
@@ -22,7 +22,7 @@ namespace Orchard.Mvc {
|
||||
}
|
||||
|
||||
protected override void Load(ContainerBuilder moduleBuilder) {
|
||||
var extensions = _extensionManager.ActiveExtensions();
|
||||
var extensions = _extensionManager.ActiveExtensions_Obsolete();
|
||||
var assemblies = extensions.Select(x => x.Assembly);
|
||||
var actionInvokerService = new UniqueService();
|
||||
moduleBuilder.RegisterType<FilterResolvingActionInvoker>().As(actionInvokerService).InstancePerDependency();
|
||||
|
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Autofac.Core;
|
||||
using Autofac.Integration.Web.Mvc;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
public class OrchardControllerIdentificationStrategy : IControllerIdentificationStrategy {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
|
||||
namespace Orchard.Mvc.Routes {
|
||||
public class StandardExtensionRouteProvider : IRouteProvider {
|
||||
@@ -12,7 +12,7 @@ namespace Orchard.Mvc.Routes {
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
foreach (var entry in _extensionManager.ActiveExtensions()) {
|
||||
foreach (var entry in _extensionManager.ActiveExtensions_Obsolete()) {
|
||||
var areaName = entry.Descriptor.Name;
|
||||
var displayName = entry.Descriptor.DisplayName ?? areaName;
|
||||
|
||||
|
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Themes;
|
||||
@@ -52,7 +52,7 @@ namespace Orchard.Mvc.ViewEngines {
|
||||
}
|
||||
|
||||
|
||||
var modules = _extensionManager.ActiveExtensions()
|
||||
var modules = _extensionManager.ActiveExtensions_Obsolete()
|
||||
.Where(x => x.Descriptor.ExtensionType == "Module");
|
||||
|
||||
var moduleLocations = modules.Select(x => Path.Combine(x.Descriptor.Location, x.Descriptor.Name));
|
||||
|
@@ -187,16 +187,15 @@
|
||||
<Compile Include="Events\DefaultOrchardEventBus.cs" />
|
||||
<Compile Include="Events\IEventBus.cs" />
|
||||
<Compile Include="Events\IEventBusHandler.cs" />
|
||||
<Compile Include="Extensions\AreaFolders.cs" />
|
||||
<Compile Include="Extensions\ExtensionFolders.cs" />
|
||||
<Compile Include="Extensions\Models\Extension.cs" />
|
||||
<Compile Include="Extensions\Models\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" />
|
||||
<Compile Include="Environment\Extensions\Folders\AreaFolders.cs" />
|
||||
<Compile Include="Environment\Extensions\Folders\ExtensionFolders.cs" />
|
||||
<Compile Include="Environment\Extensions\Models\Extension.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\AreaExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Models\Feature.cs" />
|
||||
<Compile Include="Environment\Extensions\Models\FeatureDescriptor.cs" />
|
||||
<Compile Include="Environment\Extensions\OrchardFeatureAttribute.cs" />
|
||||
<Compile Include="Environment\Extensions\Records\ExtensionRecord.cs" />
|
||||
<Compile Include="Environment\Extensions\ShellTopology.cs" />
|
||||
<Compile Include="Mvc\AntiForgery\ValidateAntiForgeryTokenOrchardAttribute.cs" />
|
||||
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
|
||||
<Compile Include="Mvc\Html\FileRegistrationContextExtensions.cs" />
|
||||
@@ -264,8 +263,8 @@
|
||||
<Compile Include="ContentManagement\Records\ContentPartVersionRecord.cs" />
|
||||
<Compile Include="ContentManagement\Records\ContentTypeRecord.cs" />
|
||||
<Compile Include="ContentManagement\Records\Utility.cs" />
|
||||
<Compile Include="Extensions\HackInstallationGenerator.cs" />
|
||||
<Compile Include="Extensions\IExtensionManagerEvents.cs" />
|
||||
<Compile Include="Environment\Extensions\HackInstallationGenerator.cs" />
|
||||
<Compile Include="Environment\Extensions\IExtensionManagerEvents.cs" />
|
||||
<Compile Include="Localization\Text.cs" />
|
||||
<Compile Include="Mvc\ViewModels\ContentItemViewModel.cs" />
|
||||
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs" />
|
||||
@@ -274,8 +273,8 @@
|
||||
<Compile Include="Data\TransactionManager.cs" />
|
||||
<Compile Include="Environment\IOrchardShellEvents.cs" />
|
||||
<Compile Include="Environment\OrchardServices.cs" />
|
||||
<Compile Include="Extensions\Models\ExtensionDescriptor.cs" />
|
||||
<Compile Include="Extensions\ExtensionEntry.cs" />
|
||||
<Compile Include="Environment\Extensions\Models\ExtensionDescriptor.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionEntry.cs" />
|
||||
<Compile Include="IOrchardServices.cs" />
|
||||
<Compile Include="Themes\ThemeFilter.cs" />
|
||||
<Compile Include="Themes\ThemedAttribute.cs" />
|
||||
@@ -290,17 +289,17 @@
|
||||
<Compile Include="Tasks\Scheduling\IScheduledTaskManager.cs" />
|
||||
<Compile Include="Tasks\Scheduling\ScheduledTaskContext.cs" />
|
||||
<Compile Include="Themes\ExtensionManagerExtensions.cs" />
|
||||
<Compile Include="Extensions\Helpers\PathHelpers.cs" />
|
||||
<Compile Include="Extensions\IExtensionManager.cs" />
|
||||
<Compile Include="Extensions\ModuleFolders.cs" />
|
||||
<Compile Include="Extensions\ExtensionManager.cs" />
|
||||
<Compile Include="Extensions\IExtensionFolders.cs" />
|
||||
<Compile Include="Extensions\Loaders\CoreExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Loaders\DynamicExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Loaders\IExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Loaders\PrecompiledExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Loaders\ReferencedExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\ThemeFolders.cs" />
|
||||
<Compile Include="Environment\Extensions\Helpers\PathHelpers.cs" />
|
||||
<Compile Include="Environment\Extensions\IExtensionManager.cs" />
|
||||
<Compile Include="Environment\Extensions\Folders\ModuleFolders.cs" />
|
||||
<Compile Include="Environment\Extensions\ExtensionManager.cs" />
|
||||
<Compile Include="Environment\Extensions\Folders\IExtensionFolders.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\CoreExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\DynamicExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\IExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\PrecompiledExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Loaders\ReferencedExtensionLoader.cs" />
|
||||
<Compile Include="Environment\Extensions\Folders\ThemeFolders.cs" />
|
||||
<Compile Include="IEvents.cs" />
|
||||
<Compile Include="Localization\IText.cs" />
|
||||
<Compile Include="Localization\LocalizationModule.cs" />
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Themes {
|
||||
public static class ExtensionManagerExtensions {
|
||||
|
Reference in New Issue
Block a user