Skip to content

API Host ScriptProxy

Liu.Yandong.Hanks edited this page Aug 19, 2026 · 3 revisions

ScriptProxy

将读取、写入、删除行为委托给脚本闭包处理器的运行时代理对象。

Runtime proxy object that delegates get/set/delete behavior to script closure handlers.

命名空间:AuroraScript.Runtime.Types。类型:class。

Namespace: AuroraScript.Runtime.Types. Kind: class.

返回 .NET Host API 参考

Back to .NET Host API Reference

用途

Purpose

ScriptProxy 是公开宿主类型。通过下方签名选择调用方式;对运行时对象、生命周期和异常,应由宿主在边界处明确处理。

Runtime proxy object that delegates get/set/delete behavior to script closure handlers.

注意

选项对象需要名为 getsetunset 的脚本闭包。

The options object expects script closures named get, set, or unset.

简单示例

Simple Example

下面是 ScriptProxy 的最小使用方式。

A minimal use of ScriptProxy.

// ScriptProxy 依赖脚本闭包处理器,通常直接在脚本中创建。
@module(MAIN);

export func run() {
    var target = { value: 42 };
    return new Proxy(target, {
        get: (obj, key) => obj[key]
    });
}

成员

Members

ScriptProxy(ScriptObject target, ScriptObject options)

创建 ScriptProxy 实例。

Use the member according to its public signature.

Parameters:

  • target
    操作的目标对象。

    Target object for the operation.

  • options
    控制此操作的配置。

    Configuration controlling this operation.

Returns

新建的 ScriptProxy 实例。

A new ScriptProxy instance.

调用示意

以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。

The example shows the call shape; replace placeholder instances and arguments with actual host values.

var value = new ScriptProxy(/* 参数 */);

Define

签名

  • void Define(string key, ScriptObject value, bool writeable = true, bool enumerable = true)
  • void Define(string key, ScriptDatum value, bool writeable = true, bool enumerable = true)

调用 Define 完成其公开操作。

Use the member according to its public signature.

Parameters:

  • key
    要查找或保存的键。

    Key to look up or store.

  • value
    要处理、保存或转换的值。

    Value to process, store, or convert.

  • writeable
    按签名提供的 bool 参数。

    The bool parameter required by the signature.

  • enumerable
    成员是否参与枚举。

    Whether the member participates in enumeration.

Returns

无。

None.

调用示意

以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。

The example shows the call shape; replace placeholder instances and arguments with actual host values.

ScriptProxy value = /* 从宿主 API 获取实例 */;
value.Define(/* key */, /* value */, /* writeable */, /* enumerable */);

Clone this wiki locally