예제 #1
0
        public void TestDiff()
        {
            var content1 = "Today is a good day" + Environment.NewLine + "WooHoo";
            var content2 = "Tomorrow is not, what a day" + Environment.NewLine + "WOW";

            var dmp        = new Diff_Match_Patch();
            var differents = dmp.Diff_Main(content1, content2);

            dmp.Diff_CleanupSemantic(differents);
            Assert.AreEqual(6, differents.Count);
        }
예제 #2
0
        /// <summary>
        /// Compares two String objects to determine their relative ordering.
        /// </summary>
        ///
        /// <remarks>
        /// Based on Google diff_match_patch.
        /// </remarks>
        ///
        /// <param name="a"> A String to process. </param>
        /// <param name="b"> A String to process. </param>
        ///
        /// <returns>
        /// A String.
        /// </returns>
        public static String Diff(String a, String b)
        {
            Diff_Match_Patch dmp = new Diff_Match_Patch();

            List <Diff> diffs = dmp.diff_main(a, b, false);

            dmp.diff_cleanupSemantic(diffs);
            dmp.Diff_EditCost = 80;
            dmp.diff_cleanupEfficiency(diffs);

            return((dmp.patch_toText(dmp.patch_make(diffs))).Replace("%09", "\t"));
        }