GetRandomIndex() 개인적인 메소드

private GetRandomIndex ( int finishIndex ) : int
finishIndex int
리턴 int
예제 #1
0
        private static ImmutableDictionary <string, string> GetRandomImageOptions(int numberOfOptions)
        {
            var randomOptions    = ImmutableDictionary.CreateBuilder <string, string>();
            var availableOptions = Assets.Images.ToList();

            var crypto = new CryptoHelper();

            for (var i = 0; i < numberOfOptions; i++)
            {
                var randomItem = availableOptions[crypto.GetRandomIndex(availableOptions.Count)];
                randomOptions.Add(randomItem.Key, crypto.GetRandomString(20));

                availableOptions.Remove(randomItem); // We don't want duplicate entries
            }

            return(randomOptions.ToImmutable());
        }
예제 #2
0
        private static ImmutableDictionary<string, string> GetRandomImageOptions(int numberOfOptions)
        {
            var randomOptions = ImmutableDictionary.CreateBuilder<string, string>();
            var availableOptions = Assets.Images.ToList();

            var crypto = new CryptoHelper();
            for (var i = 0; i < numberOfOptions; i++)
            {
                var randomItem = availableOptions[crypto.GetRandomIndex(availableOptions.Count)];
                randomOptions.Add(randomItem.Key, crypto.GetRandomString(20));

                availableOptions.Remove(randomItem); // We don't want duplicate entries
            }

            return randomOptions.ToImmutable();
        }