forked from SteveMoyer/nToggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
68 lines (57 loc) · 2.46 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
}