mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
35
src/Orchard/Mvc/Extensions/RouteExtention.cs
Normal file
35
src/Orchard/Mvc/Extensions/RouteExtention.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Mvc{
|
||||
|
||||
public static class RouteExtention{
|
||||
public static string GetAreaName(this RouteBase route){
|
||||
var routeWithArea = route as IRouteWithArea;
|
||||
if (routeWithArea != null) {
|
||||
return routeWithArea.Area;
|
||||
}
|
||||
|
||||
var castRoute = route as Route;
|
||||
if (castRoute != null && castRoute.DataTokens != null) {
|
||||
return castRoute.DataTokens["area"] as string;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetAreaName(this RouteData routeData){
|
||||
object area;
|
||||
if (routeData.DataTokens.TryGetValue("area", out area))
|
||||
{
|
||||
return area as string;
|
||||
}
|
||||
|
||||
return GetAreaName(routeData.Route);
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,7 +30,7 @@ namespace Orchard.Mvc {
|
||||
var routeData = requestContext.RouteData;
|
||||
|
||||
// Determine the area name for the request, and fall back to stock orchard controllers
|
||||
var areaName = GetAreaName(routeData);
|
||||
var areaName = routeData.GetAreaName();
|
||||
|
||||
// Service name pattern matches the identification strategy
|
||||
var serviceKey = (areaName + "/" + controllerName).ToLowerInvariant();
|
||||
@@ -57,27 +57,5 @@ namespace Orchard.Mvc {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetAreaName(RouteBase route) {
|
||||
var routeWithArea = route as IRouteWithArea;
|
||||
if (routeWithArea != null) {
|
||||
return routeWithArea.Area;
|
||||
}
|
||||
|
||||
var castRoute = route as Route;
|
||||
if (castRoute != null && castRoute.DataTokens != null) {
|
||||
return castRoute.DataTokens["area"] as string;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetAreaName(RouteData routeData) {
|
||||
object area;
|
||||
if (routeData.DataTokens.TryGetValue("area", out area)) {
|
||||
return area as string;
|
||||
}
|
||||
|
||||
return GetAreaName(routeData.Route);
|
||||
}
|
||||
}
|
||||
}
|
@@ -25,15 +25,7 @@ namespace Orchard.Mvc.Routes {
|
||||
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
|
||||
_urlPrefix = new UrlPrefix(_shellSettings.RequestUrlPrefix);
|
||||
|
||||
var routeWithArea = route as IRouteWithArea;
|
||||
if (routeWithArea != null) {
|
||||
Area = routeWithArea.Area;
|
||||
}
|
||||
|
||||
var routeWithDataTokens = route as Route;
|
||||
if ((routeWithDataTokens != null) && (routeWithDataTokens.DataTokens != null)) {
|
||||
Area = (routeWithDataTokens.DataTokens["area"] as string);
|
||||
}
|
||||
Area = route.GetAreaName();
|
||||
}
|
||||
|
||||
public string ShellSettingsName { get { return _shellSettings.Name; } }
|
||||
|
@@ -183,6 +183,7 @@
|
||||
<Compile Include="Localization\Services\ILocalizedStringManager.cs" />
|
||||
<Compile Include="Logging\OrchardFileAppender.cs" />
|
||||
<Compile Include="Messaging\Services\DefaultMessageManager.cs" />
|
||||
<Compile Include="Mvc\Extensions\RouteExtention.cs" />
|
||||
<Compile Include="Mvc\HttpContextWorkContext.cs" />
|
||||
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
|
||||
<Compile Include="Mvc\IOrchardViewPage.cs" />
|
||||
|
Reference in New Issue
Block a user