Esempio n. 1
0
        /// <summary>
        /// Generates the integers and stores them in a text file
        /// </summary>
        /// <param name="options">The parsed command line options</param>
        /// <param name="updateIntegerGenerationStatus">A callback method that will be called to update
        /// the status of integer generation</param>
        static void GenerateIntegers(CommandLineOptions options, Action <int> updateIntegerGenerationStatus)
        {
            //Get an instance of the integer file creator
            IIntegerFileCreator integerFileCreator = serviceProvider.GetService <IIntegerFileCreator>();

            //Get an instance of the random integer generator
            IRandomIntegerGenerator randomIntegerGenerator = serviceProvider.GetService <IRandomIntegerGenerator>();

            //Create the random integers. The IEnumerable is actually a generator, so it generates them one at a time as
            //it is enumerated rather than a whole bunch at once
            IEnumerable <int> randomIntegers = randomIntegerGenerator.CreateIntegerGenerator(options.LowerBound,
                                                                                             options.UpperBound, (int)options.Count);

            int integersGenerated = 0;


            //When an integer is enumerated, update the integer generation status
            randomIntegers = randomIntegers.Select(integer =>
            {
                integersGenerated++;

                updateIntegerGenerationStatus(integersGenerated);

                return(integer);
            });

            //Create the integer file with the randomly-generated integers
            integerFileCreator.CreateIntegerTextFile(randomIntegers, options.FilePath);
        }
Esempio n. 2
0
 /// <summary>
 /// Instantiates a new instance of ChunkFileCreate
 /// </summary>
 /// <param name="integerFileCreator">An integer file creator instance</param>
 public ChunkFileCreator(IIntegerFileCreator integerFileCreator)
 {
     this.integerFileCreator = integerFileCreator;
 }