//TODO: Finish this
 private int GetPercentageBasedOnRequestStatistics(AbstractFeatureToggle toggle)
 {
     return(0);
     //return toggle.TotalRequestAmount == 0
     //    ? 0
     //    : toggle.EnabledRequestAmount / toggle.TotalRequestAmount * 100;
 }
        public override bool IsEnabled(AbstractFeatureToggle toggle)
        {
            int percentage = toggle.EnrichedState.HasValue
                ? GetPercentageBasedOnRemoteIpAddress(toggle)
                : GetPercentageBasedOnRequestStatistics(toggle);

            return(percentage <= Percentage);
        }
        private int GetPercentageBasedOnRemoteIpAddress(AbstractFeatureToggle toggle)
        {
            using (var hashAlgorithm = MD5.Create())
            {
                var hash          = hashAlgorithm.ComputeHash(toggle.EnrichedState.HttpContext.Connection.RemoteIpAddress.GetAddressBytes());
                var number        = BitConverter.ToInt32(hash, 0);
                var absoluteValue = Math.Abs(number);

                //return absoluteValue % (100 - Percentage);
                return(absoluteValue % 100);
            }
        }
        public override bool IsEnabled(AbstractFeatureToggle toggle)
        {
            if (!toggle.EnrichedState.HasValue)
            {
                return(false);
            }
            if (!toggle.EnrichedState.HttpContext.Request.Query.ContainsKey(toggle.Name))
            {
                return(false);
            }

            return(toggle.EnrichedState.HttpContext.Request.Query[toggle.Name].ToString().Equals(Enabled));
        }
Beispiel #5
0
        public override bool IsEnabled(AbstractFeatureToggle toggle)
        {
            if (!toggle.EnrichedState.HasValue)
            {
                return(false);
            }

            foreach (var featureGroup in _featureGroups)
            {
                if (featureGroup.ClientIps.Contains(toggle.EnrichedState.HttpContext.Connection.RemoteIpAddress.ToString()))
                {
                    return(true);
                }
                if (featureGroup.CustomerIds.Contains(toggle.EnrichedState.HttpContext.User.Identity.Name))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #6
0
 public override bool IsEnabled(AbstractFeatureToggle toggle)
 {
     return(Rules.All(x => x.IsEnabled(toggle)));
 }
Beispiel #7
0
 public override bool IsEnabled(AbstractFeatureToggle toggle)
 {
     return(false);
 }
 public abstract bool IsEnabled(AbstractFeatureToggle toggle);
Beispiel #9
0
 public NullState(AbstractFeatureToggle toggle) : base(null, toggle)
 {
 }
Beispiel #10
0
 public EnrichedState(HttpContext httpContext, AbstractFeatureToggle toggle) : base(httpContext, toggle)
 {
 }