forked from SharpRepository/SharpDiff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiffFileSection.cs
More file actions
54 lines (42 loc) · 1.52 KB
/
DiffFileSection.cs
File metadata and controls
54 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
namespace SharpDiff.Formatter
{
public class DiffFileSection
{
public DiffFileSection(string description)
{
Lines = new List<DiffLine>();
var shortDescription = description.Substring(0, description.IndexOf("@@", 3) + 2);
Description = description;
var parts = shortDescription.Replace("@@", "").Trim().Split(' ');
OldLineNumber = Int32.Parse(parts[0].Split(',')[0].Replace("-", "")) - 1;
NewLineNumber = Int32.Parse(parts[1].Split(',')[0].Replace("+", "")) - 1;
}
public string Description { get; set; }
public IList<DiffLine> Lines { get; set; }
public int OldLineNumber { get; set; }
public int NewLineNumber { get; set; }
public void AddLine(DiffLine line)
{
switch (line.LineChangeType)
{
case LineChangeType.Add:
NewLineNumber++;
line.NewLineNumber = NewLineNumber;
break;
case LineChangeType.Delete:
OldLineNumber++;
line.OldLineNumber = OldLineNumber;
break;
default:
NewLineNumber++;
OldLineNumber++;
line.NewLineNumber = NewLineNumber;
line.OldLineNumber = OldLineNumber;
break;
}
Lines.Add(line);
}
}
}