2021-02-02 01:05:48 -05:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
|
|
|
|
{
|
|
|
|
|
public static class MvcBuilderExtensions
|
|
|
|
|
{
|
2021-02-02 12:22:58 -05:00
|
|
|
|
public static IMvcBuilder AddPoweredSoftQueries(this IMvcBuilder builder, Action<QueryControllerOptions> configuration = null)
|
2021-02-02 01:05:48 -05:00
|
|
|
|
{
|
|
|
|
|
var options = new QueryControllerOptions();
|
|
|
|
|
configuration?.Invoke(options);
|
|
|
|
|
var services = builder.Services;
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
builder.AddMvcOptions(o => o.Conventions.Add(new QueryControllerConvention(serviceProvider)));
|
|
|
|
|
builder.ConfigureApplicationPartManager(m => m.FeatureProviders.Add(new QueryControllerFeatureProvider(serviceProvider)));
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 12:22:58 -05:00
|
|
|
|
public static IMvcBuilder AddPoweredSoftCommands(this IMvcBuilder builder)
|
2021-02-02 01:05:48 -05:00
|
|
|
|
{
|
|
|
|
|
var services = builder.Services;
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
builder.AddMvcOptions(o => o.Conventions.Add(new CommandControllerConvention(serviceProvider)));
|
|
|
|
|
builder.ConfigureApplicationPartManager(m => m.FeatureProviders.Add(new CommandControllerFeatureProvider(serviceProvider)));
|
|
|
|
|
return builder;
|
2021-02-02 12:19:59 -05:00
|
|
|
|
}
|
2021-02-02 01:05:48 -05:00
|
|
|
|
}
|
|
|
|
|
}
|