Beispiel #1
0
        /// <summary>
        /// Initializes the random source.
        /// </summary>
        public FileRandomSource()
        {
            FileRandomSourceSettings settings = UserSettings.GetSettings(typeof(FileRandomSourceSettings)) as FileRandomSourceSettings;

            this.filePath = settings.FilePath;
            this.fileType = settings.FileType;

            // If the file is binary allocate the block array in advance
            if (this.fileType == FileType.Binary)
            {
                this.block = new double[blockSize];
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the specified block of randomly generated numbers
        /// from the file used as a random source.
        /// </summary>
        /// <param name="blockNumber">The index of the block to load.</param>
        private void LoadBlock(int blockNumber)
        {
            // If this is the first load update the file type (in case the user edited it)
            if (this.firstLoad)
            {
                this.firstLoad = false;
                FileRandomSourceSettings settings = UserSettings.GetSettings(typeof(FileRandomSourceSettings)) as FileRandomSourceSettings;
                this.fileType = settings.FileType;
            }

            // Load the block based on the file type
            if (this.fileType == FileType.Binary)
            {
                LoadBlockBinary(blockNumber);
            }
            else
            {
                LoadBlockText(blockNumber);
            }
        }