当前位置: 首页>>代码示例>>C#>>正文


C# Differences.Count方法代码示例

本文整理汇总了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/>");
        }
开发者ID:i-e-b,项目名称:DiffTools,代码行数:43,代码来源:DocDiff.aspx.cs


注:本文中的Differences.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。