Files
Walleby/Wallet/CommentEntryCollectionViewModelHandler.cs
T
TheXamlGuy f4f9fdac46 WIP
2024-07-13 21:35:58 +01:00

31 lines
1.1 KiB
C#

using Toolkit.Foundation;
namespace Wallet;
public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFactory) :
IHandler<CreateEventArgs<CommentEntryCollectionConfiguration>, IItemEntryViewModel?>
{
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<CommentEntryCollectionConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Sender is CommentEntryCollectionConfiguration configuration)
{
string? label = configuration.Label;
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, false, false, width])
is CommentEntryCollectionViewModel viewModel)
{
viewModel.Add<CreateCommentEntryViewModel>();
return Task.FromResult<IItemEntryViewModel?>(viewModel);
}
}
return Task.FromResult<IItemEntryViewModel?>(default);
}
}