private IEnumerable <LineViewModel> GetLineViewModelsFromHunks(Hunk[] hunks) { var lines = new List <LineViewModel>(); foreach (var hunk in hunks) { foreach (var hunkLine in hunk.Lines) { var details = new LineDetailsViewModel( hunkLine.NumberInSourceFile, hunkLine.NumberInTargetFile, this.mergeRequest, this.change, this.service); var lineVm = new LineViewModel( hunkLine.NumberInChanges, hunkLine.NumberInSourceFile, hunkLine.NumberInTargetFile, hunkLine.Text, details); lines.Add(lineVm); } } return(lines); }
private IEnumerable <LineViewModel> GetLineViewModelsFromGaps(Gap[] gaps, string[] sourceLines) { var viewModelsFromGaps = new List <LineViewModel>(); foreach (var gap in gaps) { for (var i = 0; i < gap.Length; i++) { var numberInSourceFile = gap.StartInSourceFile + i; var numberInTargetFile = gap.StartInTargetFile + i; var numberInChanges = gap.StartInChanges + i; var indexInSourceFile = numberInSourceFile - 1; var line = sourceLines[indexInSourceFile]; var lineVm = new LineViewModel(numberInChanges, numberInSourceFile, numberInTargetFile, line); viewModelsFromGaps.Add(lineVm); } } return(viewModelsFromGaps); }