示例#1
0
 /// <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);
 }
示例#2
0
 /// <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);
 }
示例#3
0
 /// <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);
 }
示例#4
0
 /// <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);
 }
示例#5
0
        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);
            }
        }
示例#6
0
 /// <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);
 }
示例#7
0
        /// <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>();
                }
            }
        }
示例#8
0
 /// <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);
 }
示例#9
0
 /// <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);
 }
示例#10
0
 /// <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);
 }
示例#11
0
 /// <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);
 }