Difference between revisions of "Dice/Roller/DefaultConfig"
From DiceRoller Documentation
(Created page with "{{APIdoc|Roller.DefaultConfig Property}} Gets or sets the default configuration used when rolling dice expressions. * '''Namespace:''' Dice * '''Assembly:''' Dic...") |
m (Skizzerz moved page API/Roller/DefaultConfig to Dice/Roller/DefaultConfig without leaving a redirect) |
Revision as of 05:22, 9 April 2017
Gets or sets the default configuration used when rolling dice expressions.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
public static RollerConfig DefaultConfig { get; set; }
Property Value
Type: Dice.RollerConfig
The default configuration.
Remarks
When Roller.Roll is called with a null
config argument, the DefaultConfig is used. Setting this property therefore allows you to modify the behavior of many dice rolls without needing to remember to explicitly pass a configuration object. This property is initialized in Roller's static constructor to be default values.
Examples
The following example demonstrates setting a custom default configuration.
using Dice;
class Sample
{
public static void Main()
{
Roller.DefaultConfig = new RollerConfig()
{
NormalSidesOnly = true // restrict to rolling only "normal" die sizes
};
var result = Roller.Roll("1d19"); // throws a DiceException with DiceErrorCode.WrongSides
}
}