From 90f0e299235326c86104769998be454bd7260eb0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 24 May 2016 10:40:33 -0700 Subject: [PATCH] Inject the IRazorViewEngine directory instead of using GetRequiredService --- .../Internal/MvcRazorMvcViewOptionsSetup.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs index 65fbd586ec..679bc00d2b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs @@ -15,24 +15,24 @@ public class MvcRazorMvcViewOptionsSetup : ConfigureOptions /// /// Initializes a new instance of . /// - /// The application's . - public MvcRazorMvcViewOptionsSetup(IServiceProvider serviceProvider) - : base(options => ConfigureMvc(serviceProvider, options)) + /// The . + public MvcRazorMvcViewOptionsSetup(IRazorViewEngine razorViewEngine) + : base(options => ConfigureMvc(razorViewEngine, options)) { } /// /// Configures to use . /// - /// The application's . + /// The . /// The to configure. public static void ConfigureMvc( - IServiceProvider serviceProvider, + IRazorViewEngine razorViewEngine, MvcViewOptions options) { - if (serviceProvider == null) + if (razorViewEngine == null) { - throw new ArgumentNullException(nameof(serviceProvider)); + throw new ArgumentNullException(nameof(razorViewEngine)); } if (options == null) @@ -40,7 +40,6 @@ public static void ConfigureMvc( throw new ArgumentNullException(nameof(options)); } - var razorViewEngine = serviceProvider.GetRequiredService(); options.ViewEngines.Add(razorViewEngine); } }