Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 4.09 KB

README.md

File metadata and controls

76 lines (55 loc) · 4.09 KB

Build status

Feature Switch

Supporting FeatureSwitch

If you find this library useful, cup of coffee would be awesome! You can support further development of the library via Paypal.

Feature Toggling Framework for Various Types of Applications

Have you ever wrote the code like following to verify that either you have to disable or enable some functionality base on set of conditions (usually different sources):

  if(ConfigurationManager.AppSettings["MyKey"] == "true")
      return ...;

or something like this:

  if(HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session["MyKey"] == "true")
      return ...;

FeatureSwitch library should reduce amount of time and code needed to implement feature toggle in unified way. FeatureSwitch library is easily adoptable and extendable.

Overview

FeatureSwitch library is based on two basic aspects features and strategies. In combination they provide enough input data for feature set builder to construct feature context to be used later to check whether particular feature is enabled or disabled. Currently there are following additional integrations:

Features

Feature is main aspect of FeatureSwitch library it's your logical feature representation - either it's enabled or disabled. You will need to define your features to work with FeatureSwitch library. To define your feature you have to create class that inherits from FeatureSwitch.BaseFeature class:

  public class MySampleFeature : FeatureSwitch.BaseFeature
  {
  }

Keep in mind that you will need to add at least one strategy for the feature in order to enable it. By default every feature is disabled.

Setup (FeatureSet builder)

To get started with FeatureSwitch you need to kick-off FeatureSetBuilder by calling Build() instance method:

  var builder = new FeatureSetBuilder();
  builder.Build();

By calling Build method you are triggering auto-discovery of features in current application domain loaded assemblies. Auto-discovery will look for classes inheriting from FeatureSwitch.BaseFeature class. Those are assumed to be features.

Is Feature Enabled?

After features have been discovered and set has been built you are able to check whether feature is enabled or not:

  var isEnabled = FeatureContext.IsEnabled<MySampleFeature>();

You can also use some of the IsEnabled overloads for other usages.

Where do I get packages?

All packages are available on NuGet feeds:

More Information

More information on extending FeatureSwitch library.