Class StorageFilePickerService

Avalonia-backed implementation of IFilePickerService. Resolves the Avalonia.Platform.Storage.IStorageProvider lazily from the application's main window on each call, avoiding the chicken-and-egg problem during DI registration.

Inheritance
StorageFilePickerService
Implements
Namespace: MOSAIC.Services
Assembly: MOSAIC.dll
Syntax
public sealed class StorageFilePickerService : IFilePickerService
Remarks

Register as a parameterless singleton during DI setup — no window reference needed:

services.AddSingleton<IFilePickerService, StorageFilePickerService>();

Methods

GetStorageProvider()

Resolves the Avalonia.Platform.Storage.IStorageProvider from the current application's main window.

Declaration
private static IStorageProvider? GetStorageProvider()
Returns
Type Description
IStorageProvider

PickFolderAsync(string, string?)

Opens a folder picker and returns the selected folder's local path.

Declaration
public Task<string?> PickFolderAsync(string title, string? startIn = null)
Parameters
Type Name Description
string title

Dialog title shown to the user.

string startIn

Folder to open the picker at, or null for the default.

Returns
Type Description
Task<string>

The local folder path, or null if the user cancelled.

PickJsonFileAsync(string)

Opens a file picker filtered to JSON files and returns the selected file's local path.

Declaration
public Task<string?> PickJsonFileAsync(string title)
Parameters
Type Name Description
string title

Dialog title shown to the user.

Returns
Type Description
Task<string>

The local file path, or null if the user cancelled.

Implements

IFilePickerService

Search documentation

Start typing to search the documentation.