Skip to content

Class ScriptEnvironment

Namespace: Apogee.Reflection
Assembly: Apogee.Reflection.dll

A place for the scripts of one thing to run in, such as one UI document: a table of globals of its own that falls back to the caller's, so the functions a <script> defines are visible to the document's onclick="..." attributes and to nothing else. It runs as the script that made it (its owner, its memory and time limits).

public abstract class ScriptEnvironment : IDisposable

Inheritance

object ← ScriptEnvironment

Implements

IDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Owner

Who the environment's scripts run as (the same object gives while that script calls the engine).

public abstract object Owner { get; }

Property Value

object

Methods

CanRead(string)

Whether the owner of this environment may read the file (a script a document names): a mod can read its own files and the base game's, not another mod's.

public abstract bool CanRead(string path)

Parameters

path string

Returns

bool

Compile(string, string, string)

Compiles body as the body of a function with the given parameter names ("event, element"), in the environment. Throws when it does not compile.

public abstract ScriptFunction Compile(string chunkName, string parameters, string body)

Parameters

chunkName string

parameters string

body string

Returns

ScriptFunction

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public abstract void Dispose()

Run(string, string)

Runs a chunk (its functions and variables stay in the environment). chunkName is @path for a file, so that relative requires work, or =name. Throws when it fails.

public abstract void Run(string chunkName, string source)

Parameters

chunkName string

source string

SetGlobal(string, Value)

Sets a variable the scripts of the environment see, such as document.

public abstract void SetGlobal(string name, Value value)

Parameters

name string

value Value