在 .Net6 中配置 Dotnet 功能管理

Configuring Dotnet Feature Management in .Net6

我正在尝试在 VS2022、.net6 中配置 Dotnet 功能管理。但是,我所做的一切都是正确的,如他们 documentation 所示。但我想从不同的配置部分配置它 (Configuration.GetSection("MyFeatureFlags"))。

AddFeatureManagement 有一个带有附加参数的重载方法,我不确定要传递什么。我该如何解决这个问题?

using Microsoft.FeatureManagement;
using System.Configuration;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddFeatureManagement(Configuration.GetSection("MyFeatureFlags"));
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();

应该是:

builder.Services.AddFeatureManagement(builder.Configuration.GetSection("MyFeatureFlags"));