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));
            }
        }
Example #2
0
        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));
            }
        }
Example #3
0
        public IndexCollection(IReadOnlyCollection <Index> latest,
                               IndexCollection previous,
                               FileInfo info,
                               Encoding encoding)
        {
            Info     = info;
            Encoding = encoding;
            Count    = latest.Select(idx => idx.LineCount).Sum();
            Indicies = latest /*.GroupBy(c => c.LineCount).Select(g => g.FirstOrDefault())*/.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));

                Previous                 = previous;
                previous.Next            = this;
                NumberOfPreviousProvider = previous.NumberOfPreviousProvider + 1;

                //var prevPointer = previous;
                ////find the modified file and replace from the list
                //while (prevPointer != null)
                //{
                //    var lastPrevPointer = prevPointer;
                //    if (prevPointer.Info.FullName == Info.FullName)
                //    {
                //        Next = prevPointer.Next;
                //        Previous = prevPointer.Previous;
                //        lastPrevPointer.Previous = this;
                //        prevPointer.Previous = null;
                //        prevPointer.Next = null;
                //        NumberOfPreviousProvider = prevPointer.NumberOfPreviousProvider;
                //        return;
                //    }
                //    prevPointer = prevPointer.Previous as IndexCollection;
                //}
            }
        }
Example #4
0
        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));
            }
        }
Example #5
0
        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));
            }
        }