Xnlab.SQLMon.Diff.DiffResultSpan.AddLength C# (CSharp) Method

AddLength() public method

public AddLength ( int i ) : void
i int
return void
        public void AddLength(int i)
        {
            _length += i;
        }

Usage Example

Ejemplo n.º 1
0
        public List <DiffResultSpan> DiffReport()
        {
            var retval = new List <DiffResultSpan>();
            var dcount = _dest.Count();
            var scount = _source.Count();

            //Deal with the special case of empty files
            if (dcount == 0)
            {
                if (scount > 0)
                {
                    retval.Add(DiffResultSpan.CreateDeleteSource(0, scount));
                }
                return(retval);
            }
            else
            {
                if (scount == 0)
                {
                    retval.Add(DiffResultSpan.CreateAddDestination(0, dcount));
                    return(retval);
                }
            }


            _matchList.Sort();
            var            curDest   = 0;
            var            curSource = 0;
            DiffResultSpan last      = null;

            //Process each match record
            foreach (var drs in _matchList)
            {
                if ((!AddChanges(retval, curDest, drs.DestIndex, curSource, drs.SourceIndex)) &&
                    (last != null))
                {
                    last.AddLength(drs.Length);
                }
                else
                {
                    retval.Add(drs);
                }
                curDest   = drs.DestIndex + drs.Length;
                curSource = drs.SourceIndex + drs.Length;
                last      = drs;
            }

            //Process any tail end data
            AddChanges(retval, curDest, dcount, curSource, scount);

            return(retval);
        }