Esempio n. 1
0
        /// <summary>
        /// Returns the only instance of RandomGeneratorProvider.
        /// </summary>
        /// <returns>RandomGeneratorProvider only instance.</returns>
        public static RandomGeneratorProvider GetInstance()
        {
            // No need for multi threading fix.
            if (instance == null)
            {
                instance = new RandomGeneratorProvider();
            }

            return instance;
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the only instance of RandomGeneratorProvider.
        /// </summary>
        /// <returns>RandomGeneratorProvider only instance.</returns>
        public static RandomGeneratorProvider GetInstance()
        {
            // No need for multi threading fix.
            if (instance == null)
            {
                instance = new RandomGeneratorProvider();
            }

            return(instance);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles shuffling of an IEnumerable of T with Fisher-Yates shuffle algorithm.
        /// </summary>
        /// <typeparam name="T">Generic type.</typeparam>
        /// <param name="source">IEnumerable of T to be shuffled randomly.</param>
        /// <returns>Shuffled IEnumerable.</returns>
        public static IEnumerable <T> Shuffle <T>(this IEnumerable <T> source)
        {
            var randomGenerator = RandomGeneratorProvider.GetInstance();

            return(source.Shuffle(randomGenerator));
        }