Interface IAvaloniaUi
- Namespace
- VpnHood.AppHosting.Avalonia
- Assembly
- VpnHood.AppHosting.Avalonia.dll
Defines a UI a head can run: the head names it as a type argument.
public interface IAvaloniaUi
Remarks
The members are static, as the first of them runs before Avalonia starts, when there is no instance of the UI yet. A host runs them in this order, all before the UI's first view: InitAsync(VpnHoodApi, CancellationToken), PrepareContentAsync(IAssetProvider, CancellationToken), then ConfigureAsync(CancellationToken). A host with no app to give the UI, as a desktop's message window, runs PrepareContentAsync(IAssetProvider, CancellationToken) alone.
Methods
ConfigureAsync(CancellationToken)
Configures the app for the UI once its content is prepared: tells the app which languages the UI has words for, so its language list and its choice of culture come from the words that exist, and gives the app the UI's words for its own text, again whenever the UI's language changes.
public static abstract Task ConfigureAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
InitAsync(VpnHoodApi, CancellationToken)
Gives the UI the app's API, which the UI reads the app's information through: before Avalonia starts, as the features decide the theme.
public static abstract Task InitAsync(VpnHoodApi api, CancellationToken cancellationToken)
Parameters
apiVpnHoodApiThe app's API: the app's own in process, or the same six interfaces over HTTP from a browser page.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
PrepareContentAsync(IAssetProvider, CancellationToken)
Puts in place what the UI needs before its first view, its words and the fonts its styles name, from the content store the head hands in. It needs no app.
public static abstract Task PrepareContentAsync(IAssetProvider assets, CancellationToken cancellationToken)
Parameters
assetsIAssetProviderThe UI's content store: a folder in process, or the app's web host from a browser page.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.