Generator.OnInitialize Method
Initializes the generator.
Namespace: Microsoft.VisualStudio.TeamSystem.Data.DataGenerator
Assembly: Microsoft.VisualStudio.TeamSystem.Data (in microsoft.visualstudio.teamsystem.data.dll)
Syntax
'Declaration
Protected Overridable Sub OnInitialize ( _
initInfo As GeneratorInit _
)
'Usage
Dim initInfo As GeneratorInit
Me.OnInitialize(initInfo)
protected virtual void OnInitialize (
GeneratorInit initInfo
)
protected:
virtual void OnInitialize (
GeneratorInit^ initInfo
)
protected void OnInitialize (
GeneratorInit initInfo
)
protected function OnInitialize (
initInfo : GeneratorInit
)
Parameters
- initInfo
Runtime configuration information such as the database connection string. Also contains shared instancing information.
Remarks
OnInitialize runs any initialization code that is required before data generation starts. This code can include initializing a random object or caching a database.
When you generate random data, it can be deterministic or non-deterministic. Deterministic data repeats the same random data every time that you generate it with the same seed. All data generators have a Seed property that the user can set. You can override the OnInitialize method to seed the Random objects and make your generator deterministic.
The Initialize method calls this method. You should override OnInitialize if you want to override the Initialize functionality.
Example
This example uses the Seed property to create a deterministic generator. This code example is part of a larger example provided for the Generator class.
Random mRandom;
Random mRandomRange;
protected override void OnInitialize(GeneratorInit initInfo)
{
mRandom = new Random(this.Seed); //deterministic
mRandomRange = new Random(this.Seed); //deterministic
//mRandom = new Random(); //non-deterministic
//mRandomRange = new Random(); //non-deterministic
base.OnInitialize(initInfo);
}
Dim mRandom As Random
Dim mRandomRange As Random
Protected Overrides Sub OnInitialize(ByVal initInfo As GeneratorInit)
mRandom = New Random(Me.Seed) 'deterministic
mRandomRange = New Random(Me.Seed) 'deterministic
'mRandom = New Random() 'non-deterministic
'mRandomRange = New Random() 'non-deterministic
MyBase.OnInitialize(initInfo)
End Sub
See Also
Tasks
Walkthrough: Creating a Custom Data Generator for a Check Constraint
Reference
Generator Class
Generator Members
Microsoft.VisualStudio.TeamSystem.Data.DataGenerator Namespace
GeneratorAttribute
GeneratorInit
IGenerator
Concepts
An Overview of Data Generator Extensibility
Specifying Details of Data Generation for a Column