This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing MvcViewEngineDescriptor and switching to use OptionsSetup to
setup RazorViewEngine. Fixes #2269
- Loading branch information
Showing
13 changed files
with
61 additions
and
578 deletions.
There are no files selected for viewing
26 changes: 22 additions & 4 deletions
26
src/Microsoft.AspNet.Mvc.Razor/MvcRazorMvcViewOptionsSetup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Framework.DependencyInjection; | ||
using Microsoft.Framework.Internal; | ||
using Microsoft.Framework.OptionsModel; | ||
|
||
namespace Microsoft.AspNet.Mvc.Razor | ||
{ | ||
/// <summary> | ||
/// Configures <see cref="MvcViewOptions"/> to use <see cref="RazorViewEngine"/>. | ||
/// </summary> | ||
public class MvcRazorMvcViewOptionsSetup : ConfigureOptions<MvcViewOptions> | ||
{ | ||
public MvcRazorMvcViewOptionsSetup() | ||
: base(ConfigureMvc) | ||
/// <summary> | ||
/// Initializes a new instance of <see cref="MvcRazorMvcViewOptionsSetup"/>. | ||
/// </summary> | ||
/// <param name="serviceProvider">The application's <see cref="IServiceProvider"/>.</param> | ||
public MvcRazorMvcViewOptionsSetup(IServiceProvider serviceProvider) | ||
: base(options => ConfigureMvc(serviceProvider, options)) | ||
{ | ||
Order = DefaultOrder.DefaultFrameworkSortOrder; | ||
} | ||
|
||
public static void ConfigureMvc(MvcViewOptions options) | ||
/// <summary> | ||
/// Configures <paramref name="options"/> to use <see cref="RazorViewEngine"/>. | ||
/// </summary> | ||
/// <param name="serviceProvider">The application's <see cref="IServiceProvider"/>.</param> | ||
/// <param name="options">The <see cref="MvcViewOptions"/> to configure.</param> | ||
public static void ConfigureMvc( | ||
[NotNull] IServiceProvider serviceProvider, | ||
[NotNull] MvcViewOptions options) | ||
{ | ||
options.ViewEngines.Add(typeof(RazorViewEngine)); | ||
var razorViewEngine = ActivatorUtilities.CreateInstance<RazorViewEngine>(serviceProvider); | ||
options.ViewEngines.Add(razorViewEngine); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/ViewEngine/ICompositeViewEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.AspNet.Mvc.Rendering | ||
{ | ||
/// <summary> | ||
/// Represents an <see cref="IViewEngine"/> that delegates to one of a collection of view engines. | ||
/// </summary> | ||
public interface ICompositeViewEngine : IViewEngine | ||
{ | ||
/// <summary> | ||
/// Gets the list of <see cref="IViewEngine"/> this instance of <see cref="ICompositeViewEngine"/> delegates | ||
/// to. | ||
/// </summary> | ||
IReadOnlyList<IViewEngine> ViewEngines { get; } | ||
} | ||
} |
52 changes: 0 additions & 52 deletions
52
src/Microsoft.AspNet.Mvc.ViewFeatures/ViewEngineDescriptor.cs
This file was deleted.
Oops, something went wrong.
140 changes: 0 additions & 140 deletions
140
src/Microsoft.AspNet.Mvc.ViewFeatures/ViewEngineDescriptorExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.