本文整理汇总了C#中Differences.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Differences.Count方法的具体用法?C# Differences.Count怎么用?C# Differences.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Differences
的用法示例。
在下文中一共展示了Differences.Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string left = File.ReadAllText(Server.MapPath("~/Examples/DeOfficiis.txt"));
//string left = File.ReadAllText(Server.MapPath("~/Examples/DeOfficiis_Recombined.txt"));
string right = File.ReadAllText(Server.MapPath("~/Examples/DeOfficiis_Altered.txt"));
//string right = File.ReadAllText(Server.MapPath("~/Examples/DeOfficiis_Minor_Altered.txt"));
//string right = File.ReadAllText(Server.MapPath("~/Examples/TotallyDifferent.txt"));
GC.Collect(3, GCCollectionMode.Forced); // give the algorithm a fair shot...
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
var differences = new Differences(left, right, Differences.PerWord);
sw.Stop();
Repeater1.DataSource = from d in differences
select new Fragment(d.Type,
HttpContext.Current.Server.HtmlEncode(d.SplitPart).Replace("\n", "<br/>"), d.Position);
Repeater1.DataBind();
Response.Write("DocDiff took " + sw.Elapsed.TotalSeconds + " seconds<br/>");
// This gives a code to convert LEFT into RIGHT
// Is a revision repository, the older file would be RIGHT, and the newer be LEFT.
sw.Reset();
sw.Start();
byte[] final_out = DiffCode.StorageDiffCode(differences);
sw.Stop();
Response.Write("DocDiff-code took " + sw.Elapsed.TotalSeconds + " seconds<br/>");
double sizePc = ((double)final_out.Length / right.Length) * 100.0;
Response.Write("<br/>DocDiff code size: " + (final_out.Length / 1024) + "KiB which is " + sizePc.ToString("0.0") + "% of the resulting file");
Response.Write("<br/>diff code contains " + differences.Count() + " alterations.");
sw.Reset();
sw.Start();
File.WriteAllText(Server.MapPath("~/Examples/DeOfficiis_Recombined.txt"),
DiffCode.BuildRevision(left, DiffCode.BuildDiffCode(differences)));
sw.Stop();
Response.Write("<br/>Rebuild and write took " + sw.Elapsed.TotalSeconds + " seconds<br/>");
}