public ActivationHandler(ActivationStrategy strategy) { if (strategy == ActivationStrategy.Unknown) { throw new ArgumentException("Strategy cannot be Unknown", nameof(strategy)); } Strategy = strategy; }
public static ToggleCollection DeserializeVersion0(JObject json) { if (!json.TryGetValue("features", out var featureTogglesToken)) { Logger.Warn("Features not found in json"); return(ToggleCollection.EmptyCollection); } var featureToggles = new List <FeatureToggle>(); foreach (var token in featureTogglesToken) { var strategyName = token["strategy"].ToObject <string>(); var parameters = token["parameters"] != null ? token["parameters"].ToObject <Dictionary <string, string> >() : new Dictionary <string, string>(); var strategy = new ActivationStrategy(strategyName, parameters); featureToggles.Add( new FeatureToggle( token["name"].ToObject <string>(), token["enabled"].ToObject <bool>(), new ActivationStrategy[] { strategy })); } return(new ToggleCollection(featureToggles)); }