Anvil
Anvil.Services.ScriptHandleFactory Class Reference

A service for registering C# functions as script handlers dynamically. More...

+ Inheritance diagram for Anvil.Services.ScriptHandleFactory:
+ Collaboration diagram for Anvil.Services.ScriptHandleFactory:

Public Member Functions

ScriptCallbackHandle CreateUniqueHandler (Func< CallInfo, ScriptHandleResult > handler)
 Creates a unique script callback handle for the specified callback method.
The returned handle can be used for certain API functions that take a script name as a parameter. More...
 
bool IsScriptRegistered (string scriptName)
 Gets if the specified script name has a script handler already defined. More...
 
ScriptCallbackHandle RegisterScriptHandler (string scriptName, Func< CallInfo, ScriptHandleResult > callback)
 Registers the specified action as a callback for the specified script name. More...
 
bool UnregisterScriptHandler (string scriptName)
 Unregisters any handler assigned to the specified script. More...
 

Properties

int ExecutionOrder [get]
 
- Properties inherited from Anvil.Services.IScriptDispatcher
int ExecutionOrder [get]
 

Detailed Description

A service for registering C# functions as script handlers dynamically.

Member Function Documentation

◆ CreateUniqueHandler()

ScriptCallbackHandle Anvil.Services.ScriptHandleFactory.CreateUniqueHandler ( Func< CallInfo, ScriptHandleResult >  handler)
inline

Creates a unique script callback handle for the specified callback method.
The returned handle can be used for certain API functions that take a script name as a parameter.

Parameters
handlerThe callback function.
Returns
The callback handle.

◆ IsScriptRegistered()

bool Anvil.Services.ScriptHandleFactory.IsScriptRegistered ( string  scriptName)
inline

Gets if the specified script name has a script handler already defined.

Parameters
scriptNameThe script name to query.
Returns
True if a handler already exists, otherwise false.

◆ RegisterScriptHandler()

ScriptCallbackHandle Anvil.Services.ScriptHandleFactory.RegisterScriptHandler ( string  scriptName,
Func< CallInfo, ScriptHandleResult >  callback 
)
inline

Registers the specified action as a callback for the specified script name.

Parameters
scriptNameThe script name to be handled.
callbackThe function invoked when this script is called by the Virtual Machine.
Returns
A handle that can be disposed to remove the handler.
Exceptions
ArgumentExceptionThrown if the specified script name is internally used by Anvil.
InvalidOperationExceptionThrown if the specified script already has a handler defined.

◆ UnregisterScriptHandler()

bool Anvil.Services.ScriptHandleFactory.UnregisterScriptHandler ( string  scriptName)
inline

Unregisters any handler assigned to the specified script.

Parameters
scriptNameThe script name to unregister.
Returns
True if a handler was removed, false if nothing was removed.

The documentation for this class was generated from the following file: