Skip to content

API Host ClrType

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

ClrType

Script-visible wrapper for a registered CLR type.

Namespace: AuroraScript.Runtime.Interop. Kind: class.

Back to .NET Host API Reference

Overview

ClrType is the descriptor a script sees after a CLR type has been registered under an alias. It carries the access policy chosen at registration time, so construction and static-member access follow the TypeAccess value the host supplied.

Note

Hosts normally obtain this through AuroraEngine.RegisterType or ClrTypeRegistry.TryGetClrType.

Quick Reference

A minimal use of ClrType.

engine.RegisterType<DateTime>("HostDate", TypeAccess.Constructor);

if (engine.ClrRegistry.TryGetClrType("HostDate", out var type))
{
    Console.WriteLine(type);
}

Methods

Construct

void Construct(ScriptContext ctx, Span<ScriptDatum> args, ref ScriptDatum result)

Constructs a CLR instance when constructor access is allowed.

Parameters

Name Type Required Description
ctx ScriptContext Yes Active script execution context.
args Span<ScriptDatum> Yes Constructor arguments.
result ref ScriptDatum Yes Slot receiving the constructed instance.

Returns

None. The constructed instance is written to result.

Behavior

Construction requires TypeAccess.Constructor or TypeAccess.All at registration; the runtime normally calls this on new in script code.

engine.RegisterType<HostCalculator>("Calculator", TypeAccess.Constructor);

if (engine.ClrRegistry.TryGetClrType("Calculator", out var descriptor))
{
    var instance = ScriptDatum.Null;
    descriptor.Construct(context, Span<ScriptDatum>.Empty, ref instance);
}

Clone this wiki locally