< Dice‎ | Roller
Revision as of 05:25, 9 April 2017 by Skizzerz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Roller.DefaultConfig Property

From DiceRoller Documentation

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
    }
}