Visual Studio Team Data Managed Ref
GeneratorOnGenerateNextValues Method

Generates the next value according to the data generation algorithm.

Namespace:   Microsoft.VisualStudio.TeamSystem.Data.DataGenerator
Assembly:  Microsoft.VisualStudio.TeamSystem.Data (in Microsoft.VisualStudio.TeamSystem.Data.dll)
Protected Overridable Sub OnGenerateNextValues

Me.OnGenerateNextValues()
protected virtual void OnGenerateNextValues()
protected:
virtual 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;
    }
    else
    {
        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;
}
Dim mRandomDate As Date
Dim mRandom As Random
Dim mRandomRange As Random 

Protected Overrides Sub OnGenerateNextValues()

    Dim min As Date
    Dim max As Date

    '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() Mod 2 = 0 Then  'check for odd or even
        min = mRange1Min
        max = mRange1Max
    Else
        min = mRange2Min
        max = mRange2Max
    End If

    '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
    Dim range As TimeSpan = max - min

    '(size of range * random number between 0 and 1)
    Dim randomNumber As TimeSpan = New TimeSpan(CLng(range.Ticks * mRandom.NextDouble()))

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

End Sub