Difference between revisions of "Dice/FunctionCallback"

From DiceRoller Documentation
(Created page with "{{APIdoc|FunctionCallback Delegate}} Encapsulates a method which executes function logic. {{ns}} == Syntax == <syntaxhighlight lang="C#"> public delegate void FunctionCallba...")
 
 
Line 17: Line 17:
  
 
== Remarks ==
 
== Remarks ==
The FunctionCallback delegate is used alongside the [[Dice/DiceFunctionAttribute|DiceFunctionAttribute]] and [[Dice/FunctionRegistry/RegisterType|FunctionRegistry.RegisterType]], or with [[Dice/FunctionRegistry/RegisterFunction|FunctionRegistry.RegisterFunction]]. The delegate can gain insight into the context of the function call by examining the passed-in ''context'' object, and it must also modify the ''context'' object's Value and Values. If no delegate in the chain modifies the context's Value or Values, an exception is thrown.
+
The FunctionCallback delegate is used alongside the [[Dice/DiceFunctionAttribute|DiceFunctionAttribute]] and [[Dice/FunctionRegistry/RegisterType|FunctionRegistry.RegisterType]], or with [[Dice/FunctionRegistry/RegisterFunction|FunctionRegistry.RegisterFunction]]. The delegate can gain insight into the context of the function call by examining the passed-in ''context'' object, and it must also modify the ''context'' object's Value. If no delegate in the chain modifies the context's Value, an InvalidOperationException is thrown.
 +
 
 +
The context's Values should also be modified, but if left {{cs|null}}, then {{cs|context.Expression.Values}} is used instead. Should ''that'' be {{cs|null}}, an empty list is returned.

Latest revision as of 20:29, 12 April 2017

Encapsulates a method which executes function logic.

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

Syntax

public delegate void FunctionCallback(
    FunctionContext context
)

Parameters

context
Type: Dice.FunctionContext
Function context, to be filled in by the delegate.

Remarks

The FunctionCallback delegate is used alongside the DiceFunctionAttribute and FunctionRegistry.RegisterType, or with FunctionRegistry.RegisterFunction. The delegate can gain insight into the context of the function call by examining the passed-in context object, and it must also modify the context object's Value. If no delegate in the chain modifies the context's Value, an InvalidOperationException is thrown.

The context's Values should also be modified, but if left null, then context.Expression.Values is used instead. Should that be null, an empty list is returned.