-
Notifications
You must be signed in to change notification settings - Fork 0
API Host ScriptMethodDelegate
宿主持有的可调用脚本方法委托签名。
Delegate shape for host-held callable script methods.
命名空间:AuroraScript.Runtime。类型:delegate。
Namespace:
AuroraScript.Runtime. Kind: delegate.
Purpose
ScriptMethodDelegate 是公开宿主类型。通过下方签名选择调用方式;对运行时对象、生命周期和异常,应由宿主在边界处明确处理。
Delegate shape for host-held callable script methods.
Simple Example
下面是 ScriptMethodDelegate 的最小使用方式。
A minimal use of
ScriptMethodDelegate.
ScriptMethodDelegate echo = (userState, arguments) =>
arguments.Length == 0 ? ScriptDatum.Null : arguments[0];
var result = echo(null, ScriptDatum.FromNumber(42));
Console.WriteLine(result.Number); // 42Members
调用 Invoke 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
userState
与执行上下文关联的用户状态。User state associated with the execution context.
-
arguments
传给脚本或回调的实参数组。Argument array passed to a script or callback.
Returns
返回 ScriptDatum。
Returns
ScriptDatum.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptMethodDelegate value = /* 从宿主 API 获取实例 */;
var result = value.Invoke(/* userState */, /* arguments */);AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License