RollerConfig Class
From DiceRoller Documentation
Stores various configuration related to the dice roller.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Inheritance Hierarchy
System.Object
- Dice.RollerConfig
Syntax
public class RollerConfig
Constructors
Name | Description | |
---|---|---|
RollerConfig() | Constructs a new RollerConfig instance with default values. |
Properties
Name | Description | |
---|---|---|
ExecuteMacro | Gets or sets the function used to execute macros. | |
GetRandomBytes | Gets or sets the function used to generate random numbers. | |
MaxDice | Gets or sets the maximum number of dice that may be rolled. | |
MaxRecursionDepth | Gets or sets how deeply nested a dice expression can get. | |
MaxRerolls | Gets or sets the maximum number of times a single die may be rerolled. | |
MaxSides | Gets or sets the maximum number of sides a single die may have. | |
NormalSidesOnly | Gets or sets whether dice expressions are limited to rolling dice with a "normal" number of sides, or if they can roll dice of any number of sides. |
Remarks
The default values for RollerConfig are as follows. These values are set upon constructing the object, however they can be overridden by passing in different values when creating the object (see Examples below for details).
ExecuteMacro = null; // null indicates that using a macro in a dice expression is an error
GetRandomBytes = null; // null makes use of System.Cryptography.RNGCryptoServiceProvider to generate random numbers
MaxDice = 1000;
MaxRecursionDepth = 20;
MaxRerolls = 100;
MaxSides = 10000;
NormalSidesOnly = false;
Thread Safety
RollerConfig is thread safe.
Examples
The following is an example of creating a custom RollerConfig which leaves most values at their default but customizes some others.
using Dice;
class Sample
{
public static void Main()
{
var config = new RollerConfig()
{
ExecuteMacro = DoMacroStuff
};
}
public static void DoMacroStuff(MacroContext context)
{
// ...
}
}