This documentation is archived and is not being maintained.

Generator.OnGenerateNextValues Method

Visual Studio 2005

Generates the next value according to the data generation algorithm.

Namespace: Microsoft.VisualStudio.TeamSystem.Data.DataGenerator
Assembly: Microsoft.VisualStudio.TeamSystem.Data (in

protected virtual void OnGenerateNextValues ()
protected void OnGenerateNextValues ()
protected function OnGenerateNextValues ()

The OnGenerateNextValues method creates the data when a data generation plan runs. You must override this method to provide the logic that generates the data for the output properties of your data generator.

The GenerateNextValues method calls this method. You should override OnGenerateNextValues if you want to override the GenerateNextValues functionality.

This example overrides the OnGenerateNextValues method to generate the random data for a data generator. This code example is part of a larger example provided for the Generator class.

DateTime mRandomDate;
Random mRandom;
Random mRandomRange;

protected override void OnGenerateNextValues()
    DateTime min;
    DateTime max;

    //Generate a random date from either range 1 or range 2.
    //Randomly select either range 1 or range 2 by randomly 
    //generating an odd or an even random number.
    if (mRandomRange.Next() % 2 == 0)  //check for odd or even
        min = mRange1Min;
        max = mRange1Max;
        min = mRange2Min;
        max = mRange2Max;

    //The formula for creating a random number in a specific range is:
    //start of range + (size of range * random number between 0 and 1)

    //size of range
    TimeSpan range = max - min;

    //(size of range * random number between 0 and 1)
    TimeSpan randomNumber = new TimeSpan((long)(range.Ticks * mRandom.NextDouble()));

    //start of range + (size of range * random number between 0 and 1)
    mRandomDate = min + randomNumber;