public string ToStagePatch(bool staged) { SubChunkToPatchFnc subChunkToPatch = (SubChunk subChunk, ref int addedCount, ref int removedCount, ref bool wereSelectedLines) => { return(subChunk.ToStagePatch(ref addedCount, ref removedCount, ref wereSelectedLines, staged)); }; return(ToPatch(subChunkToPatch)); }
protected string ToPatch(SubChunkToPatchFnc subChunkToPatch) { string result = null; foreach (Chunk chunk in this) { result = result.Combine("\n", chunk.ToPatch(subChunkToPatch)); } if (result != null) { result = result.Combine("\n", "--"); result = result.Combine("\n", Application.ProductName + " " + AppSettings.ProductVersion); } return(result); }
public string ToPatch(SubChunkToPatchFnc subChunkToPatch) { bool wereSelectedLines = false; string diff = null; int addedCount = 0; int removedCount = 0; foreach (SubChunk subChunk in SubChunks) { string subDiff = subChunkToPatch(subChunk, ref addedCount, ref removedCount, ref wereSelectedLines); diff = diff.Combine("\n", subDiff); } if (!wereSelectedLines) { return(null); } diff = "@@ -" + StartLine + "," + removedCount + " +" + StartLine + "," + addedCount + " @@".Combine("\n", diff); return(diff); }
public void ToPatch(SubChunkToPatchFnc subChunkToPatch, StringBuilder str) { bool wereSelectedLines = false; int addedCount = 0; int removedCount = 0; var diff = new StringBuilder(); foreach (SubChunk subChunk in _subChunks) { if (diff.Length != 0) { diff.Append('\n'); } diff.Append(subChunkToPatch(subChunk, ref addedCount, ref removedCount, ref wereSelectedLines)); } if (wereSelectedLines) { str.Append($"@@ -{_startLine},{removedCount} +{_startLine},{addedCount} @@\n"); str.Append(diff); } }
private static string ToPatch([NotNull, ItemNotNull] IEnumerable <Chunk> chunks, [NotNull, InstantHandle] SubChunkToPatchFnc subChunkToPatch) { var result = new StringBuilder(); foreach (Chunk chunk in chunks) { if (result.Length != 0) { result.Append('\n'); } chunk.ToPatch(subChunkToPatch, result); } if (result.Length == 0) { return(null); } result.Append($"\n--\n{Application.ProductName} {AppSettings.ProductVersion}"); return(result.ToString()); }