-
Notifications
You must be signed in to change notification settings - Fork 0
API Host MemorySource
Script source backed by an in-memory string.
Namespace: AuroraScript.Source. Kind: class.
Back to .NET Host API Reference
MemorySource is the ScriptSource implementation for text a host already holds: generated code, an unsaved editor buffer, or a record loaded from a database. A custom resolver typically returns instances of this type from GetSourceAsync and GetAllSourcesAsync.
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.asMemorySource(string baseDirectory, string fullPath, string text)Creates a source over an in-memory string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
baseDirectory |
string |
Yes | Resolver root that owns the source. |
fullPath |
string |
Yes | Normalized full path or virtual source identifier. |
text |
string |
Yes | Script text. |
Returns
A new MemorySource instance.
var source = new MemorySource("mem://app/", "main.as", "@module(MAIN);");string BaseDirectoryResolver root used for module-relative paths and source read routing.
Parameters
None.
Returns
Returns string.
Console.WriteLine(source.BaseDirectory); // mem://app/string SourcePathModule-relative path used by the compiler and runtime.
Parameters
None.
Returns
Returns string.
Console.WriteLine(source.SourcePath); // main.asstring FullPathAbsolute file path or virtual source identifier.
Parameters
None.
Returns
Returns string.
Console.WriteLine(source.FullPath);string CodeScript text held by this source.
Parameters
None.
Returns
Returns string.
Console.WriteLine(source.Code);string ReadSource()Returns the script text.
Parameters
None.
Returns
Returns string.
Behavior
The text is already in memory, so the read does not touch the file system.
var code = source.ReadSource();AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License