Note: Pre-release packages are distributed via feedz.io.
This library was design to support ASP.NET WebForms, MVC4 and WebApi legacy projects for Microsoft.FeatureManagement.
dotnet add package Bet.AspNet.FeatureManagement
- Create Feature Configuration in the source
<appSettings>
<!-- inline feature config -->
<add key="FeatureManagement:Alpha" value="false" />
<add key="FeatureManagement:Beta" value="true" />
</appSettings>
- WebApi2 Controller usage
public class ValuesController : ApiController
{
private readonly OptionsService _optionsService;
private readonly IOptionsSnapshot<AppOptions> _options;
public ValuesController(OptionsService optionsService, IOptionsSnapshot<AppOptions> options)
{
_optionsService = optionsService;
_options = options;
}
// GET: api/Values
[ApiFeatureGate(FeatureReleaseFlags.Alpha)]
public IEnumerable<string> Get()
{
return new string[] { _options.Value.Message, _optionsService.GetValue() };
}
}
- MVC4 controller usage
public class FeatureManagementController : Controller
{
// GET: FeatureManagement
[FeatureGate(RequirementType.All, FeatureReleaseFlags.Beta, FeatureReleaseFlags.Alpha)]
public ActionResult Index()
{
return View();
}
}