ExtensionHost Class#
Discovers, validates, loads, and manages the lifecycle of all Verso extensions. Implements IExtensionHostContext for read-only querying and System.IAsyncDisposable for teardown.
public sealed class ExtensionHost : Verso.Abstractions.IExtensionHostContext, System.IAsyncDisposable
Inheritance System.Object → ExtensionHost
Implements IExtensionHostContext, System.IAsyncDisposable
Properties#
ConsentHandler Property#
Optional consent handler set by the hosting layer (ServerNotebookService, HostSession). When set, overrides the default auto-approve behavior for extension consent requests.
public System.Func<System.Collections.Generic.IReadOnlyList<Verso.Abstractions.ExtensionConsentInfo>,System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>>? ConsentHandler { get; set; }
Property Value#
System.Func<System.Collections.Generic.IReadOnlyList<ExtensionConsentInfo>,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>>
UnavailableExtensionsHandler Property#
Optional handler set by the hosting layer to surface required extensions that could not be loaded on open (offline, package missing, consent declined). Lets the host show a non-fatal notice instead of failing the open or silently swallowing the failure.
public System.Func<System.Collections.Generic.IReadOnlyList<Verso.Abstractions.UnavailableExtensionInfo>,System.Threading.Tasks.Task>? UnavailableExtensionsHandler { get; set; }
Property Value#
System.Func<System.Collections.Generic.IReadOnlyList<UnavailableExtensionInfo>,System.Threading.Tasks.Task>
Methods#
AttributeExtensionsToPackage(string, IReadOnlyList<string>) Method#
Records the extensions a package registered as its assemblies were loaded. A package's assemblies load one at a time, so repeated calls accumulate rather than replace.
public void AttributeExtensionsToPackage(string packageId, System.Collections.Generic.IReadOnlyList<string> extensionIds);
Parameters#
packageId System.String
extensionIds System.Collections.Generic.IReadOnlyList<System.String>
GetInteractionHandler(string) Method#
Finds the first enabled ICellInteractionHandler whose owning extension matches the specified extension ID (case-insensitive).
public Verso.Abstractions.ICellInteractionHandler? GetInteractionHandler(string extensionId);
Parameters#
extensionId System.String
The extension ID to look up.
Returns#
ICellInteractionHandler
The matching handler, or null if not found or disabled.
GetPackageCapabilities(string) Method#
The distinct capabilities a package contributed, in the order its extensions declare
them. Returns null when nothing is recorded for the package, which means it has
not loaded in this session; an empty list means it loaded and registered no extension
point at all. A caller that conflates the two would claim a package adds nothing when
the truth is that nobody has looked yet.
public System.Collections.Generic.IReadOnlyList<string>? GetPackageCapabilities(string packageId);
Parameters#
packageId System.String
Returns#
System.Collections.Generic.IReadOnlyList<System.String>
LoadBuiltInExtensionsAsync() Method#
Scans the Verso assembly and any co-located assemblies that reference
Verso.Abstractions for types marked with VersoExtensionAttribute,
instantiates them, validates, and auto-registers by capability interface.
Extension assemblies are loaded into the default assembly context so their types
share identity with the host.
public System.Threading.Tasks.Task LoadBuiltInExtensionsAsync();
Returns#
LoadExtensionAsync(IExtension) Method#
Loads a single extension instance. Validates, calls OnLoadedAsync(IExtensionHostContext), and auto-registers by implemented capability interfaces.
public System.Threading.Tasks.Task LoadExtensionAsync(Verso.Abstractions.IExtension extension);
Parameters#
extension IExtension
The extension instance to load.
Returns#
LoadFromAssemblyAsync(string) Method#
Loads extensions from a single assembly using an isolated Verso.Extensions.ExtensionLoadContext.
public System.Threading.Tasks.Task LoadFromAssemblyAsync(string path);
Parameters#
path System.String
Full path to the extension assembly (.dll).
Returns#
LoadFromDirectoryAsync(string) Method#
Scans all .dll files in the specified directory, loading each in an isolated context.
public System.Threading.Tasks.Task LoadFromDirectoryAsync(string path);
Parameters#
path System.String
Directory containing extension assemblies.
Returns#
ReportUnavailableExtensionsAsync(IReadOnlyList<UnavailableExtensionInfo>) Method#
Reports required extensions that could not be loaded, delegating to UnavailableExtensionsHandler if set.
public System.Threading.Tasks.Task ReportUnavailableExtensionsAsync(System.Collections.Generic.IReadOnlyList<Verso.Abstractions.UnavailableExtensionInfo> unavailable);
Parameters#
unavailable System.Collections.Generic.IReadOnlyList<UnavailableExtensionInfo>
Returns#
RequestExtensionConsentAsync(IReadOnlyList<ExtensionConsentInfo>, CancellationToken) Method#
Requests user consent, delegating to ConsentHandler if set.
public System.Threading.Tasks.Task<bool> RequestExtensionConsentAsync(System.Collections.Generic.IReadOnlyList<Verso.Abstractions.ExtensionConsentInfo> extensions, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters#
extensions System.Collections.Generic.IReadOnlyList<ExtensionConsentInfo>
cancellationToken System.Threading.CancellationToken
Implements RequestExtensionConsentAsync(IReadOnlyList<ExtensionConsentInfo>, CancellationToken)
Returns#
System.Threading.Tasks.Task<System.Boolean>
TryGetLayoutEngine(string, string, ILayoutEngine) Method#
Looks up an enabled ILayoutEngine by its (ExtensionId, LayoutId)
identity pair.
public bool TryGetLayoutEngine(string extensionId, string layoutId, out Verso.Abstractions.ILayoutEngine engine);
Parameters#
extensionId System.String
The owning extension's id.
layoutId System.String
The layout id the engine services.
engine ILayoutEngine
The matching engine when found and enabled.
Returns#
System.Boolean
true when a matching enabled engine exists.
TryGetLayoutInteractionHandler(string, string, ILayoutInteractionHandler) Method#
Looks up an enabled ILayoutInteractionHandler by its
(ExtensionId, LayoutId) identity pair.
public bool TryGetLayoutInteractionHandler(string extensionId, string layoutId, out Verso.Abstractions.ILayoutInteractionHandler handler);
Parameters#
extensionId System.String
The owning extension's id.
layoutId System.String
The layout id the handler services.
handler ILayoutInteractionHandler
The matching handler when found and enabled.
Returns#
System.Boolean
true when a matching enabled handler exists.
TryGetLayoutLifecycleHandler(string, string, ILayoutLifecycleHandler) Method#
Looks up an enabled ILayoutLifecycleHandler by its
(ExtensionId, LayoutId) identity pair.
public bool TryGetLayoutLifecycleHandler(string extensionId, string layoutId, out Verso.Abstractions.ILayoutLifecycleHandler handler);
Parameters#
extensionId System.String
The owning extension's id.
layoutId System.String
The layout id the handler services.
handler ILayoutLifecycleHandler
The matching handler when found and enabled.
Returns#
System.Boolean
true when a matching enabled handler exists.
TryGetPanel(string, string, INotebookPanel) Method#
Looks up an enabled INotebookPanel by its
(ExtensionId, PanelId) identity pair.
public bool TryGetPanel(string extensionId, string panelId, out Verso.Abstractions.INotebookPanel panel);
Parameters#
extensionId System.String
The owning extension's id.
panelId System.String
The panel id.
panel INotebookPanel
The matching panel when found and enabled.
Returns#
System.Boolean
true when a matching enabled panel exists.
TryGetPanelInteractionHandler(string, string, IPanelInteractionHandler) Method#
Looks up an enabled IPanelInteractionHandler by its
(ExtensionId, PanelId) identity pair.
public bool TryGetPanelInteractionHandler(string extensionId, string panelId, out Verso.Abstractions.IPanelInteractionHandler handler);
Parameters#
extensionId System.String
The owning extension's id.
panelId System.String
The panel id the handler services.
handler IPanelInteractionHandler
The matching handler when found and enabled.
Returns#
System.Boolean
true when a matching enabled handler exists.
UnloadAllAsync() Method#
Unloads all extensions in reverse load order: calls OnUnloadedAsync(), disposes System.IAsyncDisposable extensions, then unloads isolated contexts.
public System.Threading.Tasks.Task UnloadAllAsync();
Returns#
ValidateExtension(IExtension) Method#
Validates an extension against all rules. Returns an empty list if valid.
public System.Collections.Generic.IReadOnlyList<Verso.Extensions.ExtensionValidationError> ValidateExtension(Verso.Abstractions.IExtension extension);
Parameters#
extension IExtension
Returns#
System.Collections.Generic.IReadOnlyList<ExtensionValidationError>
Events#
OnExtensionLoaded Event#
Raised after a new extension is loaded and auto-registered.
public event Action<IExtension>? OnExtensionLoaded;
Event Type#
OnExtensionStatusChanged Event#
Raised when an extension is enabled or disabled.
public event Action<string,ExtensionStatus>? OnExtensionStatusChanged;