forked from ivaylokenov/MyTested.AspNetCore.Mvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceCollectionRazorRuntimeCompilationExtensions.cs
More file actions
24 lines (23 loc) · 1.17 KB
/
ServiceCollectionRazorRuntimeCompilationExtensions.cs
File metadata and controls
24 lines (23 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace MyTested.AspNetCore.Mvc
{
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using MyTested.AspNetCore.Mvc.Internal.Razor;
/// <summary>
/// Contains Razor runtime compilation extension methods for <see cref="IServiceCollection"/>.
/// </summary>
public static class ServiceCollectionRazorRuntimeCompilationExtensions
{
/// <summary>
/// Replaces the default <see cref="IActionDescriptorChangeProvider"/> with a mocked implementation..
/// </summary>
/// <param name="serviceCollection">Instance of <see cref="IServiceCollection"/> type.</param>
/// <returns>The same <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection ReplaceRazorRuntimeCompilation(this IServiceCollection serviceCollection)
=> serviceCollection
.Remove<IActionDescriptorProvider, PageActionDescriptorProvider>()
.ReplaceSingleton<IActionDescriptorChangeProvider, TestActionDescriptorChangeProvider>();
}
}