< Dice
Revision as of 22:10, 15 September 2017 by Skizzerz (talk | contribs) (→‎Properties)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

RollData Class

From DiceRoller Documentation

Holds data relevant to the scope of a single roll (as opposed to the global scope of RollerConfig).

  • Namespace: Dice
  • Assembly: DiceRoller (in DiceRoller.dll)

Inheritance Hierarchy

System.Object

Dice.RollData

Syntax

public class RollData

Properties

Name Description
Config Gets or sets the config that was rolled along this roll.
FunctionRegistry Gets or sets functions specific to this roll. If these have the same name as a global function, this is executed instead. Cannot be null.
InternalContext Gets or sets opaque contextual information used when evaluating dice expressions.
MacroRegistry Gets or sets macros specific to this roll. If these have the same name as a global macro, this is executed instead. Cannot be null.
Metadata Gets or sets an optional metadata object that is passed as-is to the RollResult and is serialized alongside it.

Remarks

FunctionRegistry and MacroRegistry are initialized with default versions of those classes when a RollData object is constructed. The Metadata object is probably the most interesting property here, as it allows for serializing custom data along with a post. This metadata is also passed into the function and macro callbacks, so that you can implement advanced behaviors as needed.

If you need to add or remove functions or macros during the course of a roll, or a function or macro should only be valid for certain rolls but not others (depending on context), then RollData is also a good choice for such things. As an example, the [roll] macro used by RollPost is added as a roll-specific macro in the RollData rather than registered as a global macro.