Skip to content

API Host MemorySourceResolver

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

MemorySourceResolver

内存型 IScriptSourceResolver 实现。

In-memory IScriptSourceResolver implementation.

命名空间:AuroraScript.Source。类型:class。

Namespace: AuroraScript.Source. Kind: class.

返回 .NET Host API 参考

用途

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

In-memory IScriptSourceResolver implementation.

注意

ResolveAsync 只返回位于 Root 下且存在于内存表中的来源。

ResolveAsync only returns sources that fall under Root and exist in the memory table.

注意

在 Composite 中将内存 Resolver 放在文件系统 Resolver 前,可覆盖根路径下的磁盘来源。

Place memory before file system in Composite to override disk sources whose resolved target falls under the memory root.

注意

当解析目标位于内存根路径下时,父级内存根可以覆盖子级文件系统依赖。

A parent memory root can override a child file-system dependency when the resolved target is under the memory root.

简单示例

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

A minimal use of MemorySourceResolver.

var resolver = new MemorySourceResolver("mem://app/")
    .Add("main.as", "@module(MAIN); export func run() { return 42; }");

Console.WriteLine(resolver.Root); // mem://app/

成员

MemorySourceResolver(string root = "mem://app/")

创建 MemorySourceResolver 实例。

Use the member according to its public signature.

Parameters:

  • root
    解析器或来源的根路径。

    Root path for a resolver or source.

Returns

新建的 MemorySourceResolver 实例。

A new MemorySourceResolver instance.

调用示意

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

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

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

string Root

读取 Root 属性。

Use the member according to its public signature.

Parameters:

  • 无。

    None.

Returns

返回 string

Returns string.

调用示意

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

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

MemorySourceResolver value = /* 从宿主 API 获取实例 */;
var current = value.Root;

MemorySourceResolver Add(string path, string source)

调用 Add 完成其公开操作。

Adds or replaces a virtual memory source.

Parameters:

  • path
    要解析或读取的路径。

    Path to resolve or read.

  • source
    要处理的脚本源码。

    Script source to process.

Returns

返回 MemorySourceResolver

Returns MemorySourceResolver.

调用示意

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

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

MemorySourceResolver value = /* 从宿主 API 获取实例 */;
var result = value.Add(/* path */, /* source */);

Clone this wiki locally