asp.net – Diffplex入门
发布时间:2020-12-16 07:06:09 所属栏目:asp.Net 来源:网络整理
导读:我想强调asp.net中两个文件之间的区别.网络搜索后,我选择了Diffplex APi.我是个乞丐.我需要一些如何实施它的指导?我添加了参考图书馆,这就是我能理解的.没有关于Api的任何文档.我之前没有使用过Apis. 解决方法 这是一个简单的例子,来自“文档”(即源代码),
我想强调asp.net中两个文件之间的区别.网络搜索后,我选择了Diffplex APi.我是个乞丐.我需要一些如何实施它的指导?我添加了参考图书馆,这就是我能理解的.没有关于Api的任何文档.我之前没有使用过Apis.
解决方法
这是一个简单的例子,来自“文档”(即源代码),应该可以帮助您入门.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DiffPlex; using DiffPlex.DiffBuilder; using DiffPlex.DiffBuilder.Model; using System.Text; namespace DiffPlexTest.Controllers { public class HomeController : Controller { public ActionResult Index() { StringBuilder sb = new StringBuilder(); string oldText = @"We the people of the united states of america establish justice ensure domestic tranquility provide for the common defence secure the blessing of liberty to ourselves and our posterity"; string newText = @"We the peaple in order to form a more perfect union establish justice ensure domestic tranquility promote the general welfare and secure the blessing of liberty to ourselves and our posterity do ordain and establish this constitution for the United States of America"; var d = new Differ(); var builder = new InlineDiffBuilder(d); var result = builder.BuildDiffModel(oldText,newText); foreach (var line in result.Lines) { if (line.Type == ChangeType.Inserted) { sb.Append("+ "); } else if (line.Type == ChangeType.Deleted) { sb.Append("- "); } else if (line.Type == ChangeType.Modified) { sb.Append("* "); } else if (line.Type == ChangeType.Imaginary) { sb.Append("? "); } else if (line.Type == ChangeType.Unchanged) { sb.Append(" "); } sb.Append(line.Text + "<br/>"); } ViewData["old"] = oldText; ViewData["new"] = newText; ViewData["result"] = sb.ToString(); return View(); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – MVC4 SimpleMemberhip’提供商遇到了未知错
- asp.net – Azure网站和Azure云服务之间的区别
- .net – 如何正确处理n层应用程序中的错误?
- 在ASP.NET MVC表单上允许多个按钮的最佳方法是什么?
- asp.net-mvc-3 – 有没有办法使用字符串键访问.NET MVC Vie
- asp.net-mvc – ASP.NET MVC验证针对空列表框抛出NullRefer
- 使用asp.net标识更新用户角色
- entity-framework-6 – 带有EF6的ASP.NET-5
- 校园邮政快递查询系统基于B/S模式下的asp系统
- asp.net-mvc-4 – 用于上传mime文件和表单数据的MultipartF
推荐文章
站长推荐
热点阅读