Skip to main content
Version: 2025

XSalScript

Namespace: PPJ.Runtime.XSal

Assembly: PPJ.Web.XSal.50 (5.0.0.0)

Compiles and executes XSal-compatible or C# script text through the shared script engine.

public class XSalScript

Example:

XSalScript script = new XSalScript("{ return 2 + 3; }");
string result = script.Run();
script.Dispose();

Constructors

Instance member XSalScript()

Creates a script with empty source and no compiled program.

Instance member XSalScript(source)

Creates a script and compiles nonempty source.

NameTypeDescription
sourceStringThe script text; braces around the complete text enable C# syntax.

Properties

Instance member Context

Object: Gets or sets the object used as the execution context for member lookup.

Instance member CSharpSyntax

Boolean: Gets or sets whether source is treated as C# syntax without XSal preprocessing. Changing this setting alone does not recompile the script.

Instance member DebugMode

Boolean: Gets or sets whether parser and interpreter exceptions are rethrown instead of captured in LastError.

Instance member Handle

IntPtr: Gets a lazily allocated GCHandle that keeps this script alive until Dispose releases it.

Instance member HasErrors

Boolean: Gets whether the most recently recorded error text is nonempty.

Static member Interpreter

ScriptEngine: Gets or sets the shared script engine, lazily creating an engine when the stored value is null.

Instance member LastError

String: Gets the most recently captured parser or interpreter error, or null when the last compilation or execution cleared it.

Instance member Source

String: Gets or sets script source, preprocessing XSal syntax and compiling nonempty assignments.

A source beginning with { and ending with } turns on CSharpSyntax. Assigning null or empty text stores an empty string without clearing the previously compiled program or error.

Methods

Instance member AddLine(line)

Appends a source line with a line terminator and recompiles the program.

ParameterTypeDescription
lineStringThe line to append; null or empty text leaves the script unchanged.

Returns: Boolean. True if compilation succeeds or the line is empty; false for a captured parser error.

Instance member Dispose()

Clears the execution context and releases the allocated handle, if any.

Protected member Finalize()

Clears the execution context and releases the allocated handle when the script is finalized.

Static member FromHandle(handle)

Retrieves a script from its allocated GCHandle.

ParameterTypeDescription
handleIntPtrA live handle obtained from XSalScript.Handle, or IntPtr.Zero.

Returns: XSalScript. The referenced script, or null for IntPtr.Zero.

Instance member Run()

Executes the compiled program using Context.

Returns: String. The result converted to text, or an empty string for a null result, no compiled program, or a captured interpreter error.