2023-11-04 15:24:56 -04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using OpenHarbor.CQRS.DynamicQuery.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace OpenHarbor.CQRS.DynamicQuery.AspNetCore;
|
|
|
|
|
|
|
|
|
|
public static class MvcBuilderExtensions
|
|
|
|
|
{
|
2023-11-04 16:08:39 -04:00
|
|
|
|
public static IMvcBuilder AddOpenHarborDynamicQueries(this IMvcBuilder builder, Action<DynamicQueryControllerOptions> configuration = null)
|
2023-11-04 15:24:56 -04:00
|
|
|
|
{
|
|
|
|
|
var options = new DynamicQueryControllerOptions();
|
|
|
|
|
configuration?.Invoke(options);
|
|
|
|
|
var services = builder.Services;
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
builder.AddMvcOptions(o => o.Conventions.Add(new DynamicQueryControllerConvention(serviceProvider)));
|
|
|
|
|
builder.ConfigureApplicationPartManager(m => m.FeatureProviders.Add(new DynamicQueryControllerFeatureProvider(serviceProvider)));
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
}
|