动态加载管理控制器

This commit is contained in:
Sanchime 2022-11-27 17:36:19 +08:00
parent 4aa5174881
commit 15904e0ed0
3 changed files with 9 additions and 3 deletions

View File

@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.ApplicationModels;
namespace Dipper.Alioth.Web;
public class ServiceConvention : IApplicationModelConvention
public class StarletConvention : IApplicationModelConvention
{
public void Apply(ApplicationModel application)
{

View File

@ -3,13 +3,14 @@ using Dipper.Alioth.Providers;
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Dipper.Alioth.Web;
public static class ServiceExtension
public static class StarletExtension
{
public static WebApplicationBuilder AddStarApp(this WebApplicationBuilder builder, Action<StarOption>? action = null)
{
@ -65,5 +66,10 @@ public static class ServiceExtension
manager.FeatureProviders.Add(new ApiFeatureProvider());
});
builder.Services.Configure<MvcOptions>(options =>
{
options.Conventions.Add(new StarletConvention());
});
}
}

View File

@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Controllers;
namespace Dipper.Alioth.Web;
public class ServiceFeatureProvider : ControllerFeatureProvider
public class StarletFeatureProvider : ControllerFeatureProvider
{
protected override bool IsController(TypeInfo typeInfo)
{