From 0b69c1facb0c8d32e97bbca7e6327fc8c2a362ec Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Sat, 15 Jun 2024 11:09:15 +0100 Subject: [PATCH] WIP --- Wallet.Avalonia/App.axaml.cs | 1 - Wallet/MaskedTextEntryViewModelHandler.cs | 3 ++- Wallet/MultilineTextEntryViewModelHandler.cs | 3 ++- Wallet/PasswordEntryViewModelHandler.cs | 3 ++- Wallet/PinEntryViewModelHandler.cs | 3 ++- Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs | 3 ++- Wallet/SynchronizeItemCategoryViewModelHandler.cs | 3 ++- Wallet/SynchronizeItemCollectionViewModelHandler.cs | 4 +++- .../SynchronizeItemContentFromCategoryViewModelHandler.cs | 2 +- Wallet/SynchronizeItemContentViewModelHandler.cs | 2 +- Wallet/SynchronizeMainViewModelHandler.cs | 8 +------- Wallet/TextEntryViewModelHandler.cs | 3 ++- 12 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Wallet.Avalonia/App.axaml.cs b/Wallet.Avalonia/App.axaml.cs index 4c6ce6f..76be6e6 100644 --- a/Wallet.Avalonia/App.axaml.cs +++ b/Wallet.Avalonia/App.axaml.cs @@ -59,7 +59,6 @@ public partial class App : Application } services.AddHandler(); - services.AddTransient(provider => Component.Create(provider, args => { args.AddServices(services => diff --git a/Wallet/MaskedTextEntryViewModelHandler.cs b/Wallet/MaskedTextEntryViewModelHandler.cs index 3c82331..49c783b 100644 --- a/Wallet/MaskedTextEntryViewModelHandler.cs +++ b/Wallet/MaskedTextEntryViewModelHandler.cs @@ -14,7 +14,8 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) : string? value = $"{configuration.Value}" ?? ""; double? width = configuration.Width; - if (serviceFactory.Create([.. args.Parameters, configuration, configuration.Pattern, label, value, width]) + if (serviceFactory.Create(args => args.Initialize(), + [.. args.Parameters, configuration, configuration.Pattern, label, value, width]) is MaskedTextEntryViewModel viewModel) { return Task.FromResult(viewModel); diff --git a/Wallet/MultilineTextEntryViewModelHandler.cs b/Wallet/MultilineTextEntryViewModelHandler.cs index 65789d2..6817d76 100644 --- a/Wallet/MultilineTextEntryViewModelHandler.cs +++ b/Wallet/MultilineTextEntryViewModelHandler.cs @@ -14,7 +14,8 @@ public class MultilineTextEntryViewModelHandler(IServiceFactory serviceFactory) string? value = $"{configuration.Value}" ?? ""; double? width = configuration.Width; - if (serviceFactory.Create([.. args.Parameters, configuration, label, value, width]) + if (serviceFactory.Create(args => args.Initialize(), + [.. args.Parameters, configuration, label, value, width]) is MultilineTextEntryViewModel viewModel) { return Task.FromResult(viewModel); diff --git a/Wallet/PasswordEntryViewModelHandler.cs b/Wallet/PasswordEntryViewModelHandler.cs index 2025c54..324b64d 100644 --- a/Wallet/PasswordEntryViewModelHandler.cs +++ b/Wallet/PasswordEntryViewModelHandler.cs @@ -14,7 +14,8 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) : string? value = $"{configuration.Value}" ?? ""; double? width = configuration.Width; - if (serviceFactory.Create([.. args.Parameters, configuration, label, value, width]) + if (serviceFactory.Create(args => args.Initialize(), + [.. args.Parameters, configuration, label, value, width]) is PasswordEntryViewModel viewModel) { return Task.FromResult(viewModel); diff --git a/Wallet/PinEntryViewModelHandler.cs b/Wallet/PinEntryViewModelHandler.cs index dcb4680..612350b 100644 --- a/Wallet/PinEntryViewModelHandler.cs +++ b/Wallet/PinEntryViewModelHandler.cs @@ -14,7 +14,8 @@ public class PinEntryViewModelHandler(IServiceFactory serviceFactory) : string? value = $"{configuration.Value}" ?? ""; double? width = configuration.Width; - if (serviceFactory.Create([.. args.Parameters, configuration, label, value, width]) + if (serviceFactory.Create(args => args.Initialize(), + [.. args.Parameters, configuration, label, value, width]) is PinEntryViewModel viewModel) { return Task.FromResult(viewModel); diff --git a/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs b/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs index 1fceb0c..cff3778 100644 --- a/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs +++ b/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs @@ -11,7 +11,8 @@ public class SynchronizeCategoriesNavigationViewModelHandler(IItemConfigurationC { foreach (KeyValuePair> configuration in configurations) { - if (serviceFactory.Create(configuration.Key) + if (serviceFactory.Create(args => args.Initialize(), + configuration.Key) is CategoryNavigationViewModel viewModel) { publisher.Publish(Create.As(viewModel), nameof(CategoriesNavigationViewModel)); diff --git a/Wallet/SynchronizeItemCategoryViewModelHandler.cs b/Wallet/SynchronizeItemCategoryViewModelHandler.cs index 4c8f109..088664d 100644 --- a/Wallet/SynchronizeItemCategoryViewModelHandler.cs +++ b/Wallet/SynchronizeItemCategoryViewModelHandler.cs @@ -12,7 +12,8 @@ public class SynchronizeItemCategoryViewModelHandler(IItemConfigurationCollectio bool selected = true; foreach (KeyValuePair> configuration in configurations) { - if (serviceFactory.Create(configuration.Key, selected) + if (serviceFactory.Create(args => args.Initialize(), + configuration.Key, selected) is ItemCategoryNavigationViewModel viewModel) { publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel)); diff --git a/Wallet/SynchronizeItemCollectionViewModelHandler.cs b/Wallet/SynchronizeItemCollectionViewModelHandler.cs index 2729534..ab4154d 100644 --- a/Wallet/SynchronizeItemCollectionViewModelHandler.cs +++ b/Wallet/SynchronizeItemCollectionViewModelHandler.cs @@ -29,7 +29,9 @@ public class SynchronizeItemCollectionViewModelHandler(IMediator mediator, IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService(); IDecoratorService> decoratorService = serviceScope.ServiceProvider.GetRequiredService>>(); - if (serviceFactory.Create(Id, Name, "Description", Category, selected, Favourite, Archived) is ItemNavigationViewModel viewModel) + if (serviceFactory.Create(args => args.Initialize(), + Id, Name, "Description", Category, selected, Favourite, Archived) + is ItemNavigationViewModel viewModel) { Item<(Guid, string)> item = new((Id, Name)); diff --git a/Wallet/SynchronizeItemContentFromCategoryViewModelHandler.cs b/Wallet/SynchronizeItemContentFromCategoryViewModelHandler.cs index edbb999..49bc4bf 100644 --- a/Wallet/SynchronizeItemContentFromCategoryViewModelHandler.cs +++ b/Wallet/SynchronizeItemContentFromCategoryViewModelHandler.cs @@ -22,7 +22,7 @@ public class SynchronizeItemContentFromCategoryViewModelHandler(IItemConfigurati foreach (ItemSectionConfiguration configurationSection in configuration.Sections) { string id = $"{nameof(ItemSection)}:{Guid.NewGuid()}"; - if (serviceFactory.Create(id) + if (serviceFactory.Create(args => args.Initialize(), id) is ItemSectionViewModel sectionViewModel) { publisher.Publish(Create.As(sectionViewModel), nameof(ItemContentViewModel)); diff --git a/Wallet/SynchronizeItemContentViewModelHandler.cs b/Wallet/SynchronizeItemContentViewModelHandler.cs index 192382e..5b725a7 100644 --- a/Wallet/SynchronizeItemContentViewModelHandler.cs +++ b/Wallet/SynchronizeItemContentViewModelHandler.cs @@ -25,7 +25,7 @@ public class SynchronizeItemContentViewModelHandler(IDecoratorService(id) + if (serviceFactory.Create(args => args.Initialize(), id) is ItemSectionViewModel sectionViewModel) { publisher.Publish(Create.As(sectionViewModel), nameof(ItemContentViewModel)); diff --git a/Wallet/SynchronizeMainViewModelHandler.cs b/Wallet/SynchronizeMainViewModelHandler.cs index 170e6bb..4fcc87f 100644 --- a/Wallet/SynchronizeMainViewModelHandler.cs +++ b/Wallet/SynchronizeMainViewModelHandler.cs @@ -19,13 +19,7 @@ public class SynchronizeMainViewModelHandler(IPublisher publisher, { if (Wallet.Services.GetRequiredService() is IServiceFactory factory) { - if (factory.Create(args => - { - if (args is IPostInitialization initialization) - { - initialization.PostInitialize(); - } - }, descriptor.Name, selected) + if (factory.Create(args => args.Initialize(), descriptor.Name, selected) is WalletNavigationViewModel viewModel) { publisher.Publish(Create.As(viewModel), diff --git a/Wallet/TextEntryViewModelHandler.cs b/Wallet/TextEntryViewModelHandler.cs index e87752d..2eb8731 100644 --- a/Wallet/TextEntryViewModelHandler.cs +++ b/Wallet/TextEntryViewModelHandler.cs @@ -14,7 +14,8 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) : string? value = $"{configuration.Value}" ?? ""; double? width = configuration.Width; - if (serviceFactory.Create([.. args.Parameters, configuration, label, value, width]) + if (serviceFactory.Create(args => args.Initialize(), + [.. args.Parameters, configuration, label, value, width]) is TextEntryViewModel viewModel) { return Task.FromResult(viewModel);