Ejemplo n.º 1
0
        public override bool IsEnabled(Dictionary <string, string> parameters)
        {
            if (!parameters.ContainsKey(PERCENTAGE))
            {
                return(false);
            }
            int percentage   = StrategyUtils.GetPercentage(parameters[PERCENTAGE]);
            int randomNumber = _random.Next(100) + 1;

            return(percentage >= randomNumber);
        }
Ejemplo n.º 2
0
        public override bool IsEnabled(Dictionary <string, string> parameters, UnleashContext context)
        {
            var sessionId = context.SessionId;

            if (string.IsNullOrWhiteSpace(sessionId))
            {
                return(false);
            }

            var percentage = StrategyUtils.GetPercentage(parameters[PERCENTAGE]);
            var groupId    = parameters.ContainsKey(GROUP_ID) ? parameters[GROUP_ID] : "";

            var normalizedSessionId = StrategyUtils.GetNormalizedNumber(sessionId, groupId);

            return(percentage > 0 && normalizedSessionId <= percentage);
        }