// leftLineNumber and rightLineNumber are one-based private static DiffContext.Line getLineContext(int?leftLineNumber, int?rightLineNumber, string leftLine, string rightLine) { DiffContext.Line.Side?leftSide = null; DiffContext.Line.Side?rightSide = null; string text = String.Empty; if (leftLineNumber.HasValue && rightLineNumber.HasValue) { Debug.Assert(leftLine == rightLine); leftSide = new DiffContext.Line.Side(leftLineNumber.Value, DiffContext.Line.State.Unchanged); rightSide = new DiffContext.Line.Side(rightLineNumber.Value, DiffContext.Line.State.Unchanged); text = leftLine; } else if (leftLineNumber.HasValue) { leftSide = new DiffContext.Line.Side(leftLineNumber.Value, DiffContext.Line.State.Changed); text = leftLine; } else if (rightLineNumber.HasValue) { rightSide = new DiffContext.Line.Side(rightLineNumber.Value, DiffContext.Line.State.Changed); text = rightLine; } else { Debug.Assert(false); } return(new DiffContext.Line(text, leftSide, rightSide)); }
// linenumber is one-based private static DiffContext.Line getContextLine(int linenumber, bool isRightSideContext, string text) { DiffContext.Line line = new DiffContext.Line { Text = text }; DiffContext.Line.Side side = new DiffContext.Line.Side { Number = linenumber, // this 'maker' cannot distinguish between modified and unmodified lines State = DiffContext.Line.State.Changed }; if (isRightSideContext) { line.Right = side; } else { line.Left = side; } return(line); }
// linenumber is one-based private static DiffContext.Line getContextLine(int linenumber, bool isRightSideContext, string text) { // this 'maker' cannot distinguish between modified and unmodified lines DiffContext.Line.Side side = new DiffContext.Line.Side(linenumber, DiffContext.Line.State.Changed); return(new DiffContext.Line(text, isRightSideContext ? new DiffContext.Line.Side?() : side, isRightSideContext ? side : new DiffContext.Line.Side?())); }
private static DiffContext.Line.Side getSide(int lineNumber, DiffContext.Line.State state) { DiffContext.Line.Side side = new DiffContext.Line.Side { Number = lineNumber, State = state }; return(side); }
// linenumber is one-based private DiffContext.Line getLineContext(int linenumber, bool isRightSideContext, IEnumerable <string> contents, DiffPosition position) { Debug.Assert(linenumber > 0 && linenumber <= contents.Count()); // this maker supports all three states DiffContext.Line.Side side = new DiffContext.Line.Side( linenumber, getLineState(linenumber, isRightSideContext, position)); return(new DiffContext.Line(contents.ElementAt(linenumber - 1), isRightSideContext ? new DiffContext.Line.Side?() : side, isRightSideContext ? side : new DiffContext.Line.Side?())); }