Added SelectFilesHandler

This commit is contained in:
TheXamlGuy
2024-09-29 19:15:00 +01:00
parent 39f4e28f29
commit e321da7035
3 changed files with 23 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
namespace Toolkit.Foundation;
public class SelectFilesHandler(IFileProvider fileProvider) :
IHandler<SelectionEventArgs<FileFilter>, IReadOnlyCollection<string>?>
{
public async Task<IReadOnlyCollection<string>?> Handle(SelectionEventArgs<FileFilter> args,
CancellationToken cancellationToken)
{
if (args.Sender is FileFilter filter)
{
if (await fileProvider.SelectFiles(filter)
is { Count: > 0 } files)
{
return files;
}
}
return default;
}
}
@@ -1,5 +1,6 @@
namespace Toolkit.Foundation;
public class SelectFoldersHandler(IFolderProvider folderProvider) :
IHandler<SelectionEventArgs<FolderFilter>, IReadOnlyCollection<string>?>
{