< Dice | FunctionRegistry
FunctionRegistry.RegisterFunction Method (String, FunctionCallback, FunctionScope)
From DiceRoller Documentation
Registers the specified callback to the given name and scope.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
public void RegisterFunction(
string name,
FunctionCallback callback,
FunctionScope scope
)
Parameters
- name
- Type: System.String
- Function name to register. Function names are case-insensitive.
- callback
- Type: Dice.FunctionCallback
- The method to be called whenever the function is called in a dice expression.
- scope
- Type: Dice.FunctionScope
- The scope of the function.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | name is null .
|
ArgumentException | name is the empty string. |
InvalidOperationException | A function with the same name and scope has already been registered. |
Remarks
The short-hand FunctionScope.All and FunctionScope.Roll can be used to register the function for multiple scopes simultaneously, obviating the need for multiple calls to RegisterFunction().
Basic- and group-scoped functions are registered with FunctionTiming.Last. Function timing is not used for global-scoped functions.
There can only be one callback associated with any given function name and scope. It is an error to re-register a function, but a function can be removed and then registered again.