Exemplo n.º 1
0
 public static void SetBefore(DependencyObject obj, SideBySideDiffModel value)
 {
     obj.SetValue(BeforeProperty, value);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 差分前後の文字を比較表示
 /// </summary>
 public static string ToDisplayString(this SideBySideDiffModel ssDiff) => $"{ssDiff.OldText.ToRawText()}->{ssDiff.NewText.ToRawText()}";
Exemplo n.º 3
0
 public static void SetVorher(DependencyObject obj, SideBySideDiffModel value)
 {
     obj.SetValue(VorherProperty, value);
 }
Exemplo n.º 4
0
 public SideBySideDiffModel GetMergedText(SideBySideDiffModel model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public FileDifferences(string fileName, SideBySideDiffModel differences)
 {
     FileName    = fileName;
     Differences = differences;
 }
Exemplo n.º 6
0
        // 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);
        }
Exemplo n.º 7
0
 public SideBySideViewModel(SideBySideDiffModel diffModel)
 {
     ViewMode  = ViewMode.SideBySide;
     DiffModel = diffModel;
 }
Exemplo n.º 8
0
 public InLineViewModel(SideBySideDiffModel diffModel)
 {
     this.ViewMode  = ViewMode.Inline;
     this.DiffModel = ConvertToInline(diffModel);
 }
Exemplo n.º 9
0
 public EjDiffModel(SideBySideDiffModel sideBySideDiffModel, string thisFilename, string withFilename)
 {
     SideBySideDiffModel = sideBySideDiffModel;
     ThisFilename        = thisFilename;
     WithFilename        = withFilename;
 }
Exemplo n.º 10
0
        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);
 }