This commit is contained in:
TheXamlGuy
2024-07-17 21:43:58 +01:00
parent eae11dc260
commit 9daebc7ba2
124 changed files with 233 additions and 247 deletions
+1 -2
View File
@@ -24,11 +24,10 @@ public class ArchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decorato
cache.Remove(item);
publisher.Publish(Changed.As<Item>());
}
}
}
}
catch
{
}
}
}
+1 -1
View File
@@ -14,4 +14,4 @@ public partial class AttachmentEntryCollectionViewModel(IServiceProvider provide
ICollection<Comment> value,
bool isConcealed,
bool isRevealed,
double width) : ItemEntryCollectionViewModel<AttachmentEntryViewModel, ICollection<Comment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
double width) : ItemEntryCollectionViewModel<AttachmentEntryViewModel, ICollection<Comment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
@@ -25,4 +25,4 @@ public class CategoriesNavigationViewModelActivationHandler(IMediator mediator,
}
}
}
}
}
+2 -2
View File
@@ -5,10 +5,10 @@ namespace Wallet;
public class CloseWalletHandler(IDecoratorService<WalletConnection> walletConnectionDecorator) :
IHandler<CloseEventArgs<Wallet>, bool>
{
public Task<bool> Handle(CloseEventArgs<Wallet> args,
public Task<bool> Handle(CloseEventArgs<Wallet> args,
CancellationToken cancellationToken)
{
walletConnectionDecorator.Set(null);
return Task.FromResult(true);
}
}
}
+1 -3
View File
@@ -1,6 +1,4 @@
using Toolkit.Foundation;
namespace Wallet;
namespace Wallet;
public record Closed
{
+1 -1
View File
@@ -5,4 +5,4 @@ public record Comment
public DateTimeOffset DateTime { get; set; }
public string? Text { get; set; }
}
}
+5 -3
View File
@@ -39,8 +39,10 @@ public partial class CommentEntryCollectionViewModel(IServiceProvider provider,
}
else
{
RemoveAt(Count - 1);
if (Count > 0)
{
RemoveAt(Count - 1);
}
}
}
}
}
@@ -14,7 +14,7 @@ public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFacto
List<Comment> values = configuration.Value is not null ? new List<Comment>(configuration.Value) : [];
double? width = configuration.Width;
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, values, false, false, width])
is CommentEntryCollectionViewModel viewModel)
{
@@ -29,5 +29,4 @@ public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFacto
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+2 -2
View File
@@ -20,7 +20,7 @@ public class ConfirmCreateItemHandler(IMediator mediator,
Guid id = Guid.NewGuid();
await mediator.Handle<CreateEventArgs<(Guid, string, string, IImageDescriptor?,
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, IImageDescriptor?,
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, IImageDescriptor?,
ItemConfiguration)>((id, name, category, imageDescriptor ?? default, itemConfiguration)));
Item<(Guid, string, string)> item = new((id, name, category));
@@ -30,4 +30,4 @@ public class ConfirmCreateItemHandler(IMediator mediator,
}
}
}
}
}
+2 -2
View File
@@ -25,9 +25,9 @@ public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> it
(Guid id, _) = item.Value;
await mediator.Handle<UpdateEventArgs<Item<(Guid, string, string, IImageDescriptor?,
await mediator.Handle<UpdateEventArgs<Item<(Guid, string, string, IImageDescriptor?,
ItemConfiguration)>>, bool>(new UpdateEventArgs<Item<(Guid, string, string, IImageDescriptor?,
ItemConfiguration)>>(new Item<(Guid, string, string, IImageDescriptor?, ItemConfiguration)>((id,
ItemConfiguration)>>(new Item<(Guid, string, string, IImageDescriptor?, ItemConfiguration)>((id,
name, category, imageDescriptor, itemConfiguration))));
Item<(Guid, string)> newItem = new((id, name));
+3 -3
View File
@@ -4,10 +4,10 @@ using Wallet.Data;
namespace Wallet;
public class CountCategoriesHandler(IDbContextFactory<WalletContext> dbContextFactory) :
public class CountCategoriesHandler(IDbContextFactory<WalletContext> dbContextFactory) :
IHandler<CountEventArgs<Item>, IReadOnlyCollection<(string, int)>>
{
public async Task<IReadOnlyCollection<(string, int)>> Handle(CountEventArgs<Item> args,
public async Task<IReadOnlyCollection<(string, int)>> Handle(CountEventArgs<Item> args,
CancellationToken cancellationToken)
{
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
@@ -49,4 +49,4 @@ public class CountCategoriesHandler(IDbContextFactory<WalletContext> dbContextFa
return combinedCounts;
}
}
}
+3 -3
View File
@@ -1,9 +1,9 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System.Text;
using System.Text.Json;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
@@ -15,7 +15,7 @@ public class CreateItemHandler(IImageWriter imageWriter,
CancellationToken cancellationToken)
{
(Guid id, string name, string category, IImageDescriptor? imageDescriptor, ItemConfiguration configuration) = args.Sender;
try
{
string content = JsonSerializer.Serialize(configuration);
+3 -3
View File
@@ -2,8 +2,8 @@
namespace Wallet;
public class CreateProfileImageHandler(IFileProvider fileProvider,
IImageReader imageReader) :
public class CreateProfileImageHandler(IFileProvider fileProvider,
IImageReader imageReader) :
IHandler<CreateEventArgs<ProfileImage>, IImageDescriptor?>
{
public async Task<IImageDescriptor?> Handle(CreateEventArgs<ProfileImage> args,
@@ -21,4 +21,4 @@ public class CreateProfileImageHandler(IFileProvider fileProvider,
return default;
}
}
}
+1 -1
View File
@@ -14,4 +14,4 @@ public partial class DateEntryViewModel(IServiceProvider provider,
DateTimeOffset? value,
bool isConcealed,
bool isRevealed,
double width) : ItemEntryViewModel<DateTimeOffset?>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
double width) : ItemEntryViewModel<DateTimeOffset?>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
+1 -1
View File
@@ -15,7 +15,7 @@ public class DateEntryViewModelHandler(IServiceFactory serviceFactory) :
DateTimeOffset? value = configuration.Value is not null ? configuration.Value : DateTimeOffset.Now;
double? width = configuration.Width;
if (serviceFactory.Create<DateEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<DateEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, false, false, width])
is DateEntryViewModel viewModel)
{
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Wallet;
public partial class DigitRule :
public partial class DigitRule :
IPasswordRule
{
public int CalculateScore(string password) =>
@@ -10,4 +10,4 @@ public partial class DigitRule :
[GeneratedRegex(@"\d")]
private static partial Regex Regex();
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Wallet;
public partial class DiversityBonusRule :
public partial class DiversityBonusRule :
IPasswordRule
{
public int CalculateScore(string password)
@@ -7,4 +7,4 @@ public record DropdownEntryCollectionConfiguration :
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public IList<string> Values { get; set; } = new List<string>();
}
}
+4 -4
View File
@@ -2,18 +2,18 @@
namespace Wallet;
public partial class DropdownEntryCollectionViewModel :
public partial class DropdownEntryCollectionViewModel :
ItemEntryCollectionViewModel<DropdownEntryViewModel, object>
{
public DropdownEntryCollectionViewModel(IServiceProvider provider,
IServiceFactory factory,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
IDisposer disposer,
IDisposer disposer,
IEnumerable<DropdownEntryViewModel> items,
ItemState state,
DropdownEntryCollectionConfiguration configuration,
DropdownEntryCollectionConfiguration configuration,
string key,
object value,
bool isConcealed,
@@ -34,4 +34,4 @@ public class DropdownEntryCollectionViewModelHandler(IServiceFactory serviceFact
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+2 -2
View File
@@ -7,5 +7,5 @@ public partial class DropdownEntryViewModel(IServiceProvider provider,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
IDisposer disposer,
string? value = default) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
IDisposer disposer,
string? value = default) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
+4 -4
View File
@@ -4,13 +4,13 @@ using Toolkit.Foundation;
namespace Wallet;
public partial class EmptyItemCollectionViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
ISubscriber subscriber,
IDisposer disposer,
NamedComponent named) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
{
[ObservableProperty]
private string named = $"{named}";
}
}
+2 -2
View File
@@ -11,7 +11,7 @@ public abstract partial class FilterNavigationViewModel(IServiceProvider provide
ISubscriber subscriber,
IDisposer disposer,
int key,
string value) :
string value) :
ObservableCollection<INavigationViewModel, int, string>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
INavigationViewModel,
INotificationHandler<ActivatedEventArgs<Wallet>>,
@@ -74,7 +74,7 @@ public abstract partial class FilterNavigationViewModel<TWalletNavigation>(IServ
public Task Handle(DeactivatedEventArgs<Wallet> args)
{
IsSelected = false;
IsActivated = false;
IsActivated = false;
return Task.CompletedTask;
}
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Wallet;
public record Hyperlink(string? Value);
public record Hyperlink(string? Value);
+2 -2
View File
@@ -14,7 +14,7 @@ public class HyperlinkEntryViewModelHandler(IServiceFactory serviceFactory) :
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<HyperlinkEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<HyperlinkEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, false, false, width])
is HyperlinkEntryViewModel viewModel)
{
@@ -24,4 +24,4 @@ public class HyperlinkEntryViewModelHandler(IServiceFactory serviceFactory) :
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+2 -3
View File
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
namespace Wallet;
public class HyperlinkHandler :
public class HyperlinkHandler :
INotificationHandler<CreateEventArgs<Hyperlink>>
{
public Task Handle(CreateEventArgs<Hyperlink> args)
@@ -16,10 +16,9 @@ public class HyperlinkHandler :
}
catch
{
}
}
return Task.CompletedTask;
}
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Wallet;
public interface ICommentEntryViewModel : IItemEntryViewModel;
public interface ICommentEntryViewModel : IItemEntryViewModel;
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Wallet;
public interface IItemConfigurationCollection :
IReadOnlyDictionary<string, Func<ItemConfiguration>>;
IReadOnlyDictionary<string, Func<ItemConfiguration>>;
+1 -1
View File
@@ -34,4 +34,4 @@ public interface IItemEntryConfiguration<TValue> :
[JsonDerivedType(typeof(DateEntryConfiguration), typeDiscriminator: "Date")]
[JsonDerivedType(typeof(HyperlinkEntryConfiguration), typeDiscriminator: "Hyperlink")]
[JsonDerivedType(typeof(PinEntryConfiguration), typeDiscriminator: "Pin")]
public interface IItemEntryConfiguration;
public interface IItemEntryConfiguration;
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Wallet;
public interface IItemViewModel :
public interface IItemViewModel :
IDisposable;
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Wallet;
public interface INavigationViewModel :
public interface INavigationViewModel :
IDisposable;
+1 -1
View File
@@ -3,4 +3,4 @@
public interface IPasswordRule
{
int CalculateScore(string password);
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
namespace Wallet
namespace Wallet
{
public interface IWalletConnectionFactory
{
+2 -2
View File
@@ -4,7 +4,7 @@ namespace Wallet;
public interface IWalletFactory
{
Task<bool> Create(string name,
Task<bool> Create(string name,
string password,
IImageDescriptor? imageDescriptor);
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Wallet;
public record ImageEntryConfiguration :
ItemEntryConfiguration<string>;
ItemEntryConfiguration<string>;
@@ -25,4 +25,4 @@ public partial class ItemCategoryNavigationCollectionViewModel(IServiceProvider
return base.OnActivated();
}
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ public partial class ItemCategoryNavigationViewModel(IServiceProvider provider,
[RelayCommand]
private void Invoke() => Publisher.Publish(Notify.As(new ItemCategory<string>(Name)));
}
}
@@ -12,7 +12,7 @@ public class ItemCategoryViewModelActivatedHandler(IItemConfigurationCollection
bool selected = true;
foreach (KeyValuePair<string, Func<ItemConfiguration>> configuration in configurations)
{
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(args => args.Initialize(),
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(args => args.Initialize(),
configuration.Key, selected)
is ItemCategoryNavigationViewModel viewModel)
{
@@ -23,4 +23,4 @@ public class ItemCategoryViewModelActivatedHandler(IItemConfigurationCollection
return Task.CompletedTask;
}
}
}
+4 -4
View File
@@ -3,15 +3,15 @@
namespace Wallet;
public class ItemChangedHandler(IMediator mediator,
IPublisher publisher) :
IPublisher publisher) :
INotificationHandler<ChangedEventArgs<Item>>
{
public async Task Handle(ChangedEventArgs<Item> args)
{
IReadOnlyCollection<(string, int)>? counts = await mediator.Handle<CountEventArgs<Item>,
IReadOnlyCollection<(string, int)>? counts = await mediator.Handle<CountEventArgs<Item>,
IReadOnlyCollection<(string, int)>>(Count.As<Item>());
if (counts is { Count: > 0 } )
if (counts is { Count: > 0 })
{
foreach ((string key, int count) in counts)
{
@@ -19,4 +19,4 @@ public class ItemChangedHandler(IMediator mediator,
}
}
}
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
namespace Wallet;
public class ItemCommandHeaderCollection(IList<IDisposable> list) :
ReadOnlyCollection<IDisposable>(list);
ReadOnlyCollection<IDisposable>(list);
+1 -1
View File
@@ -26,7 +26,7 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
}
});
}
return Task.CompletedTask;
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ public record ItemConfiguration
Label = "Name on account"
},
new DropdownEntryCollectionConfiguration
{
{
Label = "Type",
Values = [
"Checking Account",
+2 -2
View File
@@ -2,6 +2,6 @@
namespace Wallet;
public class ItemConfigurationCollection(IDictionary<string, Func<ItemConfiguration>> dictionary) :
public class ItemConfigurationCollection(IDictionary<string, Func<ItemConfiguration>> dictionary) :
ReadOnlyDictionary<string, Func<ItemConfiguration>>(dictionary),
IItemConfigurationCollection;
IItemConfigurationCollection;
@@ -46,4 +46,4 @@ public class ItemContentFromCategoryViewModelActivationHandler(IItemConfiguratio
}
}
}
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ public partial class ItemContentViewModel(IServiceProvider provider,
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
{
if (args.Sender is ItemCategory<string> category
if (args.Sender is ItemCategory<string> category
&& category.Value is string value)
{
Activate(() => new ActivationBuilder(new ActivationEventArgs<IItemEntryViewModel,
@@ -27,4 +27,4 @@ public partial class ItemContentViewModel(IServiceProvider provider,
return Task.CompletedTask;
}
}
}
@@ -16,7 +16,7 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
{
if (item.Value is (Guid Id, _))
{
(_, _, _, _, ItemConfiguration? configuration) = await mediator.Handle<RequestEventArgs<Item<Guid>>,
(_, _, _, _, ItemConfiguration? configuration) = await mediator.Handle<RequestEventArgs<Item<Guid>>,
(Guid, string, string?, string, ItemConfiguration?)>(Request.As(new Item<Guid>(Id)));
if (configuration is not null)
@@ -49,4 +49,4 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
}
}
}
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ public class ItemCreatedHandler(IServiceProvider serviceProvider,
int index = cache.IndexOf(cachedItem);
decoratorService.Set(cachedItem);
publisher.Publish(Insert.As(index, viewModel),
publisher.Publish(Insert.As(index, viewModel),
nameof(ItemNavigationCollectionViewModel));
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Wallet;
public record ItemEntry;
public record ItemEntry;
+1 -2
View File
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
namespace Wallet;
public partial class ItemEntryCollectionViewModel<TItem, TValue> :
public partial class ItemEntryCollectionViewModel<TItem, TValue> :
ObservableCollection<TItem, string, TValue>,
IItemEntryViewModel,
IHandler<ValidateEventArgs<ItemEntry>, bool>,
@@ -97,7 +97,6 @@ public partial class ItemEntryCollectionViewModel<TItem, TValue> :
protected virtual void OnStateChanged()
{
}
public Task Handle(ConfirmEventArgs<Item> args)
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Wallet;
[JsonDerivedType(typeof(DateEntryConfiguration), typeDiscriminator: "Date")]
[JsonDerivedType(typeof(HyperlinkEntryConfiguration), typeDiscriminator: "Hyperlink")]
[JsonDerivedType(typeof(PinEntryConfiguration), typeDiscriminator: "Pin")]
public record ItemEntryConfiguration<TValue> :
public record ItemEntryConfiguration<TValue> :
IItemEntryConfiguration<TValue>
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
+5 -6
View File
@@ -1,14 +1,14 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
public class ItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
public class ItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
IHandler<RequestEventArgs<Item<Guid>>, (Guid, string, string?, string, ItemConfiguration?)>
{
public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs<Item<Guid>> args,
public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs<Item<Guid>> args,
CancellationToken cancellationToken)
{
if (args.Sender is Item<Guid> item)
@@ -43,7 +43,6 @@ public class ItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
}
catch
{
}
}
@@ -53,4 +52,4 @@ public class ItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
return default;
}
}
}
+1 -1
View File
@@ -2,4 +2,4 @@
public record ItemHeader<TValue>(TValue Value);
public record ItemHeader;
public record ItemHeader;
+3 -3
View File
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
namespace Wallet;
public partial class ItemHeaderViewModel :
public partial class ItemHeaderViewModel :
Observable<string>,
IHandler<ValidateEventArgs<ItemEntry>, bool>,
INotificationHandler<UpdateEventArgs<ItemEntry>>,
@@ -110,7 +110,7 @@ public partial class ItemHeaderViewModel :
private async Task Import() => ImageDescriptor = await Mediator.Handle<CreateEventArgs<ProfileImage>,
IImageDescriptor>(Create.As<ProfileImage>());
partial void OnImageDescriptorChanged(IImageDescriptor? value)
private partial void OnImageDescriptorChanged(IImageDescriptor? value)
{
if (configuration is not null)
{
@@ -118,7 +118,7 @@ public partial class ItemHeaderViewModel :
}
}
partial void OnImageDescriptorChanged(IImageDescriptor? oldValue,
private partial void OnImageDescriptorChanged(IImageDescriptor? oldValue,
IImageDescriptor? newValue)
{
if (configuration is not null)
+4 -4
View File
@@ -1,6 +1,6 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
@@ -24,7 +24,7 @@ public class ItemImageHandler(IDbContextFactory<WalletContext> dbContextFactory,
})
.FirstOrDefaultAsync(cancellationToken);
if (result is not null &&
if (result is not null &&
result.Image is BlobEntity image &&
image.Data is { Length: > 0 } data)
{
@@ -35,4 +35,4 @@ public class ItemImageHandler(IDbContextFactory<WalletContext> dbContextFactory,
return default;
}
}
}
+1 -1
View File
@@ -71,4 +71,4 @@ public partial class ItemNavigationCollectionViewModel :
protected override ActivationBuilder ActivationBuilder() =>
new(Activation.As<ItemNavigationViewModel, ItemNavigationCollectionConfiguration>(configuration));
}
}
@@ -17,7 +17,7 @@ public class ItemNavigationCollectionViewModelActivatedHandler(IMediator mediato
cache.Clear();
bool selected = true;
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>? results =
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>? results =
await mediator.Handle<QueryEventArgs<Wallet<(string?, string?)>>,
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite,
bool Archived)>>(Query.As(new Wallet<(string?, string?)>((configuration.Filter, configuration.Query))));
@@ -31,8 +31,8 @@ public class ItemNavigationCollectionViewModelActivatedHandler(IMediator mediato
IDecoratorService<Item<(Guid, string)>> decoratorService = serviceScope.ServiceProvider
.GetRequiredService<IDecoratorService<Item<(Guid, string)>>>();
if (serviceFactory.Create<ItemNavigationViewModel>(args => args.Initialize(), configuration.Filter,
Id, Name, "Description", Category, selected, Favourite, Archived)
if (serviceFactory.Create<ItemNavigationViewModel>(args => args.Initialize(), configuration.Filter,
Id, Name, "Description", Category, selected, Favourite, Archived)
is ItemNavigationViewModel viewModel)
{
Item<(Guid, string)> item = new((Id, Name));
@@ -17,4 +17,4 @@ public class ItemNavigationViewModelActivatedHandler(IMediator mediator,
publisher.Publish(Notify.As(new Item<IImageDescriptor>(imageDescriptor)));
}
}
}
}
+1 -1
View File
@@ -16,4 +16,4 @@ public partial class ItemSectionViewModel(IServiceProvider provider,
public string Id => id;
public IContentTemplate Template { get; set; } = template;
}
}
+1 -1
View File
@@ -5,4 +5,4 @@ public enum ItemState
New,
Read,
Write
}
}
-1
View File
@@ -1,6 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
+2 -2
View File
@@ -3,6 +3,6 @@
public class LengthRule :
IPasswordRule
{
public int CalculateScore(string password) =>
public int CalculateScore(string password) =>
password.Length >= 8 ? 5 : 0;
}
}
+2 -3
View File
@@ -2,13 +2,12 @@
namespace Wallet;
public partial class LowercaseRule :
public partial class LowercaseRule :
IPasswordRule
{
public int CalculateScore(string password) =>
Regex().IsMatch(password) ? 2 : 0;
[GeneratedRegex(@"[a-z]")]
private static partial Regex Regex();
}
}
-1
View File
@@ -32,7 +32,6 @@ public partial class MainViewModel :
Reset(args =>
{
args.SetSource(wallet, () => wallet);
SelectedItem = wallet;
}, false);
}
else
+1 -1
View File
@@ -7,4 +7,4 @@ public record MaskedTextEntryConfiguration :
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Pattern { get; set; }
}
}
+2 -2
View File
@@ -14,7 +14,7 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<MaskedTextEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<MaskedTextEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, configuration.Pattern, label, value, false, false, width])
is MaskedTextEntryViewModel viewModel)
{
@@ -24,4 +24,4 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
namespace Wallet;
public record NumberEntryConfiguration :
public record NumberEntryConfiguration :
ItemEntryConfiguration<string>
{
public int MinLength { get; set; }
+3 -3
View File
@@ -12,7 +12,7 @@ public class OpenWalletHandler(IConfigurationDescriptor<WalletConfiguration> des
public async Task<bool> Handle(OpenEventArgs<Wallet<string>> args,
CancellationToken cancellationToken)
{
if (args.Sender is Wallet<string> Wallet &&
if (args.Sender is Wallet<string> Wallet &&
descriptor.Name is { Length: > 0 } name &&
Wallet.Value is { Length: > 0 } password)
{
@@ -22,10 +22,10 @@ public class OpenWalletHandler(IConfigurationDescriptor<WalletConfiguration> des
byte[]? salt = Convert.FromBase64String(keyPart[0]);
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password),
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password),
encryptedKey, salt) is SecurityKey securityKey)
{
if (await walletConnectionFactory.Create(name, Convert.ToBase64String(securityKey.DecryptedKey))
if (await walletConnectionFactory.Create(name, Convert.ToBase64String(securityKey.DecryptedKey))
is WalletConnection connection)
{
walletConnectionDecorator.Set(connection);
+6 -6
View File
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
namespace Wallet;
public partial class OpenWalletViewModel :
public partial class OpenWalletViewModel :
Observable
{
[ObservableProperty]
@@ -22,10 +22,10 @@ public partial class OpenWalletViewModel :
private string password;
public OpenWalletViewModel(IValidation validation,
IServiceProvider provider,
IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
IDisposer disposer,
string name,
@@ -42,8 +42,8 @@ public partial class OpenWalletViewModel :
{
using (await new ActivityLock(this))
{
if (await Validation.Validate(() => Password, [new ValidationRule(async () =>
await Mediator.Handle<OpenEventArgs<Wallet<string>>, bool>(Open.As(new Wallet<string>(Password))),
if (await Validation.Validate(() => Password, [new ValidationRule(async () =>
await Mediator.Handle<OpenEventArgs<Wallet<string>>, bool>(Open.As(new Wallet<string>(Password))),
"The password is incorrect, please try again.")]))
{
Publisher.Publish(Opened.As<Wallet>());
+2 -2
View File
@@ -14,7 +14,7 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<PasswordEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<PasswordEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, true, false, width])
is PasswordEntryViewModel viewModel)
{
@@ -24,4 +24,4 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+1 -1
View File
@@ -6,4 +6,4 @@ public record PinEntryConfiguration :
public int Minimum { get; set; }
public int Maximum { get; set; }
}
}
+2 -2
View File
@@ -14,7 +14,7 @@ public class PinEntryViewModelHandler(IServiceFactory serviceFactory) :
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<PinEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<PinEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, true, false, width])
is PinEntryViewModel viewModel)
{
@@ -24,4 +24,4 @@ public class PinEntryViewModelHandler(IServiceFactory serviceFactory) :
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+1 -2
View File
@@ -2,5 +2,4 @@
public record ProfileImage;
public record ProfileImage<TValue>(TValue Value);
public record ProfileImage<TValue>(TValue Value);
+4 -5
View File
@@ -1,15 +1,15 @@
using Wallet.Data;
using LinqKit;
using LinqKit;
using Microsoft.EntityFrameworkCore;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
public class QueryWalletHandler(IDbContextFactory<WalletContext> dbContextFactory) :
IHandler<QueryEventArgs<Wallet<(string, string)>>, IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
{
public async Task<IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
Handle(QueryEventArgs<Wallet<(string, string)>> args,CancellationToken cancellationToken)
public async Task<IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
Handle(QueryEventArgs<Wallet<(string, string)>> args, CancellationToken cancellationToken)
{
List<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)> items = [];
if (args.Sender is Wallet<(string, string)> Wallet)
@@ -42,7 +42,6 @@ public class QueryWalletHandler(IDbContextFactory<WalletContext> dbContextFactor
.And(x => EF.Functions.Like(x.Category, $"%{filter}%"));
}
if (text is { Length: > 0 })
{
predicate = predicate.And(x => EF.Functions.Like(x.Name, $"%{text}%"));
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Wallet;
public partial class SpecialCharRule : IPasswordRule
{
public int CalculateScore(string password) =>
public int CalculateScore(string password) =>
Regex().IsMatch(password) ? 2 : 0;
[GeneratedRegex(@"[^a-zA-Z0-9]")]
+1 -1
View File
@@ -14,4 +14,4 @@ public partial class TextEntryViewModel(IServiceProvider provider,
string value,
bool isConcealed,
bool isRevealed,
double width) : ItemEntryViewModel<string>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
double width) : ItemEntryViewModel<string>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
+3 -3
View File
@@ -2,7 +2,7 @@
namespace Wallet;
public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
IHandler<CreateEventArgs<TextEntryConfiguration>, IItemEntryViewModel?>
{
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<TextEntryConfiguration> args,
@@ -14,7 +14,7 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<TextEntryViewModel>(args => args.Initialize(),
if (serviceFactory.Create<TextEntryViewModel>(args => args.Initialize(),
[.. args.Parameters, configuration, label, value, false, false, width])
is TextEntryViewModel viewModel)
{
@@ -24,4 +24,4 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
return Task.FromResult<IItemEntryViewModel?>(default);
}
}
}
+3 -3
View File
@@ -1,8 +1,8 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using System.Text;
using System.Text.Json;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
+5 -5
View File
@@ -1,13 +1,13 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Toolkit.Foundation;
using Wallet.Data;
namespace Wallet;
public class UpdateItemStateHandler(IDbContextFactory<WalletContext> dbContextFactory) :
public class UpdateItemStateHandler(IDbContextFactory<WalletContext> dbContextFactory) :
IHandler<UpdateEventArgs<(Guid, int)>, bool>
{
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
CancellationToken cancellationToken)
{
if (args.Sender is (Guid id, int state))
@@ -22,4 +22,4 @@ public class UpdateItemStateHandler(IDbContextFactory<WalletContext> dbContextFa
return false;
}
}
}
+1 -1
View File
@@ -10,4 +10,4 @@ public partial class UppercaseRule :
[GeneratedRegex(@"[A-Z]")]
private static partial Regex Regex();
}
}
+4 -4
View File
@@ -35,17 +35,17 @@ public class WalletActivatedHandler(IWalletHostCollection wallets,
int index = sortedWallets.IndexOf(host);
if (host.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
if (host.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
ConfigurationDescriptor<WalletConfiguration> descriptor)
{
if (host.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
{
IDecoratorService<ProfileImage<IImageDescriptor>> profileImageDecorator =
host.Services.GetRequiredService<IDecoratorService<ProfileImage<IImageDescriptor>>>();
ProfileImage<IImageDescriptor>? profileImage = profileImageDecorator.Value;
if (serviceFactory.Create<WalletNavigationViewModel>(args => args.Initialize(),
descriptor.Name, profileImage?.Value, false)
if (serviceFactory.Create<WalletNavigationViewModel>(args => args.Initialize(),
descriptor.Name, profileImage?.Value, false)
is WalletNavigationViewModel viewModel)
{
publisher.Publish(Insert.As<IWalletNavigationViewModel>(index, viewModel),
+2 -2
View File
@@ -3,9 +3,9 @@ using Toolkit.Foundation;
namespace Wallet;
public class WalletCollectionInitializer(IHostEnvironment environment,
public class WalletCollectionInitializer(IHostEnvironment environment,
IComponentFactory componentFactory,
IWalletHostCollection wallets) :
IWalletHostCollection wallets) :
IInitialization
{
public void Initialize()
-2
View File
@@ -1,6 +1,4 @@
using Microsoft.Extensions.Hosting;
using System.Linq;
using System.Xml.Linq;
using Toolkit.Foundation;
namespace Wallet;
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Wallet;
public record WalletConnection(string Value) :
public record WalletConnection(string Value) :
IConnection
{
public override string ToString() => Value;
+3 -3
View File
@@ -1,6 +1,6 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Wallet.Data;
namespace Wallet;
@@ -32,4 +32,4 @@ public class WalletConnectionFactory(IHostEnvironment environment) :
return null;
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
using Wallet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Wallet.Data;
namespace Wallet;
+2 -2
View File
@@ -12,7 +12,7 @@ public class WalletFactory(ISecurityKeyFactory securityKeyFactory,
IWalletFactory
{
public async Task<bool> Create(string name,
string password,
string password,
IImageDescriptor? imageDescriptor)
{
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
@@ -36,4 +36,4 @@ public class WalletFactory(ISecurityKeyFactory securityKeyFactory,
return false;
}
}
}
@@ -8,11 +8,11 @@ public partial class WalletNavigationCollectionViewModel :
ObservableCollection<IWalletNavigationViewModel>,
INotificationHandler<SelectionEventArgs<INavigationViewModel>>
{
public WalletNavigationCollectionViewModel(IServiceProvider provider,
public WalletNavigationCollectionViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
ISubscriber subscriber,
IDisposer disposer,
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
@@ -30,4 +30,4 @@ public partial class WalletNavigationCollectionViewModel :
return Task.CompletedTask;
}
}
}
+2 -2
View File
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
namespace Wallet;
public class WalletProfileImageInitializer(IHostEnvironment environment,
public class WalletProfileImageInitializer(IHostEnvironment environment,
IImageReader reader,
IDecoratorService<ProfileImage<IImageDescriptor>> profileImageDecorator) :
IInitialization
@@ -19,4 +19,4 @@ public class WalletProfileImageInitializer(IHostEnvironment environment,
profileImageDecorator.Set(new ProfileImage<IImageDescriptor>(imageDescriptor));
}
}
}
}