5
asp.net에서 두 파일의 차이를 강조하고 싶습니다. 웹 검색 후 Diffplex APi를 선택했습니다. 나는 초보자이다. 그것을 구현하는 방법에 대한 지침이 필요합니까? 참조 라이브러리를 추가했는데 그것이 내가 이해할 수있는 전부입니다. Api에 대한 문서는 없습니다. 나는 전에 Apis를 사용하지 않았다.Diffplex 시작하기
asp.net에서 두 파일의 차이를 강조하고 싶습니다. 웹 검색 후 Diffplex APi를 선택했습니다. 나는 초보자이다. 그것을 구현하는 방법에 대한 지침이 필요합니까? 참조 라이브러리를 추가했는데 그것이 내가 이해할 수있는 전부입니다. Api에 대한 문서는 없습니다. 나는 전에 Apis를 사용하지 않았다.Diffplex 시작하기
다음은 시작해야하는 "문서"(즉 소스 코드)의 간단한 예입니다.
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();
}
}
}
덕분에, 나는 위대한 – JanR
찾고 있었던 정확하게 - 나는 당신이 그것으로 행운을해야합니다 생각 때문에 꽤 잘 작동 DiffPlex의 상단에은 diff 도구를 만들었습니다. –
Diffplex에는 기본 병합 옵션이 있습니까? – JanR