swiftlys2/docs/api/ai/
API Reference › Extensions

IExtensionService

Interface
Namespace: SwiftlyS2.Shared.Extensions · Assembly: SwiftlyS2.CS2.dll
public interface IExtensionService

Manages native extensions and their shared pointer registry.

View source

Methods

GetSharedPointer(string)

Gets a shared pointer, or zero if the key does not exist. Use HasSharedPointer to distinguish a stored zero from a missing key.

nint GetSharedPointer(string key)
Parameters
Returns

HasSharedPointer(string)

Checks whether a shared pointer key exists, including keys with zero values.

bool HasSharedPointer(string key)
Parameters
Returns

Load(string)

Loads an extension from extensions/{id}/{id}.dll or .so.

bool Load(string id)
Parameters
Returns
Whether the extension was loaded successfully.

LoadFromPath(string)

Loads an extension from an absolute path to its library. The extension ID is the library filename without its extension.

bool LoadFromPath(string absolutePath)
Parameters
Returns
Whether the extension was loaded successfully.
Exceptions

RemoveSharedPointer(string)

Removes a shared pointer key without freeing the pointed-to object. Missing keys are ignored.

void RemoveSharedPointer(string key)
Parameters

SetSharedPointer(string, nint)

Inserts or replaces a shared pointer. The value can be zero. The registry does not own the pointed-to object or free replaced values.

void SetSharedPointer(string key, nint pointer)
Parameters

Unload(string)

Unloads an extension and invokes its registered unload callback.

bool Unload(string id)
Parameters
Returns
Whether the extension was unloaded successfully.

UnloadFromPath(string)

Unloads an extension by the absolute path to its library.

bool UnloadFromPath(string absolutePath)
Parameters
Returns
Whether the extension was unloaded successfully.
Exceptions