< Dice
Revision as of 18:49, 15 September 2017 by Skizzerz (talk | contribs) (→‎Remarks)

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 The config that was rolled along this roll.
FunctionRegistry Functions specific to this roll. If these have the same name as a global function, this is executed instead. Cannot be null.
InternalContext Opaque contextual information used when evaluating dice expressions.
MacroRegistry Macros specific to this roll. If these have the same name as a global macro, this is executed instead. Cannot be null.
Metadata 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.