Skip to content

Latest commit

 

History

History

Bet.AspNet.FeatureManagement

Bet.AspNet.FeatureManagement

GitHub license Build status NuGet Nuget feedz.io

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.

Install

    dotnet add package Bet.AspNet.FeatureManagement

Usage

  1. Create Feature Configuration in the source
<appSettings>
    <!-- inline feature config -->
    <add key="FeatureManagement:Alpha" value="false" />
    <add key="FeatureManagement:Beta" value="true" />
  </appSettings>
  1. 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() };
        }
    }
  1. MVC4 controller usage
     public class FeatureManagementController : Controller
    {
        // GET: FeatureManagement
        [FeatureGate(RequirementType.All, FeatureReleaseFlags.Beta, FeatureReleaseFlags.Alpha)]
        public ActionResult Index()
        {
            return View();
        }
    }