Adding design time support for ViewComponent TagHelpers

This commit is contained in:
Ajay Bhargav Baaskaran 2016-09-20 15:35:42 -07:00
parent 03b3d6bec8
commit 0d782d9d9a
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// 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.Reflection;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
internal class DesignTimeMvcServiceCollectionProvider
{
// This method invoked by RazorTooling using reflection.
public static void PopulateServiceCollection(IServiceCollection services, string assemblyName)
{
var assembly = Assembly.Load(new AssemblyName(assemblyName));
var partManager = new ApplicationPartManager();
partManager.ApplicationParts.Add(new AssemblyPart(assembly));
services.AddSingleton(partManager);
services.AddMvc();
}
}
}