Difference between revisions of "Dice/Roller/DefaultConfig"
From DiceRoller Documentation
m (Skizzerz moved page API/Roller/DefaultConfig to Dice/Roller/DefaultConfig without leaving a redirect) |
m |
||
Line 2: | Line 2: | ||
Gets or sets the default configuration used when rolling dice expressions. | Gets or sets the default configuration used when rolling dice expressions. | ||
− | + | {{ns}} | |
− | |||
== Syntax == | == Syntax == | ||
Line 11: | Line 10: | ||
=== Property Value === | === Property Value === | ||
− | Type: [[ | + | Type: [[Dice/RollerConfig|Dice.RollerConfig]] |
The default configuration. | The default configuration. | ||
== Remarks == | == Remarks == | ||
− | When [[ | + | When [[Dice/Roller/Roll|Roller.Roll]] is called with a {{cs|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 == | == Examples == |
Latest revision as of 05:25, 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
}
}