You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Ds.Module.DynamicApi
|
|
|
|
|
{
|
|
|
|
|
public static class AutoAPIEx
|
|
|
|
|
{
|
|
|
|
|
public static IMvcBuilder AddDynamicWebApi(this IMvcBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
if (builder == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(builder));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.ConfigureApplicationPartManager(applicationPartManager =>
|
|
|
|
|
{
|
|
|
|
|
applicationPartManager.FeatureProviders.Add(new AutoAPIControllerFeatureProvider());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.Services.Configure<MvcOptions>(options =>
|
|
|
|
|
{
|
|
|
|
|
options.Conventions.Add(new AutoAPIApplicationModelConvention());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IMvcCoreBuilder AddDynamicWebApi(this IMvcCoreBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
if (builder == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(builder));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.ConfigureApplicationPartManager(applicationPartManager =>
|
|
|
|
|
{
|
|
|
|
|
applicationPartManager.FeatureProviders.Add(new AutoAPIControllerFeatureProvider());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.Services.Configure<MvcOptions>(options =>
|
|
|
|
|
{
|
|
|
|
|
options.Conventions.Add(new AutoAPIApplicationModelConvention());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|