Tidy
This commit is contained in:
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class ClassicDesktopStyleApplicationHandler :
|
public class ClassicDesktopStyleApplicationHandler :
|
||||||
INavigateHandler<IClassicDesktopStyleApplicationLifetime>
|
INotificationHandler<NavigateEventArgs<IClassicDesktopStyleApplicationLifetime>>
|
||||||
{
|
{
|
||||||
public Task Handle(NavigateEventArgs<IClassicDesktopStyleApplicationLifetime> args)
|
public Task Handle(NavigateEventArgs<IClassicDesktopStyleApplicationLifetime> args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class ContentControlHandler :
|
public class ContentControlHandler :
|
||||||
INavigateHandler<ContentControl>
|
INotificationHandler<NavigateEventArgs<ContentControl>>
|
||||||
{
|
{
|
||||||
public async Task Handle(NavigateEventArgs<ContentControl> args)
|
public async Task Handle(NavigateEventArgs<ContentControl> args)
|
||||||
{
|
{
|
||||||
@@ -19,11 +19,6 @@ public class ContentControlHandler :
|
|||||||
control.Loaded -= HandleLoaded;
|
control.Loaded -= HandleLoaded;
|
||||||
if (control.DataContext is object content)
|
if (control.DataContext is object content)
|
||||||
{
|
{
|
||||||
if (content is IInitialization initializer)
|
|
||||||
{
|
|
||||||
await initializer.Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content is IActivated activated)
|
if (content is IActivated activated)
|
||||||
{
|
{
|
||||||
await activated.OnActivated();
|
await activated.OnActivated();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Toolkit.UI.Controls.Avalonia;
|
|||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class ContentDialogHandler(IDispatcher dispatcher) :
|
public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||||
INavigateHandler<ContentDialog>
|
INotificationHandler<NavigateEventArgs<ContentDialog>>
|
||||||
{
|
{
|
||||||
public async Task Handle(NavigateEventArgs<ContentDialog> args)
|
public async Task Handle(NavigateEventArgs<ContentDialog> args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ using Toolkit.UI.Controls.Avalonia;
|
|||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class FrameHandler :
|
public class FrameHandler :
|
||||||
INavigateHandler<Frame>,
|
INotificationHandler<NavigateEventArgs<Frame>>,
|
||||||
INavigateBackHandler<Frame>
|
INotificationHandler<NavigateBackEventArgs<Frame>>
|
||||||
{
|
{
|
||||||
public Task Handle(NavigateEventArgs<Frame> args)
|
public Task Handle(NavigateEventArgs<Frame> args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class SingleViewApplicationHandler :
|
public class SingleViewApplicationHandler :
|
||||||
INavigateHandler<ISingleViewApplicationLifetime>
|
INotificationHandler<NavigateEventArgs<ISingleViewApplicationLifetime>>
|
||||||
{
|
{
|
||||||
public Task Handle(NavigateEventArgs<ISingleViewApplicationLifetime> args)
|
public Task Handle(NavigateEventArgs<ISingleViewApplicationLifetime> args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,13 @@ public class ContentFactory(IMediator mediator,
|
|||||||
initialization.Initialize();
|
initialization.Initialize();
|
||||||
}
|
}
|
||||||
}, parameters)
|
}, parameters)
|
||||||
: provider.GetRequiredKeyedService(descriptor.ContentType, descriptor.Key);
|
: provider.GetRequiredKeyedService(descriptor.ContentType, args =>
|
||||||
|
{
|
||||||
|
if (args is IInitialization initialization)
|
||||||
|
{
|
||||||
|
initialization.Initialize();
|
||||||
|
}
|
||||||
|
}, descriptor.Key);
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
namespace Toolkit.Foundation;
|
|
||||||
|
|
||||||
public interface INavigateBackHandler<TNavigation> :
|
|
||||||
INotificationHandler<NavigateBackEventArgs<TNavigation>>,
|
|
||||||
INavigateHandler;
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace Toolkit.Foundation;
|
|
||||||
|
|
||||||
public interface INavigateHandler;
|
|
||||||
|
|
||||||
public interface INavigateHandler<TNavigation> :
|
|
||||||
INotificationHandler<NavigateEventArgs<TNavigation>>,
|
|
||||||
INavigateHandler;
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
|
public static class IServiceProviderExtensions
|
||||||
|
{
|
||||||
|
public static object GetRequiredKeyedService(this IServiceProvider provider,
|
||||||
|
Type serviceType,
|
||||||
|
Action<object> serviceDelegate,
|
||||||
|
object? serviceKey)
|
||||||
|
{
|
||||||
|
object service = provider.GetRequiredKeyedService(serviceType, serviceKey);
|
||||||
|
serviceDelegate.Invoke(service);
|
||||||
|
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,7 +96,7 @@ public class NavigationScope(IServiceProvider provider,
|
|||||||
Type navigateType = typeof(NavigateBackEventArgs<>).MakeGenericType(navigationType);
|
Type navigateType = typeof(NavigateBackEventArgs<>).MakeGenericType(navigationType);
|
||||||
if (Activator.CreateInstance(navigateType, [region]) is object navigate)
|
if (Activator.CreateInstance(navigateType, [region]) is object navigate)
|
||||||
{
|
{
|
||||||
publisher.Publish(navigate);
|
publisher.Publish(navigate, navigationType.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
IsCompatibleObject(value) ?
|
IsCompatibleObject(value) ?
|
||||||
IndexOf((TItem)value!) : -1;
|
IndexOf((TItem)value!) : -1;
|
||||||
|
|
||||||
public Task Initialize()
|
public virtual Task Initialize()
|
||||||
{
|
{
|
||||||
if (Initialized)
|
if (Initialized)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user