CopyCommandFactory, Copy status
This commit is contained in:
@@ -5,11 +5,11 @@ namespace FileTime.App.Core.Services;
|
||||
|
||||
public interface IClipboardService
|
||||
{
|
||||
Type? CommandType { get; }
|
||||
Type? CommandFactoryType { get; }
|
||||
IReadOnlyList<FullName> Content { get; }
|
||||
|
||||
void AddContent(FullName absolutePath);
|
||||
void RemoveContent(FullName absolutePath);
|
||||
void Clear();
|
||||
void SetCommand<T>() where T : ITransportationCommand;
|
||||
void SetCommand<T>() where T : ITransportationCommandFactory;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class ClipboardService : IClipboardService
|
||||
{
|
||||
private List<FullName> _content;
|
||||
public IReadOnlyList<FullName> Content { get; private set; }
|
||||
public Type? CommandType { get; private set; }
|
||||
public Type? CommandFactoryType { get; private set; }
|
||||
|
||||
public ClipboardService()
|
||||
{
|
||||
@@ -40,11 +40,11 @@ public class ClipboardService : IClipboardService
|
||||
{
|
||||
_content = new List<FullName>();
|
||||
Content = _content.AsReadOnly();
|
||||
CommandType = null;
|
||||
CommandFactoryType = null;
|
||||
}
|
||||
|
||||
public void SetCommand<T>() where T : ITransportationCommand
|
||||
public void SetCommand<T>() where T : ITransportationCommandFactory
|
||||
{
|
||||
CommandType = typeof(T);
|
||||
CommandFactoryType = typeof(T);
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
private Task Copy()
|
||||
{
|
||||
_clipboardService.Clear();
|
||||
_clipboardService.SetCommand<FileTime.Core.Command.Copy.CopyCommand>();
|
||||
_clipboardService.SetCommand<FileTime.Core.Command.Copy.CopyCommandFactory>();
|
||||
|
||||
if ((_markedItems?.Collection?.Count ?? 0) > 0)
|
||||
{
|
||||
@@ -120,23 +120,15 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
|
||||
private async Task Paste(TransportMode mode)
|
||||
{
|
||||
if (_clipboardService.CommandType is null)
|
||||
if (_clipboardService.CommandFactoryType is null)
|
||||
{
|
||||
_userCommunicationService.ShowToastMessage("Clipboard is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
var command = (ITransportationCommand) _serviceProvider.GetRequiredService(_clipboardService.CommandType);
|
||||
command.TransportMode = mode;
|
||||
|
||||
command.Sources.Clear();
|
||||
|
||||
foreach (var item in _clipboardService.Content)
|
||||
{
|
||||
command.Sources.Add(item);
|
||||
}
|
||||
|
||||
command.Target = _currentLocation?.FullName;
|
||||
//TODO: check _currentLocation?.FullName
|
||||
var commandFactory = (ITransportationCommandFactory) _serviceProvider.GetRequiredService(_clipboardService.CommandFactoryType);
|
||||
var command = commandFactory.GenerateCommand(_clipboardService.Content, mode, _currentLocation?.FullName);
|
||||
|
||||
_clipboardService.Clear();
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public static class DependencyInjection
|
||||
private static IServiceCollection RegisterCommands(this IServiceCollection serviceCollection)
|
||||
{
|
||||
return serviceCollection
|
||||
.AddCommands()
|
||||
.AddTransient<CreateContainerCommand>()
|
||||
.AddTransient<CreateElementCommand>()
|
||||
.AddTransient<CopyCommand>()
|
||||
|
||||
Reference in New Issue
Block a user