public static void SetBefore(DependencyObject obj, SideBySideDiffModel value) { obj.SetValue(BeforeProperty, value); }
/// <summary> /// 差分前後の文字を比較表示 /// </summary> public static string ToDisplayString(this SideBySideDiffModel ssDiff) => $"{ssDiff.OldText.ToRawText()}->{ssDiff.NewText.ToRawText()}";
public static void SetVorher(DependencyObject obj, SideBySideDiffModel value) { obj.SetValue(VorherProperty, value); }
public SideBySideDiffModel GetMergedText(SideBySideDiffModel model) { throw new NotImplementedException(); }
public FileDifferences(string fileName, SideBySideDiffModel differences) { FileName = fileName; Differences = differences; }
// Handle fileSystemWatcher update private static void fsw_Changed(object sender, FileSystemEventArgs e) { // Make sure file/directory still exists - otherwise, remove it from the list of tracked files if (!File.Exists(e.FullPath)) { string dumpPath = getDumpPath(e.FullPath); if (trackedLocations.ContainsKey(e.FullPath)) { trackedLocations.Remove(e.FullPath); } else if (trackedLocations.ContainsKey(dumpPath)) { trackedLocations.Remove(dumpPath); } // Skip this file since it no longer exists return; } // --- Get changes --- // Get old/new filepaths string oldText = File.ReadAllText(getDumpPath(e.FullPath)); string newText = File.ReadAllText(e.FullPath); // Get diff object model = new SideBySideDiffModel(); DiffResult lineDiffs = differ.CreateLineDiffs(oldText, newText, true, true); // If nothing actually changed, move along if (lineDiffs.DiffBlocks.Count == 0) { return; } // Calculate LOC change int locChanged = 0; for (int i = 0; i < lineDiffs.DiffBlocks.Count; i++) { locChanged += lineDiffs.PiecesOld[i].ToCharArray().Count(x => @"\n".Contains(x)); } // Calculate code quality metrics (on the entire file) int avgCodeQualityChange = 0; avgCodeQualityChange += getCodeQuality(newText) - getCodeQuality(oldText); avgCodeQualityChange /= lineDiffs.DiffBlocks.Count; // --- Log changes --- File.AppendAllLines(changeLogDump, new string[] { "---", "File changed: " + e.FullPath, "Timestamp: " + DateTime.Now.ToString(), "Code quality change: " + avgCodeQualityChange.ToString(), "Lines changed: " + locChanged }); // --- Store changes --- File.Copy(e.FullPath, getDumpPath(e.FullPath), true); }
public SideBySideViewModel(SideBySideDiffModel diffModel) { ViewMode = ViewMode.SideBySide; DiffModel = diffModel; }
public InLineViewModel(SideBySideDiffModel diffModel) { this.ViewMode = ViewMode.Inline; this.DiffModel = ConvertToInline(diffModel); }
public EjDiffModel(SideBySideDiffModel sideBySideDiffModel, string thisFilename, string withFilename) { SideBySideDiffModel = sideBySideDiffModel; ThisFilename = thisFilename; WithFilename = withFilename; }
public async Task BuildAsync(SideBySideDiffModel sideBySideDiffModel, StreamWriter streamWriter, bool includeUnchanged) { var diffPane = new DiffPane(includeUnchanged); await diffPane.BuildAsync(sideBySideDiffModel, streamWriter); }
public static void SetRight(DependencyObject obj, SideBySideDiffModel value) { obj.SetValue(RightProperty, value); }
public static void SetActualText(DependencyObject obj, SideBySideDiffModel value) { obj.SetValue(ActualTextProperty, value); }