Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Feature Toggling for .net

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 nToggle
Octocat-spinner-32 nToggleDynamicFeatureTest
Octocat-spinner-32 nToggleTest
Octocat-spinner-32 nToggleWebTestApp
Octocat-spinner-32 nToggleWebTests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README
Octocat-spinner-32 build.bat
Octocat-spinner-32 build.xml
Octocat-spinner-32 nToggle.sln
README
Feature Toggling for .net

for more information on the concept of feature toggle see http://martinfowler.com/bliki/FeatureToggle.html

Usage
**** nToggle no longer supports appSettings and is now configured by using it's own configSection
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section
      name="nToggle"
      type="nToggle.Configuration.ToggleConfigurationSection"
      allowLocation="true"
      allowDefinition="Everywhere"
      />
  </configSections>
  
  <nToggle>
    <toggles>
      <add name="TestFeatureOn" value="True"/>
      <add name="TestFeatureOff" value="False"/>
      /*The following toggle will associate a custom IFeatureToggleRepository with the given toggle.  
	    Custom repositories can enable things like A/B testing*/
      <add name="DynamicFeature" repository="nToggleDynamicFeatureTest,nToggleDynamicFeatureTest.TestDynamicRepository" value="True"/>
    </toggles>
  </nToggle>
  <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
    <system.web>
        <compilation debug="true"/>
  </system.web>
</configuration>


Remove controls from a web page based on a feature toggle:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ToggledOff.aspx.cs" Inherits="nToggleWebTestApp.ToggledOff" %>

<%@ Register assembly="nToggle" namespace="nToggle" tagprefix="nToggle" %>
<nToggle:WebFeatureToggle ID="FeatureToggle1" EnabledBy="TestFeatureOff" runat="server" >
    <span id="enabledby"> Feature Turned Off</span>
</nToggle:WebFeatureToggle>
<nToggle:WebFeatureToggle ID="FeatureToggle2" RemovedBy="TestFeatureOff"  runat="server" >
    <span id="removedby">Feature Turned Off But Toggle is remove by feature</span>
</nToggle:WebFeatureToggle>
  
 ************ Warning: Asp.net does not populate the  controls collection with inline script tags so the following is NOT valid 
<nToggle:WebFeatureToggle ID="FeatureToggle1" EnabledBy="TestFeatureOff" runat="server" >
    <span id="enabledby"> <%= "Feature Turned Off" %></span>
</nToggle:WebFeatureToggle>


Run code in a Code Behind based on a feature toggle:
protected void Page_Load(object sender, EventArgs e)
        {
            WebFeatureToggle1.RunActionWhenDisabled(CodeToRunIfDisabled);
            WebFeatureToggle1.RunActionWhenEnabled(CodeToRunIfEnabled);
        }
        protected void CodeToRunIfDisabled()
        {
        //your code
        }
        protected void CodeToRunIfEnabled()
        {
        //your code
        }


Something went wrong with that request. Please try again.