c#做對比軟體

來源:互聯網
上載者:User

一些 HTML內容比較/文本差異比較 開原始碼

1. DiffPlex - a .NET Diff Generator   
http://diffplex.codeplex.com/SourceControl/changeset/view/052fd342999b  原網站dll下載

http://diffplex.codeplex.com/

簡介:

具體使用可以參考http://diffplex.codeplex.com/wikipage?title=library&referringTitle=Home

IDiffer是差異比較的核心類,提供了兩個文本的低精度的大致比較

ISidebySideDiff:提供了高精度的比較以及可以用兩欄對比顯示差異

介面

 

Silverlight

Website 

2.diffengine

簡介:

功能強大,

缺點:文本每行不能超過1024個字元

DifferenceEngine.DiffList_TextFile sourceFile  null;
DifferenceEngine.DiffList_TextFile destinationFile = null;

sourceFile = new DifferenceEngine.DiffList_TextFile("1.txt");
destinationFile = new DifferenceEngine.DiffList_TextFile("2.txt");

DifferenceEngine.DiffEngine engine = new DifferenceEngine.DiffEngine();
engine.ProcessDiff(sourceFile,destinationFile, DifferenceEngine.DiffEngineLevel.FastImperfect);
ArrayList diffLines = engine.DiffReport();
foreach (DifferenceEngine.DiffResultSpan span in diffLines)
 {  
   switch (span.Status)
    {
 case ifferenceEngine.DiffResultSpanStatus.NoChange:
    //沒改變
      break;
 case DifferenceEngine.DiffResultSpanStatus.AddDestination:
//新增的
     break;
 case DifferenceEngine.DiffResultSpanStatus.DeleteSource:
//已刪除的
     break;
case DifferenceEngine.DiffResultSpanStatus.Replace:
//修改的      
                break;
default:
 //  預設
                      break;

                }

            } 

擷取新增內容樣本:

 

string str = ((DifferenceEngine.TextLine)(destinationFile.GetByIndex(span.DestIndex))).Line;

http://www.codeproject.com/KB/recipes/diffengine.aspx

 

3. htmldiff

簡介:

HtmlDiff原本是Ruby版的HTML差異比較演算法,後來有朋友做了個C#版本,特點是非常好用,過於簡單
C#版:  http://htmldiff.codeplex.com/

Ruby版: http://github.com/myobie/htmldiff
http://www.rohland.co.za/index.php/2009/10/31/csharp-html-diff-algorithm/

 

4.NDiffDiff: A Diff Implementation for Lines and Chars in Text File

簡介:

提供Winform Demo

http://www.codeproject.com/KB/recipes/NBDiffDiff.aspx

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.