Skip to content

API Host MemorySource

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

MemorySource

由内存字符串承载的脚本源码。

Script source backed by an in-memory string.

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

Namespace: AuroraScript.Source. Kind: class.

返回 .NET Host API 参考

Back to .NET Host API Reference

用途

Purpose

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

Script source backed by an in-memory string.

简单示例

Simple Example

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

A minimal use of MemorySource.

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

Console.WriteLine(source.SourcePath); // main.as

成员

Members

MemorySource(string baseDirectory, string fullPath, string text)

创建 MemorySource 实例。

Use the member according to its public signature.

Parameters:

  • baseDirectory
    来源所属的 Resolver 根目录。

    Resolver root directory owning the source.

  • fullPath
    来源的规范化完整路径。

    Normalized full path of the source.

  • text
    要保存或读取的文本。

    Text to store or read.

Returns

新建的 MemorySource 实例。

A new MemorySource instance.

调用示意

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

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

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

string BaseDirectory

读取 BaseDirectory 属性。

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.

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

string SourcePath

读取 SourcePath 属性。

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.

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

string FullPath

读取 FullPath 属性。

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.

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

string Code

读取 Code 属性。

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.

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

string ReadSource()

调用 ReadSource 完成其公开操作。

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.

MemorySource value = /* 从宿主 API 获取实例 */;
var result = value.ReadSource();

Clone this wiki locally