RemoteContentProvider get items WIP

This commit is contained in:
2023-08-28 09:29:52 +02:00
parent 79971fe0f4
commit bb44ca0308
49 changed files with 765 additions and 118 deletions

View File

@@ -28,6 +28,7 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
private readonly IContainerSizeScanProvider _containerSizeScanProvider;
private readonly IProgramsService _programsService;
private readonly IContentProviderRegistry _contentProviderRegistry;
private readonly IServiceProvider _serviceProvider;
private readonly ILogger<ToolUserCommandHandlerService> _logger;
private IDeclarativeProperty<IContainer?>? _currentLocation;
private IDeclarativeProperty<IItemViewModel?>? _currentSelectedItem;
@@ -45,6 +46,7 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
IContainerSizeScanProvider containerSizeScanProvider,
IProgramsService programsService,
IContentProviderRegistry contentProviderRegistry,
IServiceProvider serviceProvider,
ILogger<ToolUserCommandHandlerService> logger) : base(appState)
{
_systemClipboardService = systemClipboardService;
@@ -57,6 +59,7 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
_containerSizeScanProvider = containerSizeScanProvider;
_programsService = programsService;
_contentProviderRegistry = contentProviderRegistry;
_serviceProvider = serviceProvider;
_logger = logger;
SaveCurrentLocation(l => _currentLocation = l);
SaveCurrentSelectedItem(i => _currentSelectedItem = i);
@@ -92,7 +95,7 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
Func<Task<IRemoteConnection>>? connection = null;
if (path.StartsWith("http"))
{
connection = async () => await SignalRConnection.GetOrCreateForAsync(path);
connection = async () => await SignalRConnection.GetOrCreateForAsync(path, providerName.Value);
}
if (connection is null)
@@ -109,15 +112,17 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
var remoteContentProvider = new RemoteContentProvider(
_timelessContentProvider,
_serviceProvider,
connection,
"local",
providerName.Value);
_contentProviderRegistry.AddContentProvider(remoteContentProvider);
await _userCommandHandlerService.HandleCommandAsync(
new OpenContainerCommand(new AbsolutePath(_timelessContentProvider, remoteContentProvider)));
await remoteContentProvider.InitializeChildren();
}
private Task Edit()

View File

@@ -13,7 +13,7 @@ namespace FileTime.App.Core;
public static class Startup
{
public static IServiceCollection AddCoreAppServices(this IServiceCollection serviceCollection, IConfigurationRoot configuration)
public static IServiceCollection AddAppCoreDependencies(this IServiceCollection serviceCollection, IConfigurationRoot configuration)
{
serviceCollection.TryAddTransient<ITabViewModel, TabViewModel>();
serviceCollection.TryAddTransient<IContainerViewModel, ContainerViewModel>();

View File

@@ -2,14 +2,7 @@ using FileTime.App.Core;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services;
using FileTime.App.Core.Services.Persistence;
using FileTime.Core.Command;
using FileTime.Core.Command.CreateContainer;
using FileTime.Core.Command.CreateElement;
using FileTime.Core.Command.Delete;
using FileTime.Core.CommandHandlers;
using FileTime.Core.ContentAccess;
using FileTime.Core.Services;
using FileTime.Core.Timeline;
using FileTime.Core;
using FileTime.Providers.Local;
using FileTime.Providers.LocalAdmin;
using FileTime.Providers.Remote;
@@ -25,36 +18,16 @@ public static class DependencyInjection
{
serviceCollection ??= new ServiceCollection();
serviceCollection.TryAddSingleton<ICommandScheduler, CommandScheduler>();
serviceCollection.TryAddSingleton<ITimelessContentProvider, TimelessContentProvider>();
serviceCollection.TryAddSingleton<ICommandRunner, CommandRunner>();
serviceCollection.TryAddSingleton<IContentAccessorFactory, ContentAccessorFactory>();
serviceCollection.TryAddSingleton<IContentProviderRegistry, ContentProviderRegistry>();
serviceCollection.TryAddSingleton<IRootContentProvider, RootContentProvider>();
//TODO: check local/remote context
serviceCollection.TryAddSingleton<ILocalCommandExecutor, LocalCommandExecutor>();
serviceCollection.TryAddSingleton<ICommandSchedulerNotifier, LocalCommandSchedulerNotifier>();
serviceCollection.TryAddSingleton<IApplicationSettings, ApplicationSettings>();
serviceCollection.TryAddSingleton<ITabPersistenceService, TabPersistenceService>();
serviceCollection.TryAddTransient<ITab, Tab>();
serviceCollection.TryAddSingleton<ITabEvents, TabEvents>();
serviceCollection.AddSingleton<IExitHandler, ITabPersistenceService>(sp => sp.GetRequiredService<ITabPersistenceService>());
serviceCollection.AddSingleton<IStartupHandler, ITabPersistenceService>(sp => sp.GetRequiredService<ITabPersistenceService>());
return serviceCollection
.AddCoreAppServices(configuration)
.AddCoreDependencies()
.AddAppCoreDependencies(configuration)
.AddLocalProviderServices()
.AddLocalAdminProviderServices(configuration)
.AddRemoteProviderServices()
.RegisterCommands()
.AddDefaultCommandHandlers();
.AddRemoteProviderServices();
}
private static IServiceCollection RegisterCommands(this IServiceCollection serviceCollection)
=> serviceCollection
.AddCommands()
.AddTransient<CreateContainerCommand>()
.AddTransient<CreateElementCommand>()
.AddTransient<DeleteCommand>();
}

View File

@@ -15,6 +15,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\FileTime.Core.CommandHandlers\FileTime.Core.CommandHandlers.csproj" />
<ProjectReference Include="..\..\Core\FileTime.Core.Extensions.DependencyInjection\FileTime.Core.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\Core\FileTime.Core.Serialization\FileTime.Core.Serialization.csproj" />
<ProjectReference Include="..\..\Core\FileTime.Core.Timeline\FileTime.Core.Timeline.csproj" />
<ProjectReference Include="..\..\Providers\FileTime.Providers.LocalAdmin\FileTime.Providers.LocalAdmin.csproj" />
<ProjectReference Include="..\..\Providers\FileTime.Providers.Local\FileTime.Providers.Local.csproj" />