Use Value, not sender!!!!!!!!!!!!!!!!!!!!

This commit is contained in:
Dan Clark
2024-11-29 21:20:14 +00:00
parent f9f7339fc6
commit cbc0be4c3d
63 changed files with 193 additions and 192 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
public record Activate public record Activate
{ {
public static ActivateEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static ActivateEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static ActivateEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static ActivateEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ActivateEventArgs<TSender> public record ActivateEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ActivateEventArgs(TSender sender) public ActivateEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ActivateEventArgs() public ActivateEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Activated public record Activated
{ {
public static ActivatedEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static ActivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static ActivatedEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static ActivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ActivatedEventArgs<TSender> public record ActivatedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ActivatedEventArgs(TSender sender) public ActivatedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ActivatedEventArgs() public ActivatedEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Cancel public record Cancel
{ {
public static CancelEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static CancelEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static CancelEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static CancelEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record CancelEventArgs<TSender> public record CancelEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public CancelEventArgs(TSender sender) public CancelEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public CancelEventArgs() public CancelEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Changed public record Changed
{ {
public static ChangedEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static ChangedEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ChangedEventArgs<TSender> public record ChangedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ChangedEventArgs(TSender sender) public ChangedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ChangedEventArgs() public ChangedEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Close public record Close
{ {
public static CloseEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static CloseEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static CloseEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static CloseEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record CloseEventArgs<TSender> public record CloseEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public CloseEventArgs(TSender sender) public CloseEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public CloseEventArgs() public CloseEventArgs()
+2 -2
View File
@@ -2,8 +2,8 @@
public record Closed public record Closed
{ {
public static ClosedEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static ClosedEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static ClosedEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static ClosedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ClosedEventArgs<TSender> public record ClosedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ClosedEventArgs(TSender sender) public ClosedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ClosedEventArgs() public ClosedEventArgs()
@@ -7,7 +7,7 @@ public class ConfigurationChangedHandler<TConfiguration, TValue>(ConfigurationVa
{ {
public void Handle(ChangedEventArgs<TConfiguration> args) public void Handle(ChangedEventArgs<TConfiguration> args)
{ {
if (args.Sender is TConfiguration configuration) if (args.Value is TConfiguration configuration)
{ {
if (configurationValue.TryUpdate(configuration, out TValue value)) if (configurationValue.TryUpdate(configuration, out TValue value))
{ {
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ConfirmEventArgs<TSender> public record ConfirmEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ConfirmEventArgs(TSender sender) public ConfirmEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ConfirmEventArgs() public ConfirmEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public record Count public record Count
{ {
public static CountEventArgs<TSender> As<TSender>(TSender sender) => public static CountEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static CountEventArgs<TSender> As<TSender>() where TSender : new() => public static CountEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record CountEventArgs<TSender> public record CountEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public CountEventArgs(TSender sender) public CountEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public CountEventArgs() public CountEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public record Create public record Create
{ {
public static CreateEventArgs<TSender> As<TSender>(TSender sender) => public static CreateEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static CreateEventArgs<TSender> As<TSender>(params object[] parameters) where TSender : new() => public static CreateEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record CreateEventArgs<TSender> public record CreateEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public CreateEventArgs(TSender sender) public CreateEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public CreateEventArgs() public CreateEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public record Created public record Created
{ {
public static CreatedEventArgs<TSender> As<TSender>(TSender sender) => public static CreatedEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static CreatedEventArgs<TSender> As<TSender>() where TSender : new() => public static CreatedEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record CreatedEventArgs<TSender>(TSender? Sender = default); public record CreatedEventArgs<TValue>(TValue? Value = default);
+2 -2
View File
@@ -2,7 +2,7 @@
public record Deactivate public record Deactivate
{ {
public static DeactivateEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static DeactivateEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static DeactivateEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static DeactivateEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record DeactivateEventArgs<TSender> public record DeactivateEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public DeactivateEventArgs(TSender sender) public DeactivateEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public DeactivateEventArgs() public DeactivateEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Deactivated public record Deactivated
{ {
public static DeactivatedEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static DeactivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static DeactivatedEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static DeactivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record DeactivatedEventArgs<TSender> public record DeactivatedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public DeactivatedEventArgs(TSender sender) public DeactivatedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public DeactivatedEventArgs() public DeactivatedEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public record Delete public record Delete
{ {
public static DeleteEventArgs<TSender> As<TSender>(TSender sender) => public static DeleteEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static DeleteEventArgs<TSender> As<TSender>() where TSender : new() => public static DeleteEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record DeleteEventArgs<TSender> public record DeleteEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public DeleteEventArgs(TSender sender) public DeleteEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public DeleteEventArgs() public DeleteEventArgs()
@@ -157,6 +157,7 @@ public static class IServiceCollectionExtensions
public static IServiceCollection AddInitialization(this IServiceCollection services, public static IServiceCollection AddInitialization(this IServiceCollection services,
Action<IServiceProvider> delegateAction) Action<IServiceProvider> delegateAction)
{ {
services.AddTransient<IInitialization>(provider => new ActionableInitialization(provider, delegateAction)); services.AddTransient<IInitialization>(provider => new ActionableInitialization(provider, delegateAction));
return services; return services;
+4 -4
View File
@@ -2,9 +2,9 @@
public record Insert public record Insert
{ {
public static InsertEventArgs<TSender> As<TSender>(int index, TSender sender) => public static InsertEventArgs<TValue> As<TValue>(int index, TValue value) =>
new(index, sender); new(index, value);
public static InsertEventArgs<TSender> As<TSender>(int index) where TSender : new() => public static InsertEventArgs<TValue> As<TValue>(int index) where TValue : new() =>
new(index, new TSender()); new(index, new TValue());
} }
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record InsertEventArgs<TSender>(int Index, TSender Sender); public record InsertEventArgs<TValue>(int Index, TValue Value);
+2 -2
View File
@@ -2,7 +2,7 @@
public record Move public record Move
{ {
public static MoveEventArgs<TSender> As<TSender>(int index, TSender sender) => new(index, sender); public static MoveEventArgs<TValue> As<TValue>(int index, TValue value) => new(index, value);
public static MoveEventArgs<TSender> As<TSender>(int index) where TSender : new() => new(index, new TSender()); public static MoveEventArgs<TValue> As<TValue>(int index) where TValue : new() => new(index, new TValue());
} }
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record MoveEventArgs<TSender>(int Index, TSender? Sender = default); public record MoveEventArgs<TValue>(int Index, TValue? Value = default);
+4 -4
View File
@@ -1,18 +1,18 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record MoveToEventArgs<TSender> public record MoveToEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public int OldIndex { get; } public int OldIndex { get; }
public int NewIndex { get; } public int NewIndex { get; }
public MoveToEventArgs(TSender sender, public MoveToEventArgs(TValue value,
int oldIndex, int oldIndex,
int newIndex) int newIndex)
{ {
Sender = sender; Value = value;
OldIndex = oldIndex; OldIndex = oldIndex;
NewIndex = newIndex; NewIndex = newIndex;
} }
+2 -2
View File
@@ -2,7 +2,7 @@
public class Notify public class Notify
{ {
public static NotifyEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static NotifyEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static NotifyEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static NotifyEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record NotifyEventArgs<TSender> public record NotifyEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public NotifyEventArgs(TSender sender) public NotifyEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public NotifyEventArgs() public NotifyEventArgs()
+5 -5
View File
@@ -313,7 +313,7 @@ public abstract partial class ObservableCollection<TViewModel> :
{ {
foreach (TViewModel item in this.ToList()) foreach (TViewModel item in this.ToList())
{ {
if (args.Sender is not null && args.Sender.Equals(item)) if (args.Value is not null && args.Value.Equals(item))
{ {
Remove(item); Remove(item);
} }
@@ -322,7 +322,7 @@ public abstract partial class ObservableCollection<TViewModel> :
public void Receive(CreateEventArgs<TViewModel> args) public void Receive(CreateEventArgs<TViewModel> args)
{ {
if (args.Sender is TViewModel item) if (args.Value is TViewModel item)
{ {
Add(item); Add(item);
} }
@@ -330,7 +330,7 @@ public abstract partial class ObservableCollection<TViewModel> :
public void Receive(InsertEventArgs<TViewModel> args) public void Receive(InsertEventArgs<TViewModel> args)
{ {
if (args.Sender is TViewModel item) if (args.Value is TViewModel item)
{ {
Insert(args.Index, item); Insert(args.Index, item);
} }
@@ -343,7 +343,7 @@ public abstract partial class ObservableCollection<TViewModel> :
public void Receive(MoveEventArgs<TViewModel> args) public void Receive(MoveEventArgs<TViewModel> args)
{ {
if (args.Sender is TViewModel item) if (args.Value is TViewModel item)
{ {
Move(args.Index, item); Move(args.Index, item);
} }
@@ -351,7 +351,7 @@ public abstract partial class ObservableCollection<TViewModel> :
public void Receive(ReplaceEventArgs<TViewModel> args) public void Receive(ReplaceEventArgs<TViewModel> args)
{ {
if (args.Sender is TViewModel item) if (args.Value is TViewModel item)
{ {
Replace(args.Index, item); Replace(args.Index, item);
} }
@@ -34,7 +34,7 @@ public partial class ObservableConfiguration<TConfiguration, TValue> :
public void Receive(ChangedEventArgs<TConfiguration> args) public void Receive(ChangedEventArgs<TConfiguration> args)
{ {
if (args.Sender is TConfiguration configuration) if (args.Value is TConfiguration configuration)
{ {
dispatcher.Invoke(() => Value = read(configuration)); dispatcher.Invoke(() => Value = read(configuration));
} }
@@ -57,7 +57,7 @@ public partial class ObservableConfigurationCollection<TConfiguration, TValue, T
public void Receive(ChangedEventArgs<TConfiguration> args) public void Receive(ChangedEventArgs<TConfiguration> args)
{ {
if (args.Sender is TConfiguration configuration) if (args.Value is TConfiguration configuration)
{ {
dispatcher.Invoke(() => Value = read(configuration)); dispatcher.Invoke(() => Value = read(configuration));
} }
+2 -2
View File
@@ -2,7 +2,7 @@
public record Open public record Open
{ {
public static OpenEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static OpenEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static OpenEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static OpenEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record OpenEventArgs<TSender> public record OpenEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public OpenEventArgs(TSender sender) public OpenEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public OpenEventArgs() public OpenEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Opened public record Opened
{ {
public static OpenedEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static OpenedEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static OpenedEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static OpenedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record OpenedEventArgs<TSender> public record OpenedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public OpenedEventArgs(TSender sender) public OpenedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public OpenedEventArgs() public OpenedEventArgs()
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record QueryEventArgs<TSender> public record QueryEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public QueryEventArgs(TSender sender) public QueryEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public QueryEventArgs() public QueryEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public class Read public class Read
{ {
public static ReadEventArgs<TSender> As<TSender>(TSender sender) => public static ReadEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static ReadEventArgs<TSender> As<TSender>() where TSender : new() => public static ReadEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ReadEventArgs<TSender> public record ReadEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ReadEventArgs(TSender sender) public ReadEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ReadEventArgs() public ReadEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Remove public record Remove
{ {
public static RemoveEventArgs<TSender> As<TSender>(TSender sender) => new(sender); public static RemoveEventArgs<TValue> As<TValue>(TValue value) => new(value);
public static RemoveEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender()); public static RemoveEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
} }
+1 -1
View File
@@ -2,6 +2,6 @@
public record RemoveAt public record RemoveAt
{ {
public static RemoveAtEventArgs<TSender> As<TSender>(int index) => public static RemoveAtEventArgs<TValue> As<TValue>(int index) =>
new(index); new(index);
} }
+4 -4
View File
@@ -1,15 +1,15 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record RemoveAtEventArgs<TSender> public record RemoveAtEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public int Index { get; } public int Index { get; }
public RemoveAtEventArgs(TSender sender, public RemoveAtEventArgs(TValue value,
int index) int index)
{ {
Sender = sender; Value = value;
Index = index; Index = index;
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record RemoveEventArgs<TSender> public record RemoveEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public RemoveEventArgs(TSender sender) public RemoveEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public RemoveEventArgs() public RemoveEventArgs()
+2 -2
View File
@@ -2,7 +2,7 @@
public record Replace public record Replace
{ {
public static ReplaceEventArgs<TSender> As<TSender>(int index, TSender sender) => new(sender, index); public static ReplaceEventArgs<TValue> As<TValue>(int index, TValue value) => new(value, index);
public static ReplaceEventArgs<TSender> As<TSender>(int index) where TSender : new() => new(index); public static ReplaceEventArgs<TValue> As<TValue>(int index) where TValue : new() => new(index);
} }
+4 -4
View File
@@ -1,15 +1,15 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ReplaceEventArgs<TSender> public record ReplaceEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public int Index { get; } public int Index { get; }
public ReplaceEventArgs(TSender sender, public ReplaceEventArgs(TValue value,
int index) int index)
{ {
Sender = sender; Value = value;
Index = index; Index = index;
} }
+4 -4
View File
@@ -2,9 +2,9 @@
public class Request public class Request
{ {
public static RequestEventArgs<TSender> As<TSender>(TSender sender) => public static RequestEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static RequestEventArgs<TSender> As<TSender>() where TSender : new() => public static RequestEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+5 -5
View File
@@ -2,17 +2,17 @@
public record RequestEventArgs public record RequestEventArgs
{ {
public object? Sender { get; init; } public object? Value { get; init; }
public RequestEventArgs(object? sender = null) public RequestEventArgs(object? value = null)
{ {
Sender = sender; Value = value;
} }
} }
public record RequestEventArgs<TSender> : RequestEventArgs public record RequestEventArgs<TValue> : RequestEventArgs
{ {
public RequestEventArgs(TSender sender) : base(sender) public RequestEventArgs(TValue value) : base(value)
{ {
} }
} }
+1 -1
View File
@@ -6,7 +6,7 @@ public class SelectFilesHandler(IFileProvider fileProvider) :
public async Task<IReadOnlyCollection<string>?> Handle(SelectionEventArgs<FileFilter> args, public async Task<IReadOnlyCollection<string>?> Handle(SelectionEventArgs<FileFilter> args,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (args.Sender is FileFilter filter) if (args.Value is FileFilter filter)
{ {
if (await fileProvider.SelectFiles(filter) if (await fileProvider.SelectFiles(filter)
is { Count: > 0 } files) is { Count: > 0 } files)
+1 -1
View File
@@ -7,7 +7,7 @@ public class SelectFoldersHandler(IFolderProvider folderProvider) :
public async Task<IReadOnlyCollection<string>?> Handle(SelectionEventArgs<FolderFilter> args, public async Task<IReadOnlyCollection<string>?> Handle(SelectionEventArgs<FolderFilter> args,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
if (args.Sender is FolderFilter filter) if (args.Value is FolderFilter filter)
{ {
if (await folderProvider.SelectFolders(filter) if (await folderProvider.SelectFolders(filter)
is { Count: > 0 } folders) is { Count: > 0 } folders)
+4 -4
View File
@@ -2,9 +2,9 @@
public record Selection public record Selection
{ {
public static SelectionEventArgs<TSender?> As<TSender>(TSender? sender) => public static SelectionEventArgs<TValue?> As<TValue>(TValue? value) =>
new(sender); new(value);
public static SelectionEventArgs<TSender?> As<TSender>() where TSender : new() => public static SelectionEventArgs<TValue?> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record SelectionEventArgs<TSender> public record SelectionEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public SelectionEventArgs(TSender sender) public SelectionEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public SelectionEventArgs() public SelectionEventArgs()
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record UpdateEventArgs<TSender> public record UpdateEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public UpdateEventArgs(TSender sender) public UpdateEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public UpdateEventArgs() public UpdateEventArgs()
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record UpdatedEventArgs<TSender> public record UpdatedEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public UpdatedEventArgs(TSender sender) public UpdatedEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public UpdatedEventArgs() public UpdatedEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public record Validate public record Validate
{ {
public static ValidateEventArgs<TSender> As<TSender>(TSender sender) => public static ValidateEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static ValidateEventArgs<TSender> As<TSender>() where TSender : new() => public static ValidateEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record ValidateEventArgs<TSender> public record ValidateEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public ValidateEventArgs(TSender sender) public ValidateEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public ValidateEventArgs() public ValidateEventArgs()
+4 -4
View File
@@ -2,9 +2,9 @@
public class Write public class Write
{ {
public static WriteEventArgs<TSender> As<TSender>(TSender sender) => public static WriteEventArgs<TValue> As<TValue>(TValue value) =>
new(sender); new(value);
public static WriteEventArgs<TSender> As<TSender>() where TSender : new() => public static WriteEventArgs<TValue> As<TValue>() where TValue : new() =>
new(new TSender()); new(new TValue());
} }
+1 -1
View File
@@ -6,7 +6,7 @@ public class WriteClipboardHandler(IClipboardWriter clipboardWriter) :
public async Task Handle(WriteEventArgs<Clipboard<object>> args, public async Task Handle(WriteEventArgs<Clipboard<object>> args,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
if (args.Sender is Clipboard<object> clipboard) if (args.Value is Clipboard<object> clipboard)
{ {
await clipboardWriter.Write(clipboard.Value); await clipboardWriter.Write(clipboard.Value);
} }
+4 -4
View File
@@ -1,12 +1,12 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record WriteEventArgs<TSender> public record WriteEventArgs<TValue>
{ {
public TSender? Sender { get; } public TValue? Value { get; }
public WriteEventArgs(TSender sender) public WriteEventArgs(TValue value)
{ {
Sender = sender; Value = value;
} }
public WriteEventArgs() public WriteEventArgs()