Medium Trust: Fixing route collection build code to avoid autofac delegate factories lambda method issue with medium trust.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-03 16:02:42 -07:00
parent 6f15acaf5f
commit ab4ba17b90

View File

@@ -2,21 +2,26 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web.Routing; using System.Web.Routing;
using Autofac;
using Orchard.Environment;
using Orchard.Environment.Configuration; using Orchard.Environment.Configuration;
namespace Orchard.Mvc.Routes { namespace Orchard.Mvc.Routes {
public class RoutePublisher : IRoutePublisher { public class RoutePublisher : IRoutePublisher {
private readonly RouteCollection _routeCollection; private readonly RouteCollection _routeCollection;
private readonly ShellSettings _shellSettings; private readonly ShellSettings _shellSettings;
private readonly Func<RouteBase, ShellRoute> _shellRouteFactory; private readonly ILifetimeScope _shellLifetimeScope;
private readonly IRunningShellTable _runningShellTable;
public RoutePublisher( public RoutePublisher(
RouteCollection routeCollection, RouteCollection routeCollection,
ShellSettings shellSettings, ShellSettings shellSettings,
Func<RouteBase, ShellRoute> shellRouteFactory) { ILifetimeScope shellLifetimeScope,
IRunningShellTable runningShellTable) {
_routeCollection = routeCollection; _routeCollection = routeCollection;
_shellSettings = shellSettings; _shellSettings = shellSettings;
_shellRouteFactory = shellRouteFactory; _shellLifetimeScope = shellLifetimeScope;
_runningShellTable = runningShellTable;
} }
public void Publish(IEnumerable<RouteDescriptor> routes) { public void Publish(IEnumerable<RouteDescriptor> routes) {
@@ -41,8 +46,8 @@ namespace Orchard.Mvc.Routes {
// new routes are added // new routes are added
foreach (var routeDescriptor in routesArray) { foreach (var routeDescriptor in routesArray) {
//_routeCollection.Add(route.Name, _shellRouteFactory(_shellSettings.Name, route.Route)); ShellRoute shellRoute = new ShellRoute(routeDescriptor.Route, _shellSettings, _shellLifetimeScope, _runningShellTable);
_routeCollection.Add(routeDescriptor.Name, _shellRouteFactory(routeDescriptor.Route)); _routeCollection.Add(routeDescriptor.Name, shellRoute);
} }
} }
} }