コード例 #1
0
        //properties

        //methods

        /// <summary>
        /// Creates a DataTable containing a set of random number values.
        /// </summary>
        /// <param name="numRows">Num of rows with number values to generate.</param>
        /// <param name="dataRequest">RandomNumberDataRequest object contains the definition for how to generate the random numbers.</param>
        /// <returns>ADO.NET DataTable containing the set of random values.</returns>
        public DataTable CreateRandomNumberDataTable(int numRows, RandomNumberDataRequest dataRequest)
        {
            enRandomNumberType numType = enRandomNumberType.enUnknown;
            DataTable          dt      = null;

            numType = GetRandomNumberTypeFromDataRequest(dataRequest);

            if (dataRequest.OutputRangeOfNumbers)
            {
                dt = CreateRangeDataTable(numType, numRows, dataRequest.MinimumValueForRange, dataRequest.MaximumValueForRange);
            }
            else if (dataRequest.OutputOffsetFromCurrentNumber)
            {
                dt = CreateOffsetDataTable(numType, numRows, dataRequest.MinimumOffsetPercent, dataRequest.MaximumOffsetPercent);
            }
            else if (dataRequest.OutputSequentialNumbers)
            {
                dt = CreateSequentialNumbersDataTable(numType, numRows, dataRequest.StartSequentialValue, dataRequest.IncrementForSequentialValue, dataRequest.MaxSequentialValue, dataRequest.InitStartSequentialValue);
            }
            else
            {
                dt = new DataTable();  //return an empty data table
            }

            return(dt);
        }
コード例 #2
0
        /// <summary>
        /// Routine to retrieve the number type from a RandomNumberDataRequest object.
        /// </summary>
        /// <param name="dataRequest">RandomNumberDataRequest object containing the definition for the random number generation.</param>
        /// <returns>enRandomNumberType enum value.</returns>
        public enRandomNumberType GetRandomNumberTypeFromDataRequest(RandomNumberDataRequest dataRequest)
        {
            enRandomNumberType randNumType = enRandomNumberType.enUnknown;

            if (dataRequest.OutputIntegerValue)
            {
                if (dataRequest.Output64bitInteger)
                {
                    if (dataRequest.OutputSignedInteger)
                    {
                        randNumType = enRandomNumberType.enLong;
                    }
                    else
                    {
                        randNumType = enRandomNumberType.enULong;
                    }
                }
                else if (dataRequest.Output32bitInteger)
                {
                    if (dataRequest.OutputSignedInteger)
                    {
                        randNumType = enRandomNumberType.enInt;
                    }
                    else
                    {
                        randNumType = enRandomNumberType.enUInt;
                    }
                }
                else if (dataRequest.Output16bitInteger)
                {
                    if (dataRequest.OutputSignedInteger)
                    {
                        randNumType = enRandomNumberType.enShort;
                    }
                    else
                    {
                        randNumType = enRandomNumberType.enUShort;
                    }
                }
                else if (dataRequest.Output8bitInteger)
                {
                    if (dataRequest.OutputSignedInteger)
                    {
                        randNumType = enRandomNumberType.enSByte;
                    }
                    else
                    {
                        randNumType = enRandomNumberType.enByte;
                    }
                }
                else
                {
                    randNumType = enRandomNumberType.enUnknown;
                }
            }
            else if (dataRequest.OutputDoubleValue)
            {
                randNumType = enRandomNumberType.enDouble;
            }
            else if (dataRequest.OutputFloatValue)
            {
                randNumType = enRandomNumberType.enFloat;
            }
            else if (dataRequest.OutputDecimalValue)
            {
                randNumType = enRandomNumberType.enDecimal;
            }
            else
            {
                randNumType = enRandomNumberType.enUnknown;
            }

            return(randNumType);
        }