如何使用 google-diff-match-patch C# 库?
我正在查看 http://code.google.com/p/google-diff-match-patch / 并已下载该文件。当我看到它是 2 个文件时
DiffMatchPatch.cs
DiffMatchPatchTest.cs
,当我尝试创建 DiffMatchPatch.cs 的新对象时,我必须传入一些操作和字符串文本。
http://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/ demo_diff.html
在演示中,他们划掉了不同的单词,这就是我想要实现的目标。
我正在尝试比较服务器端的 2 个文本块,找出差异,并向用户发送一封电子邮件,其中包含文件文本块,就像最终结果在我上面发布的演示中一样。
那么有人有关于如何使用 C# 版本的教程吗?
I am looking at http://code.google.com/p/google-diff-match-patch/ and have downloaded the file. When I look at it is 2 files
DiffMatchPatch.cs
DiffMatchPatchTest.cs
When I try to make a new object of DiffMatchPatch.cs I have to pass in some operation and string text.
http://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html
In the demo they cross out the words that are different and that is what I am trying to achieve.
I am trying to compare 2 blocks of text on the server side finds the differences and send a email to the user with the file block of text to them like the end result is in the demo that I posted above.
So does anyone have a tutorial on how to use the C# version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为参考,这非常简单:
For reference, this is really easy:
当前版本(2.1.0)的实现如下所示
Implementation with current version(2.1.0) would look like this
对于任何因标题而遇到此线程并期望通过 https://github.com/pocketberserker/Diff.Match.Patch 在 NuGet 上找到的库,用于创建 diff 字符串,以便他可以将更改发送到某个地方(例如通过 websocket)并且根据旧值和差异字符串在目的地恢复它,其工作方式如下:
For anyone who came across this thread because of the title and expected an explanation on how to use the Google Diff-Match-Patch algorithm via the https://github.com/pocketberserker/Diff.Match.Patch library found on NuGet, to create a diff string, so he can send the change somewhere (e.g. via websocket) and restore it at the destination based on the old value and the diff string, that would work like this: