public bool IsEnabled(Dictionary <string, string> parameters, UnleashContext context = null) { if (!parameters.TryGetValue(Percentage, out var value)) { return(false); } var percentage = StrategyUtils.GetPercentage(value); var randomNumber = random.Next(100) + 1; return(percentage >= randomNumber); }
public bool IsEnabled(Dictionary <string, string> parameters, UnleashContext context = null) { var sessionId = context?.SessionId; if (sessionId == null || sessionId == string.Empty) { return(false); } if (!(parameters.ContainsKey(Percentage) && parameters.ContainsKey(GroupId))) { return(false); } var percentageString = parameters[Percentage]; var percentage = StrategyUtils.GetPercentage(percentageString); var groupId = parameters[GroupId] ?? string.Empty; var normalizedSessionId = StrategyUtils.GetNormalizedNumber(sessionId, groupId); return(percentage > 0 && normalizedSessionId <= percentage); }