/// <summary> /// Activates a User on the feature /// </summary> /// <param name="feature">The feature</param> /// <param name="userID">The UserID to activate</param> public void ActivateUser(Feature feature, string userID) { feature.AddUser(userID); SaveFeature(feature); }
/// <summary> /// Deactivates the group on the feature /// </summary> /// <param name="feature">The feature</param> /// <param name="group">The group to deactivate</param> public void DeactivateGroup(Feature feature, string group) { feature.RemoveGroup(group); SaveFeature(feature); }
/// <summary> /// Activates the group on the feature /// </summary> /// <param name="feature">The feature</param> /// <param name="group">The group to activate</param> public void ActivateGroup(Feature feature, string group) { feature.AddGroup(group); SaveFeature(feature); }
/// <summary> /// Activates the percentage on a feature /// </summary> /// <param name="feature">The feature</param> /// <param name="percentage">The percentage to allow active</param> public void ActivatePercentage(Feature feature, int percentage) { feature.Percentage = percentage; SaveFeature(feature); }
private void SaveFeature(Feature feature) { using (var client = manager.GetClient()) using (var featureClient = client.As<Feature>()) { featureClient.Lists["Flipper:Features"].Remove(feature); featureClient.Lists["Flipper:Features"].Add(feature); } }
/// <summary> /// Sets a feature to active by setting the percentage to 100 /// </summary> /// <param name="feature">The feature to activate</param> public void ActivateFeature(Feature feature) { feature.Percentage = 100; SaveFeature(feature); }
/// <summary> /// Loads a feature from redis /// </summary> /// <param name="feature">The feature to load</param> public void LoadFeature(Feature feature) { using (var client = manager.GetClient()) using (var featureClient = client.As<Feature>()) { var f = featureClient.Lists["Flipper:Features"].FirstOrDefault(fe => fe == feature); if (f != null) { feature.Percentage = f.Percentage; feature.Groups = f.Groups; feature.Users = f.Users; } else { feature.Percentage = 0; feature.Groups = new List<string>(); feature.Users = new List<string>(); } } }
/// <summary> /// Indicates if a feature is active /// </summary> /// <param name="feature">The feature</param> /// <param name="userID">Opitional specific userID</param> /// <returns>Bool indicating if active</returns> public bool IsActive(Feature feature, string userID = "") { return feature.IsActive(this, userID); }
/// <summary> /// Sets a feature to inactive by Clearing the feature /// </summary> /// <param name="feature">The feature to deactivate</param> public void DeactiveFeature(Feature feature) { feature.Clear(); SaveFeature(feature); }
/// <summary> /// Deactivate the User on a feature /// </summary> /// <param name="feature">The feature</param> /// <param name="userID">The UserID to deactivate</param> public void DeactivateUser(Feature feature, string userID) { feature.RemoveUser(userID); SaveFeature(feature); }
/// <summary> /// Deactivates a the percentage on a feature (sets to 0) /// </summary> /// <param name="feature">The feature</param> public void DeactivatePercentage(Feature feature) { feature.Percentage = 0; SaveFeature(feature); }