namespace FileTime.Core.Timeline; public class PointInTime { public static readonly PointInTime Eternal = new PointInTime(); public static readonly PointInTime Present = new PointInTime(); private readonly List _differences; public IReadOnlyList Differences { get; } private PointInTime() : this(new List()) { } private PointInTime(IEnumerable differences) { _differences = new List(differences); Differences = _differences.AsReadOnly(); } private PointInTime(PointInTime previous, IEnumerable differences) : this(MergeDifferences(previous.Differences, differences)) { } public PointInTime WithDifferences(IEnumerable differences) => new(this, differences); public PointInTime WithDifferences(Func> differenceGenerator) { var newPointInTime = new PointInTime(); newPointInTime._differences.AddRange(differenceGenerator(newPointInTime)); return newPointInTime; } private static List MergeDifferences(IEnumerable previouses, IEnumerable differences) { var merged = new List(); merged.AddRange(previouses); merged.AddRange(differences); return merged; } public static PointInTime CreateEmpty() => new PointInTime(); }