From 93c9b3419ec8f9fd7f428dec675aa2b6ebfbadfc Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 15 Apr 2014 21:25:32 -0700 Subject: [PATCH] Made some changes to the MvcApplication class - Renamed it to MvcRouteHandler - Removed required IServiceProvider ctor param. - The HttpContext flows the application services through to MVC. This does require a call to app.UseContainer in order for things to work but that should be fine. This will be the pattern we use for all frameworks going forward and we'll need to have some good error handling around this area when things aren't wired up properly. --- samples/MvcSample.Web/Startup.cs | 2 +- .../Microsoft.AspNet.Mvc.Core.kproj | 2 +- .../{MvcApplication.cs => MvcRouteHandler.cs} | 11 ++--------- 3 files changed, 4 insertions(+), 11 deletions(-) rename src/Microsoft.AspNet.Mvc.Core/{MvcApplication.cs => MvcRouteHandler.cs} (93%) diff --git a/samples/MvcSample.Web/Startup.cs b/samples/MvcSample.Web/Startup.cs index fbf385796f..2a02529425 100644 --- a/samples/MvcSample.Web/Startup.cs +++ b/samples/MvcSample.Web/Startup.cs @@ -19,7 +19,7 @@ namespace MvcSample.Web var routes = new RouteCollection() { - DefaultHandler = new MvcApplication(serviceProvider), + DefaultHandler = new MvcRouteHandler(), }; // TODO: Add support for route constraints, so we can potentially constrain by existing routes diff --git a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj index fa0472d5e8..097cfb1f33 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj +++ b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj @@ -113,7 +113,7 @@ - + diff --git a/src/Microsoft.AspNet.Mvc.Core/MvcApplication.cs b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs similarity index 93% rename from src/Microsoft.AspNet.Mvc.Core/MvcApplication.cs rename to src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs index fdd78367ca..292faa9a9d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/MvcApplication.cs +++ b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs @@ -11,15 +11,8 @@ using Microsoft.AspNet.Routing; namespace Microsoft.AspNet.Mvc { - public class MvcApplication : IRouter + public class MvcRouteHandler : IRouter { - private readonly IServiceProvider _serviceProvider; - - public MvcApplication([NotNull] IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - public string GetVirtualPath([NotNull] VirtualPathContext context) { // The contract of this method is to check that the values coming in from the route are valid; @@ -81,7 +74,7 @@ namespace Microsoft.AspNet.Mvc return null; } - var applicationServices = httpContext.ApplicationServices ?? _serviceProvider; + var applicationServices = httpContext.ApplicationServices; var scopeFactory = applicationServices.GetService(); var scope = scopeFactory.CreateScope();