mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -30,6 +30,10 @@ namespace Orchard.Tests.Utility {
|
||||
public AutoMockSource(MockBehavior behavior) {
|
||||
_behavior = behavior;
|
||||
}
|
||||
|
||||
public bool IsAdapterForIndividualComponents {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
IEnumerable<IComponentRegistration> IRegistrationSource.RegistrationsFor(
|
||||
Service service,
|
||||
|
@@ -14,6 +14,10 @@ namespace Orchard.Events {
|
||||
_proxyBuilder = new DefaultProxyBuilder();
|
||||
}
|
||||
|
||||
public bool IsAdapterForIndividualComponents {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor) {
|
||||
var serviceWithType = service as IServiceWithType;
|
||||
if (serviceWithType == null)
|
||||
@@ -40,4 +44,4 @@ namespace Orchard.Events {
|
||||
yield return rb.CreateRegistration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Autofac.Core;
|
||||
using Autofac.Integration.Web.Mvc;
|
||||
using Orchard.Environment.Extensions;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
public class OrchardControllerIdentificationStrategy : IControllerIdentificationStrategy {
|
||||
private readonly IEnumerable<ExtensionEntry> _extensions;
|
||||
|
||||
public OrchardControllerIdentificationStrategy(IEnumerable<ExtensionEntry> extensions) {
|
||||
_extensions = extensions;
|
||||
}
|
||||
|
||||
public Service ServiceForControllerName(string controllerName) {
|
||||
// the OrchardControllerFactory class does not call on the strategy, because the controller name
|
||||
// alone is insufficient to identify the service
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Service ServiceForControllerType(Type controllerType) {
|
||||
var controllerNamespace = controllerType.Namespace;
|
||||
var extension = _extensions.FirstOrDefault(x => x.Assembly == controllerType.Assembly);
|
||||
var assemblySimpleName = controllerType.Assembly.GetName().Name;
|
||||
string areaName;
|
||||
if (assemblySimpleName == "Orchard.Core" &&
|
||||
controllerNamespace.StartsWith("Orchard.Core.")) {
|
||||
|
||||
areaName = controllerNamespace.Split('.').Skip(2).FirstOrDefault();
|
||||
}
|
||||
else if (assemblySimpleName == "Orchard.Web" &&
|
||||
controllerNamespace.StartsWith("Orchard.Web.Areas.")) {
|
||||
|
||||
areaName = controllerNamespace.Split('.').Skip(3).FirstOrDefault();
|
||||
}
|
||||
else if (extension != null) {
|
||||
areaName = extension.Descriptor.Name;
|
||||
}
|
||||
else {
|
||||
areaName = assemblySimpleName;
|
||||
}
|
||||
var controllerName = controllerType.Name.Replace("Controller", "");
|
||||
return new NamedService(("controller." + areaName + "." + controllerName).ToLowerInvariant(), typeof(IController));
|
||||
}
|
||||
}
|
||||
}
|
@@ -717,7 +717,6 @@
|
||||
<Compile Include="Mvc\ModelBinders\KeyedListModelBinder.cs" />
|
||||
<Compile Include="Mvc\ModelBinders\ModelBinderDescriptor.cs" />
|
||||
<Compile Include="Mvc\Results\NotFoundResult.cs" />
|
||||
<Compile Include="Mvc\OrchardControllerIdentificationStrategy.cs" />
|
||||
<Compile Include="Mvc\Routes\RouteExtensions.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\IViewEngineProvider.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\LayoutView.cs" />
|
||||
|
Reference in New Issue
Block a user