Difference between revisions of "Dice/RollData"

From DiceRoller Documentation
(Created page with "{{APIdoc|RollData Class}} Holds data relevant to the scope of a single roll (as opposed to the global scope of {{l|RollerConfig}}). {{ns}} == Inheritance Hierarchy == System...")
 
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
 
! Name !! Description
 
! Name !! Description
 
|-
 
|-
| {{internal}} {{property}} || [[/Config|Config]] || The config that was rolled along this roll.
+
| {{internal}} {{property}} || [[/Config|Config]] || Gets or sets the config that was rolled along this roll.
 
|-
 
|-
| {{public}} {{property}} || [[/FunctionRegistry|FunctionRegistry]] || Functions specific to this roll. If these have the same name as a global function, this is executed instead. Cannot be {{cs|null}}.
+
| {{public}} {{property}} || [[/FunctionRegistry|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 {{cs|null}}.
 
|-
 
|-
| {{internal}} {{property}} || [[/InternalContext|InternalContext]] || Opaque contextual information used when evaluating dice expressions.
+
| {{internal}} {{property}} || [[/InternalContext|InternalContext]] || Gets or sets opaque contextual information used when evaluating dice expressions.
 
|-
 
|-
| {{public}} {{property}} || [[/MacroRegistry|MacroRegistry]] || Macros specific to this roll. If these have the same name as a global macro, this is executed instead. Cannot be {{cs|null}}.
+
| {{public}} {{property}} || [[/MacroRegistry|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 {{cs|null}}.
 
|-
 
|-
| {{public}} {{property}} || [[/Metadata|Metadata]] || An optional metadata object that is passed as-is to the {{l|RollResult}} and is serialized alongside it.
+
| {{public}} {{property}} || [[/Metadata|Metadata]] || Gets or sets an optional metadata object that is passed as-is to the {{l|RollResult}} and is serialized alongside it.
 
|}
 
|}
  
Line 32: Line 32:
 
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.
 
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 {{c|[roll]}} macro used by {{l|Dice.Grammar.RollPost|RollPost}} is added as a roll-specific macro in the RollData rather than registered as a global macro.
+
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 {{c|[roll]}} macro used by {{l|Dice.PbP.RollPost|RollPost}} is added as a roll-specific macro in the RollData rather than registered as a global macro.

Latest revision as of 22:10, 15 September 2017

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.