From a6b85f1f15b8d50d9097b57e0628ede3c412f7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sun, 28 Feb 2016 22:48:32 +0100 Subject: [PATCH] React to breaking changes in aspnet/Mvc https://github.com/aspnet/Mvc/commit/80b6996701ca240b8b4b1ba8f56c7ecae3e69b60 https://github.com/aspnet/Mvc/commit/385c21fbe2af2d61e697b9df826681e6d064d85c --- samples/Mvc.Client/Startup.cs | 1 + samples/Mvc.Client/project.json | 3 ++- samples/Mvc.Server/Startup.cs | 1 + samples/Mvc.Server/project.json | 1 + src/OpenIddict.Mvc/OpenIddictExtensions.cs | 22 ++++++++++++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/samples/Mvc.Client/Startup.cs b/samples/Mvc.Client/Startup.cs index 555da251..5d9a0614 100644 --- a/samples/Mvc.Client/Startup.cs +++ b/samples/Mvc.Client/Startup.cs @@ -27,6 +27,7 @@ namespace Mvc.Client { }); services.AddMvc(); + services.AddMvcDnx(); } public void Configure(IApplicationBuilder app) { diff --git a/samples/Mvc.Client/project.json b/samples/Mvc.Client/project.json index c9f42a47..a9ad8108 100644 --- a/samples/Mvc.Client/project.json +++ b/samples/Mvc.Client/project.json @@ -1,12 +1,13 @@ { "dependencies": { - "Microsoft.AspNetCore.Mvc": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", "Microsoft.AspNetCore.Hosting": "1.0.0-*", + "Microsoft.AspNetCore.Mvc": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 637d4257..622b0520 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -35,6 +35,7 @@ namespace Mvc.Server { .Build(); services.AddMvc(); + services.AddMvcDnx(); services.AddEntityFramework() .AddSqlServer() diff --git a/samples/Mvc.Server/project.json b/samples/Mvc.Server/project.json index 7c0c7706..f81ddf2f 100644 --- a/samples/Mvc.Server/project.json +++ b/samples/Mvc.Server/project.json @@ -7,6 +7,7 @@ "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*", "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", diff --git a/src/OpenIddict.Mvc/OpenIddictExtensions.cs b/src/OpenIddict.Mvc/OpenIddictExtensions.cs index 41ef2d7d..f1d18d41 100644 --- a/src/OpenIddict.Mvc/OpenIddictExtensions.cs +++ b/src/OpenIddict.Mvc/OpenIddictExtensions.cs @@ -11,6 +11,8 @@ using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using OpenIddict; @@ -93,6 +95,26 @@ namespace Microsoft.AspNetCore.Builder { .MakeGenericType(registration.UserType, registration.ApplicationType)); }); + // Register the assembly provider in the isolated container. + services.AddScoped(provider => { + var accessor = provider.GetRequiredService(); + var container = (IServiceProvider) accessor.HttpContext.Items[typeof(IServiceProvider)]; + Debug.Assert(container != null); + + // Resolve the assembly provider from the parent container. + return container.GetRequiredService(); + }); + + // Register the compilation service in the isolated container. + services.AddScoped(provider => { + var accessor = provider.GetRequiredService(); + var container = (IServiceProvider) accessor.HttpContext.Items[typeof(IServiceProvider)]; + Debug.Assert(container != null); + + // Resolve the compilation service from the parent container. + return container.GetRequiredService(); + }); + // Register the options in the isolated container. services.AddScoped(provider => builder.Options); }));