tidy up
This commit is contained in:
@@ -8,9 +8,11 @@ public class TemplateFactory(IEnumerable<IContentTemplateDescriptor> descriptors
|
||||
{
|
||||
public object? Create(object key)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Key == key) is IContentTemplateDescriptor descriptor)
|
||||
if (descriptors.FirstOrDefault(x => x.Key == key)
|
||||
is IContentTemplateDescriptor descriptor)
|
||||
{
|
||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType, descriptor.Key) is { } template)
|
||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType,
|
||||
descriptor.Key) is { } template)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.MediaController.Windows;
|
||||
|
||||
public sealed partial class MediaButtonView :
|
||||
public partial class MediaButtonView :
|
||||
UserControl
|
||||
{
|
||||
public MediaButtonView() =>
|
||||
this.InitializeComponent(ref _contentLoaded);
|
||||
|
||||
private IMediaButtonViewModel ViewModel => (IMediaButtonViewModel)DataContext;
|
||||
protected IMediaButtonViewModel ViewModel =>
|
||||
(IMediaButtonViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace Hyperbar.Widget.MediaController.Windows;
|
||||
public class MediaControllerHandler(IMediator mediator,
|
||||
IServiceScopeProvider<MediaController> scopeProvider,
|
||||
ICache<MediaController, MediaControllerViewModel> cache) :
|
||||
INotificationHandler<Created<MediaController>>,
|
||||
INotificationHandler<Removed<MediaController>>
|
||||
INotificationHandler<Create<MediaController>>,
|
||||
INotificationHandler<Remove<MediaController>>
|
||||
{
|
||||
public async Task Handle(Created<MediaController> notification,
|
||||
public async Task Handle(Create<MediaController> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is MediaController mediaController &&
|
||||
@@ -18,17 +18,17 @@ public class MediaControllerHandler(IMediator mediator,
|
||||
factory.Create(mediaController) is MediaControllerViewModel viewModel)
|
||||
{
|
||||
cache.Add(mediaController, viewModel);
|
||||
await mediator.PublishAsync(new Created<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||
await mediator.PublishAsync(new Create<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Handle(Removed<MediaController> notification, CancellationToken cancellationToken)
|
||||
public async Task Handle(Remove<MediaController> notification, CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is MediaController mediaController &&
|
||||
cache.TryGetValue(mediaController, out MediaControllerViewModel? viewModel) &&
|
||||
viewModel is not null)
|
||||
{
|
||||
await mediator.PublishAsync(new Removed<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||
await mediator.PublishAsync(new Remove<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||
cache.Remove(mediaController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MediaControllerService(IMediator mediator,
|
||||
{
|
||||
if (factory.Create(session) is MediaController mediaController)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<MediaController>(mediaController));
|
||||
await mediator.PublishAsync(new Create<MediaController>(mediaController));
|
||||
cache.Add(new KeyValuePair<GlobalSystemMediaTransportControlsSession, MediaController>(session,
|
||||
mediaController));
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class MediaControllerService(IMediator mediator,
|
||||
{
|
||||
if (!sessions.Any(x => x.SourceAppUserModelId == session.Key.SourceAppUserModelId))
|
||||
{
|
||||
await mediator.PublishAsync(new Removed<MediaController>(session.Value));
|
||||
await mediator.PublishAsync(new Remove<MediaController>(session.Value));
|
||||
cache.Remove(session);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
HorizontalAlignment="Right"
|
||||
HorizontalContentAlignment="Right"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemsSource="{Binding}">
|
||||
ItemsSource="{x:Bind ViewModel}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" />
|
||||
|
||||
@@ -3,9 +3,12 @@ using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.MediaController.Windows;
|
||||
|
||||
public sealed partial class MediaControllerView :
|
||||
public partial class MediaControllerView :
|
||||
UserControl
|
||||
{
|
||||
public MediaControllerView() =>
|
||||
this.InitializeComponent(ref _contentLoaded);
|
||||
|
||||
protected MediaControllerViewModel ViewModel =>
|
||||
(MediaControllerViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.MediaController.Windows;
|
||||
|
||||
public sealed partial class MediaControllerWidgetView :
|
||||
public partial class MediaControllerWidgetView :
|
||||
UserControl
|
||||
{
|
||||
public MediaControllerWidgetView() =>
|
||||
this.InitializeComponent(ref _contentLoaded);
|
||||
|
||||
protected MediaControllerWidgetViewModel ViewModel =>
|
||||
(MediaControllerWidgetViewModel)DataContext;
|
||||
}
|
||||
@@ -3,11 +3,12 @@ using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.MediaController.Windows;
|
||||
|
||||
public sealed partial class MediaInformationView :
|
||||
public partial class MediaInformationView :
|
||||
UserControl
|
||||
{
|
||||
public MediaInformationView() =>
|
||||
this.InitializeComponent(ref _contentLoaded);
|
||||
|
||||
private MediaInformationViewModel ViewModel => (MediaInformationViewModel)DataContext;
|
||||
protected MediaInformationViewModel ViewModel =>
|
||||
(MediaInformationViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
||||
if (moved.Value is PrimaryCommandConfiguration configuration &&
|
||||
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
||||
{
|
||||
await mediator.PublishAsync(new Moved<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||
await mediator.PublishAsync(new Move<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||
moved.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : moved.Key.ParentId,
|
||||
cancellationToken);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
||||
factory.Create(configuration) is IWidgetComponentViewModel viewModel)
|
||||
{
|
||||
await mediator.PublishAsync(
|
||||
new Inserted<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||
new Insert<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||
added.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : added.Key.ParentId,
|
||||
cancellationToken);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
||||
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
||||
{
|
||||
await mediator.PublishAsync(
|
||||
new Removed<IWidgetComponentViewModel>(viewModel),
|
||||
new Remove<IWidgetComponentViewModel>(viewModel),
|
||||
removed.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : removed.Key.ParentId,
|
||||
cancellationToken);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration confi
|
||||
{
|
||||
if (factory.Create(item) is IWidgetComponentViewModel viewModel)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
|
||||
await mediator.PublishAsync(new Create<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class WidgetExtensionEnumerator(IFactory<Type, IWidget> factory,
|
||||
{
|
||||
if (factory.Create(widgetType) is IWidget widget)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<WidgetExtension>(new WidgetExtension(widget,
|
||||
await mediator.PublishAsync(new Create<WidgetExtension>(new WidgetExtension(widget,
|
||||
new WidgetAssembly(assembly))), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Hyperbar.Widget;
|
||||
public class WidgetExtensionHandler(IServiceProvider provider,
|
||||
IMediator mediator,
|
||||
IProxyServiceCollection<IWidgetBuilder> typedServices) :
|
||||
INotificationHandler<Created<WidgetExtension>>
|
||||
INotificationHandler<Create<WidgetExtension>>
|
||||
{
|
||||
public async Task Handle(Created<WidgetExtension> notification,
|
||||
public async Task Handle(Create<WidgetExtension> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if(notification.Value is WidgetExtension widgetExtension)
|
||||
@@ -22,7 +22,7 @@ public class WidgetExtensionHandler(IServiceProvider provider,
|
||||
});
|
||||
|
||||
IWidgetHost host = builder.Build();
|
||||
await mediator.PublishAsync(new Created<IWidgetHost>(host),
|
||||
await mediator.PublishAsync(new Create<IWidgetHost>(host),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetHostHandler :
|
||||
INotificationHandler<Created<IWidgetHost>>
|
||||
INotificationHandler<Create<IWidgetHost>>
|
||||
{
|
||||
public async Task Handle(Created<IWidgetHost> notification,
|
||||
public async Task Handle(Create<IWidgetHost> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is IWidgetHost host)
|
||||
|
||||
@@ -12,7 +12,7 @@ public class WidgetStartedHandler(IMediator mediator) :
|
||||
{
|
||||
if (host.Services.GetService<IWidgetViewModel>() is IWidgetViewModel viewModel)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<IWidgetViewModel>(viewModel),
|
||||
await mediator.PublishAsync(new Create<IWidgetViewModel>(viewModel),
|
||||
nameof(IWidgetHostViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class WidgetViewModelEnumerator(IWidgetHost host,
|
||||
{
|
||||
foreach (IWidgetViewModel viewModel in viewModels)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<IWidgetViewModel>(viewModel),
|
||||
await mediator.PublishAsync(new Create<IWidgetViewModel>(viewModel),
|
||||
nameof(IWidgetHostViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public partial class App :
|
||||
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
||||
|
||||
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
||||
services.AddContentTemplate<SettingsView, SettingsView>("Settings");
|
||||
|
||||
services.AddTransient<IInitializer, AppInitializer>();
|
||||
})
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ItemsControl
|
||||
Margin="6,0,6,0"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemsSource="{Binding}">
|
||||
ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class ApplicationBarView :
|
||||
public partial class ApplicationBarView :
|
||||
UserControl
|
||||
{
|
||||
public ApplicationBarView() => InitializeComponent();
|
||||
public ApplicationBarView() =>
|
||||
InitializeComponent();
|
||||
protected ApplicationBarViewModel ViewModel =>
|
||||
(ApplicationBarViewModel)DataContext;
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
<None Remove="PrimaryView.xaml" />
|
||||
<None Remove="SecondaryView.xaml" />
|
||||
<None Remove="SettingsButtonView.xaml" />
|
||||
<None Remove="SettingsView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
@@ -54,6 +55,11 @@
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="SettingsView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="SettingsButtonView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Center"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemsSource="{Binding}">
|
||||
ItemsSource="{x:Bind ViewModel}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
namespace Hyperbar.Windows
|
||||
public partial class PrimaryView :
|
||||
UserControl
|
||||
{
|
||||
public sealed partial class PrimaryView : UserControl
|
||||
{
|
||||
public PrimaryView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
public PrimaryView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected PrimaryViewModel ViewModel =>
|
||||
(PrimaryViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
<Grid>
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
namespace Hyperbar.Windows
|
||||
public partial class SecondaryView :
|
||||
UserControl
|
||||
{
|
||||
public sealed partial class SecondaryView : UserControl
|
||||
{
|
||||
public SecondaryView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
public SecondaryView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected SecondaryViewModel ViewModel =>
|
||||
(SecondaryViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.SettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows
|
||||
{
|
||||
public sealed partial class SettingsView :
|
||||
UserControl
|
||||
{
|
||||
public SettingsView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hyperbar.Windows
|
||||
{
|
||||
internal class SettingsViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Create<TValue>(TValue Value, object? Target = null) :
|
||||
INotification;
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Insert<TValue>(int Index, TValue Value) : INotification;
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Move<TValue>(int Index, TValue Value) : INotification;
|
||||
@@ -15,11 +15,11 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
IList,
|
||||
IReadOnlyList<TItem>,
|
||||
INotifyCollectionChanged,
|
||||
INotificationHandler<Removed<TItem>>,
|
||||
INotificationHandler<Created<TItem>>,
|
||||
INotificationHandler<Inserted<TItem>>,
|
||||
INotificationHandler<Moved<TItem>>,
|
||||
INotificationHandler<Replaced<TItem>>,
|
||||
INotificationHandler<Remove<TItem>>,
|
||||
INotificationHandler<Create<TItem>>,
|
||||
INotificationHandler<Insert<TItem>>,
|
||||
INotificationHandler<Move<TItem>>,
|
||||
INotificationHandler<Replace<TItem>>,
|
||||
IDisposable,
|
||||
IInitialization
|
||||
where TItem :
|
||||
@@ -206,7 +206,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
IEnumerator IEnumerable.GetEnumerator() =>
|
||||
((IEnumerable)collection).GetEnumerator();
|
||||
|
||||
public Task Handle(Removed<TItem> notification,
|
||||
public Task Handle(Remove<TItem> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (TItem item in this.ToList())
|
||||
@@ -220,7 +220,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Created<TItem> notification,
|
||||
public Task Handle(Create<TItem> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is TItem item)
|
||||
@@ -231,7 +231,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Inserted<TItem> notification,
|
||||
public Task Handle(Insert<TItem> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is TItem item)
|
||||
@@ -242,7 +242,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Moved<TItem> notification,
|
||||
public Task Handle(Move<TItem> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is TItem item)
|
||||
@@ -253,7 +253,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Replaced<TItem> notification,
|
||||
public Task Handle(Replace<TItem> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.Value is TItem item)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Remove<TValue>(TValue Value) : INotification;
|
||||
|
||||
public record Navigate(object Key) :
|
||||
INotification;
|
||||
|
||||
public class NavigateHandler :
|
||||
INotificationHandler<Navigate>
|
||||
{
|
||||
private readonly IEnumerable<IContentTemplateDescriptor> descriptors;
|
||||
|
||||
public NavigateHandler(IEnumerable<IContentTemplateDescriptor> descriptors,
|
||||
IServiceProvider provider)
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public Task Handle(Navigate args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Key == args.Key)
|
||||
is IContentTemplateDescriptor descriptor)
|
||||
{
|
||||
//if (provider.GetRequiredKeyedService(descriptor.TemplateType,
|
||||
// descriptor.Key) is { } template)
|
||||
//{
|
||||
// return template;
|
||||
//}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Replace<TValue>(int Index, TValue Value, object? Target = null) :
|
||||
INotification;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Created<TValue>(TValue Value, object? Target = null) :
|
||||
INotification;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Inserted<TValue>(int Index, TValue Value) : INotification;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Moved<TValue>(int Index, TValue Value) : INotification;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Removed<TValue>(TValue Value) : INotification;
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public record Replaced<TValue>(int Index, TValue Value, object? Target = null) :
|
||||
INotification;
|
||||
|
||||
Reference in New Issue
Block a user