Improved event naming
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Toolkit.Avalonia;
|
||||
public class ClassicDesktopStyleApplicationHandler :
|
||||
INavigateHandler<IClassicDesktopStyleApplicationLifetime>
|
||||
{
|
||||
public Task Handle(Navigate<IClassicDesktopStyleApplicationLifetime> args,
|
||||
public Task Handle(NavigateEventArgs<IClassicDesktopStyleApplicationLifetime> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Toolkit.Avalonia;
|
||||
public class ContentControlHandler :
|
||||
INavigateHandler<ContentControl>
|
||||
{
|
||||
public async Task Handle(Navigate<ContentControl> args,
|
||||
public async Task Handle(NavigateEventArgs<ContentControl> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Context is ContentControl contentControl)
|
||||
@@ -27,7 +27,7 @@ public class ContentControlHandler :
|
||||
|
||||
if (content is IActivated activated)
|
||||
{
|
||||
await activated.Activated();
|
||||
await activated.OnActivated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ContentControlHandler :
|
||||
{
|
||||
if (content is IDeactivated deactivated)
|
||||
{
|
||||
await deactivated.Deactivated();
|
||||
await deactivated.OnDeactivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Toolkit.Avalonia;
|
||||
public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
INavigateHandler<ContentDialog>
|
||||
{
|
||||
public async Task Handle(Navigate<ContentDialog> args,
|
||||
public async Task Handle(NavigateEventArgs<ContentDialog> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Context is ContentDialog contentDialog)
|
||||
@@ -94,7 +94,7 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
|
||||
if (content is IActivated activated)
|
||||
{
|
||||
await activated.Activated();
|
||||
await activated.OnActivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ContentTemplate :
|
||||
|
||||
if (content is IActivated activated)
|
||||
{
|
||||
await activated.Activated();
|
||||
await activated.OnActivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ContentTemplate :
|
||||
{
|
||||
if (content is IDeactivated deactivated)
|
||||
{
|
||||
await deactivated.Deactivated();
|
||||
await deactivated.OnDeactivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class FrameHandler :
|
||||
INavigateHandler<Frame>,
|
||||
INavigateBackHandler<Frame>
|
||||
{
|
||||
public Task Handle(Navigate<Frame> args,
|
||||
public Task Handle(NavigateEventArgs<Frame> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Context is Frame frame)
|
||||
@@ -43,7 +43,7 @@ public class FrameHandler :
|
||||
{
|
||||
if (content is IDeactivating deactivating)
|
||||
{
|
||||
await deactivating.Deactivating();
|
||||
await deactivating.OnDeactivating();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class FrameHandler :
|
||||
{
|
||||
if (content is IDeactivated deactivated)
|
||||
{
|
||||
await deactivated.Deactivated();
|
||||
await deactivated.OnDeactivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class FrameHandler :
|
||||
|
||||
if (content is IActivated activated)
|
||||
{
|
||||
await activated.Activated();
|
||||
await activated.OnActivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class FrameHandler :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(NavigateBack<Frame> args,
|
||||
public Task Handle(NavigateBackEventArgs<Frame> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Context is Frame frame)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Toolkit.Avalonia;
|
||||
public class SingleViewApplicationHandler :
|
||||
INavigateHandler<ISingleViewApplicationLifetime>
|
||||
{
|
||||
public Task Handle(Navigate<ISingleViewApplicationLifetime> args,
|
||||
public Task Handle(NavigateEventArgs<ISingleViewApplicationLifetime> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Activate
|
||||
{
|
||||
public static ActivateEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static ActivateEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ActivateEventArgs<TValue>(TValue? Value = default);
|
||||
@@ -1,10 +1,8 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Activated<TValue>(TValue? Value = default);
|
||||
|
||||
public record Activated
|
||||
{
|
||||
public static Activated<TValue> As<TValue>(TValue value) => new(value);
|
||||
public static ActivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static Activated<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
public static ActivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ActivatedEventArgs<TValue>(TValue? Value = default);
|
||||
@@ -13,7 +13,7 @@ public class AppService(IEnumerable<IInitializer> initializers,
|
||||
await initializer.Initialize();
|
||||
}
|
||||
|
||||
await publisher.Publish<Started>(cancellationToken);
|
||||
await publisher.Publish<StartedEventArgs>(cancellationToken);
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Changed<TValue>(TValue? Value = default);
|
||||
|
||||
public record Changed
|
||||
{
|
||||
public static Changed<TValue> As<TValue>(TValue value) => new(value);
|
||||
public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static Changed<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ChangedEventArgs<TValue>(TValue? Value = default);
|
||||
@@ -5,7 +5,7 @@ namespace Toolkit.Foundation;
|
||||
public partial class ComponentConfigurationViewModel<TConfiguration, TValue, THeader, TDescription, TAction> :
|
||||
ValueViewModel<TValue>,
|
||||
IComponentConfigurationViewModel,
|
||||
INotificationHandler<Changed<TConfiguration>>
|
||||
INotificationHandler<ChangedEventArgs<TConfiguration>>
|
||||
where TConfiguration : class
|
||||
{
|
||||
public ComponentConfigurationViewModel(IServiceProvider provider,
|
||||
@@ -20,7 +20,7 @@ public partial class ComponentConfigurationViewModel<TConfiguration, TValue, THe
|
||||
{
|
||||
}
|
||||
|
||||
public Task Handle(Changed<TConfiguration> args,
|
||||
public Task Handle(ChangedEventArgs<TConfiguration> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -40,7 +40,7 @@ public partial class ComponentConfigurationViewModel<TConfiguration, TValue, TAc
|
||||
object description) :
|
||||
ValueViewModel<TValue>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IComponentConfigurationViewModel,
|
||||
INotificationHandler<Changed<TConfiguration>>
|
||||
INotificationHandler<ChangedEventArgs<TConfiguration>>
|
||||
where TConfiguration : class
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -52,13 +52,13 @@ public partial class ComponentConfigurationViewModel<TConfiguration, TValue, TAc
|
||||
[ObservableProperty]
|
||||
private object description = description;
|
||||
|
||||
public override Task Activated()
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Value = valueDelegate.Invoke(configuration);
|
||||
return base.Activated();
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
public Task Handle(Changed<TConfiguration> args,
|
||||
public Task Handle(ChangedEventArgs<TConfiguration> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is TConfiguration configuration)
|
||||
@@ -83,7 +83,7 @@ public partial class ComponentConfigurationViewModel<TConfiguration, TValue, TDe
|
||||
object header) :
|
||||
ValueViewModel<TValue>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IComponentConfigurationViewModel,
|
||||
INotificationHandler<Changed<TConfiguration>>
|
||||
INotificationHandler<ChangedEventArgs<TConfiguration>>
|
||||
where TConfiguration : class
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -95,13 +95,13 @@ public partial class ComponentConfigurationViewModel<TConfiguration, TValue, TDe
|
||||
[ObservableProperty]
|
||||
private TDescription description = description;
|
||||
|
||||
public override Task Activated()
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Value = valueDelegate.Invoke(configuration);
|
||||
return base.Activated();
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
public Task Handle(Changed<TConfiguration> args,
|
||||
public Task Handle(ChangedEventArgs<TConfiguration> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is TConfiguration configuration)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class ConfigurationChangedHandler<TConfiguration, TValue>(ConfigurationValue<TConfiguration, TValue> configurationValue) :
|
||||
INotificationHandler<Changed<TConfiguration>>
|
||||
INotificationHandler<ChangedEventArgs<TConfiguration>>
|
||||
where TValue :
|
||||
class, new()
|
||||
{
|
||||
public Task Handle(Changed<TConfiguration> args,
|
||||
public Task Handle(ChangedEventArgs<TConfiguration> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is TConfiguration configuration)
|
||||
|
||||
@@ -20,6 +20,6 @@ public class ConfigurationInitializer<TConfiguration>(IConfigurationReader<TConf
|
||||
}
|
||||
}
|
||||
|
||||
await publisher.PublishUI(new Activated<TConfiguration>(configuration));
|
||||
await publisher.PublishUI(new ActivatedEventArgs<TConfiguration>(configuration));
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class ConfigurationMonitor<TConfiguration>(IConfigurationFile<TConfigurat
|
||||
{
|
||||
if (reader.Read() is { } configuration)
|
||||
{
|
||||
await publisher.PublishUI(new Changed<TConfiguration>(configuration));
|
||||
await publisher.PublishUI(new ChangedEventArgs<TConfiguration>(configuration));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Confirm<TValue>(TValue Value);
|
||||
|
||||
public record Confirm
|
||||
{
|
||||
public static Confirm<TValue> As<TValue>(TValue value) =>
|
||||
public static ConfirmEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static Confirm<TValue> As<TValue>() where TValue : new() =>
|
||||
public static ConfirmEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ConfirmEventArgs<TValue>(TValue Value);
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Create<TValue>(TValue Value);
|
||||
|
||||
public record Create
|
||||
{
|
||||
public static Create<TValue> As<TValue>(TValue value) =>
|
||||
public static CreateEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static Create<TValue> As<TValue>() where TValue : new() =>
|
||||
public static CreateEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record CreateEventArgs<TValue>(TValue Value);
|
||||
@@ -1,3 +1,8 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Deactivated;
|
||||
public record Deactivated
|
||||
{
|
||||
public static DeactivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static DeactivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record DeactivatedEventArgs<TValue>(TValue? Value = default);
|
||||
@@ -1,18 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Enumerate<TValue> :
|
||||
IEnumerate
|
||||
{
|
||||
public object? Key { get; init; }
|
||||
|
||||
public EnumerateMode Mode { get; init; }
|
||||
|
||||
public static Enumerate<TValue, TOptions> With<TOptions>(TOptions options) where TOptions : class
|
||||
{
|
||||
return new Enumerate<TValue, TOptions>(options);
|
||||
}
|
||||
}
|
||||
|
||||
public record Enumerate<TValue, TOptions>(TOptions? Options = null) :
|
||||
IEnumerate
|
||||
where TOptions : class
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record EnumerateEventArgs<TValue> :
|
||||
IEnumerate
|
||||
{
|
||||
public object? Key { get; init; }
|
||||
|
||||
public EnumerateMode Mode { get; init; }
|
||||
|
||||
public static Enumerate<TValue, TOptions> With<TOptions>(TOptions options) where TOptions : class
|
||||
{
|
||||
return new Enumerate<TValue, TOptions>(options);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public interface IActivated
|
||||
{
|
||||
Task Activated();
|
||||
Task OnActivated();
|
||||
}
|
||||
|
||||
public interface IActivated<TResult>
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public interface IDeactivated
|
||||
{
|
||||
Task Deactivated();
|
||||
Task OnDeactivated();
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public interface IDeactivating
|
||||
{
|
||||
Task Deactivating();
|
||||
Task OnDeactivating();
|
||||
}
|
||||
|
||||
public interface IDeactivating<TResult>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface INavigateBackHandler<TNavigation> :
|
||||
INotificationHandler<NavigateBack<TNavigation>>,
|
||||
INotificationHandler<NavigateBackEventArgs<TNavigation>>,
|
||||
INavigateHandler;
|
||||
@@ -3,5 +3,5 @@
|
||||
public interface INavigateHandler;
|
||||
|
||||
public interface INavigateHandler<TNavigation> :
|
||||
INotificationHandler<Navigate<TNavigation>>,
|
||||
INotificationHandler<NavigateEventArgs<TNavigation>>,
|
||||
INavigateHandler;
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Insert<TValue>(int Index, TValue Value);
|
||||
|
||||
public record Insert
|
||||
{
|
||||
public static Insert<TValue> As<TValue>(int index, TValue value) =>
|
||||
public static InsertEventArgs<TValue> As<TValue>(int index, TValue value) =>
|
||||
new(index, value);
|
||||
|
||||
public static Insert<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
public static InsertEventArgs<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
new(index, new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record InsertEventArgs<TValue>(int Index, TValue Value);
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Move<TValue>(int Index, TValue Value);
|
||||
|
||||
public record Move
|
||||
{
|
||||
public static Move<TValue> As<TValue>(int index, TValue value) =>
|
||||
public static MoveEventArgs<TValue> As<TValue>(int index, TValue value) =>
|
||||
new(index, value);
|
||||
|
||||
public static Insert<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
public static InsertEventArgs<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
new(index, new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record MoveEventArgs<TValue>(int Index, TValue Value);
|
||||
@@ -1,5 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record NavigateBack(object? Context = null, string? Scope = null);
|
||||
|
||||
public record NavigateBack<TNavigation>(object? Context);
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record NavigateBackEventArgs(object? Context = null, string? Scope = null);
|
||||
|
||||
public record NavigateBackEventArgs<TNavigation>(object? Context);
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class NavigateBackHandler(IComponentScopeProvider provider) :
|
||||
INotificationHandler<NavigateBack>
|
||||
INotificationHandler<NavigateBackEventArgs>
|
||||
{
|
||||
public async Task Handle(NavigateBack args,
|
||||
public async Task Handle(NavigateBackEventArgs args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (provider.Get(args.Scope ?? "Root")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record NavigateEventArgs(string Route,
|
||||
object? Context = null,
|
||||
string? Scope = null,
|
||||
object? Sender = null,
|
||||
EventHandler? Navigated = null,
|
||||
object[]? Parameters = null);
|
||||
|
||||
public record NavigateEventArgs<TNavigation>(object Context,
|
||||
object Template,
|
||||
object Content,
|
||||
object? Sender = null,
|
||||
object[]? Parameters = null);
|
||||
@@ -5,9 +5,9 @@ namespace Toolkit.Foundation;
|
||||
public class NavigateHandler(NamedComponent scope,
|
||||
IComponentScopeProvider componentScopeProvider,
|
||||
IServiceProvider provider) :
|
||||
INotificationHandler<Navigate>
|
||||
INotificationHandler<NavigateEventArgs>
|
||||
{
|
||||
public async Task Handle(Navigate args,
|
||||
public async Task Handle(NavigateEventArgs args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
INavigationScope? navigationScope;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record NavigationChanged<TValue>(TValue? Value);
|
||||
@@ -62,7 +62,7 @@ public class NavigationScope(IPublisher publisher,
|
||||
if (navigationProvider.Get(context is Type type ? type : context.GetType())
|
||||
is INavigation navigation)
|
||||
{
|
||||
Type navigateType = typeof(Navigate<>).MakeGenericType(navigation.Type);
|
||||
Type navigateType = typeof(NavigateEventArgs<>).MakeGenericType(navigation.Type);
|
||||
if (Activator.CreateInstance(navigateType, [context, view, viewModel, sender, parameters]) is object navigate)
|
||||
{
|
||||
await publisher.Publish(navigate, cancellationToken);
|
||||
@@ -92,7 +92,7 @@ public class NavigationScope(IPublisher publisher,
|
||||
if (navigationProvider.Get(context is Type type ? type : context.GetType())
|
||||
is INavigation navigation)
|
||||
{
|
||||
Type navigateType = typeof(NavigateBack<>).MakeGenericType(navigation.Type);
|
||||
Type navigateType = typeof(NavigateBackEventArgs<>).MakeGenericType(navigation.Type);
|
||||
if (Activator.CreateInstance(navigateType, [context]) is object navigate)
|
||||
{
|
||||
await publisher.Publish(navigate, cancellationToken);
|
||||
|
||||
@@ -19,11 +19,11 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
IList,
|
||||
IReadOnlyList<TViewModel>,
|
||||
INotifyCollectionChanged,
|
||||
INotificationHandler<Remove<TViewModel>>,
|
||||
INotificationHandler<Create<TViewModel>>,
|
||||
INotificationHandler<Insert<TViewModel>>,
|
||||
INotificationHandler<Move<TViewModel>>,
|
||||
INotificationHandler<Replace<TViewModel>>
|
||||
INotificationHandler<RemoveEventArgs<TViewModel>>,
|
||||
INotificationHandler<CreateEventArgs<TViewModel>>,
|
||||
INotificationHandler<InsertEventArgs<TViewModel>>,
|
||||
INotificationHandler<MoveEventArgs<TViewModel>>,
|
||||
INotificationHandler<ReplaceEventArgs<TViewModel>>
|
||||
where TViewModel :
|
||||
notnull
|
||||
{
|
||||
@@ -121,7 +121,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Task Activated() =>
|
||||
public virtual Task OnActivated() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public TViewModel Add()
|
||||
@@ -222,10 +222,10 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual Task Deactivated() =>
|
||||
public virtual Task OnDeactivated() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public virtual Task Deactivating() =>
|
||||
public virtual Task OnDeactivating() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public virtual void Dispose()
|
||||
@@ -240,7 +240,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
IEnumerator IEnumerable.GetEnumerator() =>
|
||||
((IEnumerable)collection).GetEnumerator();
|
||||
|
||||
public Task Handle(Remove<TViewModel> args,
|
||||
public Task Handle(RemoveEventArgs<TViewModel> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (TViewModel item in this.ToList())
|
||||
@@ -254,7 +254,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Create<TViewModel> args,
|
||||
public Task Handle(CreateEventArgs<TViewModel> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is TViewModel item)
|
||||
@@ -265,7 +265,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Insert<TViewModel> args,
|
||||
public Task Handle(InsertEventArgs<TViewModel> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is TViewModel item)
|
||||
@@ -276,7 +276,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Move<TViewModel> args,
|
||||
public Task Handle(MoveEventArgs<TViewModel> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is TViewModel item)
|
||||
@@ -287,7 +287,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Replace<TViewModel> args,
|
||||
public Task Handle(ReplaceEventArgs<TViewModel> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is TViewModel item)
|
||||
@@ -332,7 +332,7 @@ public partial class ObservableCollectionViewModel<TViewModel> :
|
||||
}
|
||||
|
||||
protected virtual IEnumerate PrepareEnumeration(object? key) =>
|
||||
new Enumerate<TViewModel>() with { Key = key };
|
||||
new EnumerateEventArgs<TViewModel>() with { Key = key };
|
||||
|
||||
public void Insert(int index, TViewModel item) =>
|
||||
InsertItem(index, item);
|
||||
|
||||
@@ -42,7 +42,7 @@ public partial class ObservableViewModel :
|
||||
|
||||
public IPublisher Publisher { get; }
|
||||
|
||||
public virtual Task Activated() =>
|
||||
public virtual Task OnActivated() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public Task Deactivate()
|
||||
@@ -51,10 +51,10 @@ public partial class ObservableViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual Task Deactivated() =>
|
||||
public virtual Task OnDeactivated() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public virtual Task Deactivating() =>
|
||||
public virtual Task OnDeactivating() =>
|
||||
Task.CompletedTask;
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Open<TValue>(TValue Value);
|
||||
|
||||
public record Open
|
||||
{
|
||||
public static Open<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static Open<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Remove<TValue>(TValue Value);
|
||||
|
||||
public record Remove
|
||||
{
|
||||
public static Remove<TValue> As<TValue>(TValue value) =>
|
||||
public static RemoveEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static Remove<TValue> As<TValue>() where TValue : new() =>
|
||||
public static RemoveEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record RemoveEventArgs<TValue>(TValue Value);
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Replace<TValue>(int Index, TValue Value);
|
||||
|
||||
public record Replace
|
||||
{
|
||||
public static Replace<TValue> As<TValue>(int index, TValue value) =>
|
||||
public static ReplaceEventArgs<TValue> As<TValue>(int index, TValue value) =>
|
||||
new(index, value);
|
||||
|
||||
public static Replace<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
public static ReplaceEventArgs<TValue> As<TValue>(int index) where TValue : new() =>
|
||||
new(index, new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ReplaceEventArgs<TValue>(int Index, TValue Value);
|
||||
@@ -1,8 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Request<TValue>;
|
||||
|
||||
public class Request
|
||||
{
|
||||
public static Request<TValue> As<TValue>() => new();
|
||||
public static RequestEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static RequestEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record RequestEventArgs<TValue>(TValue Value);
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Selected<TValue>(TValue? Value);
|
||||
|
||||
public record Selected
|
||||
{
|
||||
public static Selected<TValue> As<TValue>(TValue value) =>
|
||||
public static SelectedEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static Selected<TValue> As<TValue>() where TValue : new() =>
|
||||
public static SelectedEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record SelectedEventArgs<TValue>(TValue? Value);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Started;
|
||||
public record StartedEventArgs;
|
||||
@@ -4,6 +4,9 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Navigate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.3.24172.9" />
|
||||
|
||||
@@ -74,7 +74,7 @@ public class NavigateAction :
|
||||
ParameterBindings.Select(binding => new KeyValuePair<string, object>(binding.Key, binding.Value)).ToArray() :
|
||||
Enumerable.Empty<KeyValuePair<string, object>>()];
|
||||
|
||||
observableViewModel.Publisher.Publish(new Navigate(Route, Context == this ? control : Context, Scope ?? null,
|
||||
observableViewModel.Publisher.Publish(new NavigateEventArgs(Route, Context == this ? control : Context, Scope ?? null,
|
||||
control.DataContext, Navigated, parameters)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class NavigateBackAction :
|
||||
{
|
||||
if (control.DataContext is IObservableViewModel observableViewModel)
|
||||
{
|
||||
observableViewModel.Publisher.Publish(new NavigateBack(Context
|
||||
observableViewModel.Publisher.Publish(new NavigateBackEventArgs(Context
|
||||
?? null, Scope ?? null)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user