< Dice
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. | |
FunctionRegistry | Gets or sets the registry of all valid function names and their callbacks. | |
MacroRegistry | Gets or sets the registry of all valid macro names and their callbacks. | |
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).
FunctionRegistry = new FunctionRegistry();
FunctionRegistry.RegisterType(typeof(BuiltinFunctions));
MacroRegistry = new MacroRegistry();
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
Reading values from RollerConfig is thread safe. Writing values or manipulating the FunctionRegistry or MacroRegistry is not thread-safe. Internal functions do not write to RollerConfig.
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()
{
MaxDice = 200
};
}
}