-
Notifications
You must be signed in to change notification settings - Fork 0
API Host ClrTypeRegistry
Host-side registry mapping script-visible aliases to CLR types.
Namespace: AuroraScript.Runtime.Interop. Kind: class.
Back to .NET Host API Reference
ClrTypeRegistry maps script aliases to CLR types. Registration grants capability to scripts, so register reviewed types only and expose the smallest suitable TypeAccess.
An engine owns one registry, reachable as AuroraEngine.ClrRegistry. AuroraEngine.RegisterType is a shortcut over the same registry.
Warning
A registered alias is a capability handed to every script the engine runs. Prefer TypeAccess.Constructor or TypeAccess.Static over TypeAccess.All when the script only needs one of them.
A minimal use of ClrTypeRegistry.
engine.ClrRegistry.RegisterType(typeof(HostCalculator), "Calculator", TypeAccess.All);void RegisterType(Type type, string alias, TypeAccess access)Registers a CLR type under a script-visible alias.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type |
Type |
Yes | CLR type to expose. |
alias |
string |
Yes | Script-visible alias. |
access |
TypeAccess |
Yes | Allowed constructor and static-member access. |
Returns
None.
engine.ClrRegistry.RegisterType(typeof(HostCalculator), "Calculator", TypeAccess.All);bool UnregisterType(string alias)Removes a registration by alias.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
alias |
string |
Yes | Script alias to remove. |
Returns
true when a registration was removed; otherwise false.
var removed = engine.ClrRegistry.UnregisterType("Calculator");bool TryGetClrType(string alias, out ClrType descriptor)Looks up the descriptor registered for an alias.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
alias |
string |
Yes | Script alias to look up. |
descriptor |
out ClrType |
Yes | Receives the ClrType descriptor. |
Returns
true when a registration exists; otherwise false.
if (engine.ClrRegistry.TryGetClrType("Calculator", out var descriptor))
{
Console.WriteLine(descriptor);
}void Dispose()Releases registry-lifetime resources.
Parameters
None.
Returns
None.
Behavior
The registry is normally managed with the owning engine's lifetime; dispose it explicitly only when the host owns the registry directly.
engine.ClrRegistry.Dispose();TypeAccess selects which members an alias exposes. Instance members are available only from successfully constructed or host-injected instances.
| Value | Exposes |
|---|---|
Constructor |
Constructors only. |
Static |
Static members only. |
All |
Constructors and static members. |
engine.RegisterType<HostCalculator>("Calculator", TypeAccess.Constructor);
engine.RegisterType<HostMath>("HostMath", TypeAccess.Static);
engine.RegisterType<HostCalculator>("Calculator", TypeAccess.All);AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License