Command execution, CreateContainer command WIP

This commit is contained in:
2022-05-23 18:12:22 +02:00
parent 6b3a8f7127
commit d4bd9d3ba1
29 changed files with 499 additions and 26 deletions

View File

@@ -7,6 +7,7 @@ public class CommandTimeState
public ICommand Command { get; }
public CanCommandRun CanRun { get; private set; } = CanCommandRun.False;
public bool ForceRun { get; set; }
public ExecutionState ExecutionState { get; set; }
public CommandTimeState(ICommand command, PointInTime? startTime)
{

View File

@@ -0,0 +1,9 @@
using FileTime.Core.Command;
namespace FileTime.Core.Timeline;
public interface ICommandExecutor
{
void ExecuteCommand(ICommand command);
event EventHandler<ICommand> CommandFinished;
}

View File

@@ -1,6 +1,8 @@
using FileTime.Core.Command;
namespace FileTime.Core.Timeline;
public interface ICommandScheduler
{
Task AddCommand(ICommand command, int? batchId = null, bool toNewBatch = false);
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.Core.Timeline;
public interface ILocalCommandExecutor : ICommandExecutor
{
}

View File

@@ -5,7 +5,7 @@ namespace FileTime.Core.Timeline;
public class ParallelCommands
{
private static ushort _idCounter;
public List<CommandTimeState> _commands;
private List<CommandTimeState> _commands;
public ushort Id { get; }
public IReadOnlyList<CommandTimeState> Commands { get; }
public PointInTime? Result { get; private set; }

View File

@@ -2,10 +2,11 @@ namespace FileTime.Core.Timeline;
public class PointInTime
{
private readonly List<Difference> _differences;
public static readonly PointInTime Eternal = new PointInTime();
public static readonly PointInTime Present = new PointInTime();
private readonly List<Difference> _differences;
public IReadOnlyList<Difference> Differences { get; }
private PointInTime() : this(new List<Difference>())
@@ -26,6 +27,14 @@ public class PointInTime
public PointInTime WithDifferences(IEnumerable<Difference> differences) =>
new(this, differences);
public PointInTime WithDifferences(Func<PointInTime, IEnumerable<Difference>> differenceGenerator)
{
var newPointInTime = new PointInTime();
newPointInTime._differences.AddRange(differenceGenerator(newPointInTime));
return newPointInTime;
}
private static List<Difference> MergeDifferences(IEnumerable<Difference> previouses,
IEnumerable<Difference> differences)
{