public IndexCollection(IReadOnlyCollection<Index> latest, IndexCollection previous, FileInfo info, Encoding encoding) { Info = info; Encoding = encoding; Count = latest.Select(idx => idx.LineCount).Sum(); Indicies = latest.ToArray(); Diff = Count - (previous?.Count ?? 0); //need to check whether if (previous == null) { ChangedReason = LinesChangedReason.Loaded; TailInfo = new TailInfo(latest.Max(idx => idx.End)); } else { var mostRecent = latest.OrderByDescending(l => l.TimeStamp).First(); ChangedReason = mostRecent.Type == IndexType.Tail ? LinesChangedReason.Tailed : LinesChangedReason.Paged; TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End)); } }
public IndexCollection(IReadOnlyCollection<Index> latest, IndexCollection previous, FileInfo info, Encoding encoding) { Info = info; Encoding = encoding; Count = latest.Select(idx => idx.LineCount).Sum(); Indicies = latest.ToArray(); Diff = Count - (previous?.Count ?? 0); //need to check whether if (previous == null) { TailInfo = new TailInfo(latest.Max(idx => idx.End)); } else { TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End)); } }