This repository was archived by the owner on Mar 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureToggle.cs
More file actions
43 lines (38 loc) · 1.31 KB
/
FeatureToggle.cs
File metadata and controls
43 lines (38 loc) · 1.31 KB
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
using System.Collections.Generic;
namespace Ilix.Configuration
{
public interface IFeatureToggle
{
bool Disabled(string feature);
bool Enabled(string feature);
}
public class FeatureToggle : IFeatureToggle
{
public bool Enabled(string feature)
{
if (!FeatureToggles().ContainsKey(feature))
return false;
return FeatureToggles()[feature];
}
public bool Disabled(string feature)
{
return !Enabled(feature);
}
private Dictionary<string, bool> FeatureToggles()
{
var result = new Dictionary<string, bool>();
var featureToggles = (System.Collections.Hashtable)System.Configuration.ConfigurationManager.GetSection("FeatureToggles");
if (featureToggles != null)
{
System.Collections.ICollection featureToggleFeatures =
((System.Collections.Hashtable)
System.Configuration.ConfigurationManager.GetSection("FeatureToggles")).Keys;
foreach (string feature in featureToggleFeatures)
{
result.Add(feature, featureToggles[feature].ToString() == "On");
}
}
return result;
}
}
}