private HashSet <int> BigPercentageGenerateMethod(IUsedNumbersProvider usedNumbersProvider, int count) { var allNumbers = Enumerable.Range(From, (To - From) + 1); var unusedNumbers = allNumbers.Except(usedNumbersProvider.GetUsedNumbers()); var returnedNumbers = unusedNumbers.ToList().TakeRandom(count); usedNumbersProvider.SaveUsedNumbers(returnedNumbers); return(new HashSet <int>(returnedNumbers)); }
private HashSet <int> SmallPercentageGenerateMethod(IUsedNumbersProvider usedNumbersProvider, int count) { HashSet <int> usedNumbers = usedNumbersProvider.GetUsedNumbers(); HashSet <int> returnedNumbers = new HashSet <int>(); Random rnd = new Random(); int added = 0; int currCandidate = 0; do { currCandidate = rnd.Next(From, To); if (!usedNumbers.Contains(currCandidate)) { returnedNumbers.Add(currCandidate); usedNumbers.Add(currCandidate); added++; } } while (added != count); usedNumbersProvider.SaveUsedNumbers(returnedNumbers); return(returnedNumbers); }