Click or drag to resize
Generators

Some types of content require some initial setup before random data can be generated. Other types of data benefit from some form of buffering when generating multiple instances of random data. In both of these cases, Generators can be useful, allowing the initial setup to only be performed once for a given set of parameters, and enabling any buffering behavior that needs to be performed.

Creating and Using Generators

For content that is likely to benefit from generators, there will be extension functions following the naming convention Make<function>Generator(). For example, MakeRangeOCGenerator(6) will return an IRangeGenerator<int> that will generate a number from 1 to 6 each time Next is called on the generator.

In general, generators will support a Next() method or similar method for generating random data. Some might include additional members, such as IEnumGeneratorTEnum, which also includes NextName for getting the name of the next enumeration item, rather than its value, or IDiceGenerator, which also includes the dice field to examine the individual dice rolls that produced the summed value.

Support for Generators
See Also