实例介绍
DiffPlex是一个强大的C#库,旨在帮助开发者轻松地生成文本文件之间的差异。它支持.NET标准1.0及以上版本,提供了两种主要的接口用于生成差异:IDiffer和ISidebySideDiffer,分别用于低级和高级差异生成。
例如,使用DiffPlex生成差异的代码示例如下:
var diff = InlineDiffBuilder.Diff(before, after); var savedColor = Console.ForegroundColor; foreach (var line in diff.Lines) { switch (line.Type) { case ChangeType.Inserted: Console.ForegroundColor = ConsoleColor.Green; Console.Write(" "); break; case ChangeType.Deleted: Console.ForegroundColor = ConsoleColor.Red; Console.Write("- "); break; default: Console.ForegroundColor = ConsoleColor.Gray; Console.Write(" "); break; } Console.WriteLine(line.Text); } Console.ForegroundColor = savedColor;
DiffPlex还包括用于网站和Windows应用程序开发的库,使得在各种平台上展示文本差异变得简单。不论是在ASP MVC网站中创建基本的并排差异视图,还是在Windows App SDK和WPF中渲染文本差异,DiffPlex都提供了丰富的功能和灵活的定制选项。
通过DiffPlex,开发者可以轻松实现文本差异的可视化展示,极大地提升了代码审查和文档比对的效率。
【实例截图】
文件清单
└── diffplex-1cbc3ba959da9ad8d7eaab9d8cdf6d0815fd0faf
├── appveyor.yml
├── azure-pipelines.yml
├── DiffPlex
│ ├── Chunkers
│ │ ├── CharacterChunker.cs
│ │ ├── CustomFunctionChunker.cs
│ │ ├── DelimiterChunker.cs
│ │ ├── LineChunker.cs
│ │ ├── LineEndingsPreservingChunker.cs
│ │ └── WordChunker.cs
│ ├── DiffBuilder
│ │ ├── IInlineDiffBuilder.cs
│ │ ├── InlineDiffBuilder.cs
│ │ ├── ISideBySideDiffBuilder.cs
│ │ ├── Model
│ │ │ ├── DiffPaneModel.cs
│ │ │ ├── DiffPiece.cs
│ │ │ └── SideBySideDiffModel.cs
│ │ └── SideBySideDiffBuilder.cs
│ ├── Differ.cs
│ ├── DiffPlex.csproj
│ ├── IChunker.cs
│ ├── IDiffer.cs
│ ├── Log.cs
│ └── Model
│ ├── DiffBlock.cs
│ ├── DiffResult.cs
│ ├── EditLengthResult.cs
│ └── ModificationData.cs
├── DiffPlex.App
│ ├── app.manifest
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Assets
│ │ ├── LockScreenLogo.scale-100.png
│ │ ├── LockScreenLogo.scale-200.png
│ │ ├── LockScreenLogo.scale-400.png
│ │ ├── SplashScreen.scale-200.png
│ │ ├── Square150x150Logo.scale-100.png
│ │ ├── Square150x150Logo.scale-200.png
│ │ ├── Square150x150Logo.scale-400.png
│ │ ├── Square44x44Logo.scale-100.png
│ │ ├── Square44x44Logo.scale-200.png
│ │ ├── Square44x44Logo.scale-400.png
│ │ ├── Square44x44Logo.targetsize-128_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-16_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-256_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-32_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-48_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-64_altform-unplated.png
│ │ ├── Square44x44Logo.targetsize-80_altform-unplated.png
│ │ ├── StoreLogo.png
│ │ ├── StoreLogo.scale-200.png
│ │ ├── StoreLogo.scale-400.png
│ │ └── Wide310x150Logo.scale-200.png
│ ├── DiffPlex.App.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Package.appxmanifest
│ ├── Properties
│ │ ├── launchSettings.json
│ │ └── PublishProfiles
│ │ ├── win10-arm64.pubxml
│ │ ├── win10-x64.pubxml
│ │ └── win10-x86.pubxml
│ └── README.md
├── DiffPlex.ConsoleRunner
│ ├── DiffPlex.ConsoleRunner.csproj
│ └── Program.cs
├── DiffPlex.ico
├── DiffPlex.sln
├── DiffPlex.Windows
│ ├── Converters.cs
│ ├── DiffPlex.Windows.csproj
│ ├── DiffTextView.xaml
│ ├── DiffTextView.xaml.cs
│ ├── DiffTextWindow.xaml
│ ├── DiffTextWindow.xaml.cs
│ ├── Handlers.cs
│ ├── InternalResources.lang-en.resw
│ ├── InternalResources.lang-es.resw
│ ├── InternalResources.lang-fr.resw
│ ├── InternalResources.lang-ja.resw
│ ├── InternalResources.lang-ko.resw
│ ├── InternalResources.lang-pt.resw
│ ├── InternalResources.lang-zh-Hans.resw
│ ├── InternalResources.lang-zh-Hant.resw
│ ├── InternalResources.resw
│ ├── Internals.cs
│ └── README.md
├── DiffPlex.WindowsForms
│ ├── App.config
│ ├── DiffPlex.WinForms.Demo.csproj
│ ├── Extensions
│ │ └── RichTextBoxExtensions.cs
│ ├── Form1.cs
│ ├── Form1.Designer.cs
│ ├── Form1.resx
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── README.md
│ └── screenshot.png
├── DiffPlex.WindowsForms.Demo
│ ├── DiffPlex.WindowsForms.Demo.csproj
│ ├── MainForm.cs
│ ├── MainForm.Designer.cs
│ ├── MainForm.resx
│ ├── Program.cs
│ └── README.md
├── DiffPlex.Wpf
│ ├── AssemblyInfo.cs
│ ├── Controls
│ │ ├── DiffViewer.xaml
│ │ ├── DiffViewer.xaml.cs
│ │ ├── Helper.cs
│ │ ├── InlineDiffViewer.xaml
│ │ ├── InlineDiffViewer.xaml.cs
│ │ ├── InternalLinesViewer.xaml
│ │ ├── InternalLinesViewer.xaml.cs
│ │ ├── Resource.Designer.cs
│ │ ├── Resource.en.resx
│ │ ├── Resource.es.resx
│ │ ├── Resource.fr.resx
│ │ ├── Resource.ja.resx
│ │ ├── Resource.ko.resx
│ │ ├── Resource.pt.resx
│ │ ├── Resource.resx
│ │ ├── Resource.zh-Hans.resx
│ │ ├── Resource.zh-Hant.resx
│ │ ├── SideBySideDiffViewer.xaml
│ │ └── SideBySideDiffViewer.xaml.cs
│ ├── DiffPlex.Wpf.csproj
│ ├── DiffWindow.xaml
│ ├── DiffWindow.xaml.cs
│ ├── Forms
│ │ ├── DiffViewer.cs
│ │ ├── DiffViewer.Designer.cs
│ │ └── DiffViewer.resx
│ ├── Icon.png
│ └── README.md
├── DiffPlex.Wpf.Demo
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AssemblyInfo.cs
│ ├── DiffPlex.Wpf.Demo.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── README.md
│ └── TestData.cs
├── Directory.Build.props
├── Directory.Build.targets
├── Facts.DiffPlex
│ ├── Chunkers
│ │ └── LineEndingsPreservingChunkerFacts.cs
│ ├── DifferFacts.cs
│ ├── Facts.DiffPlex.csproj
│ ├── InlineDiffBuilderFacts.cs
│ └── SideBySideDiffBuilderFacts.cs
├── images
│ ├── diffplex_icon.png
│ ├── wasdk_split_dark.jpg
│ ├── website.png
│ └── wpf_side_light.jpg
├── License.txt
├── NuGet.config
├── NuGet.props
├── opensource.snk
├── package.ps1
├── Perf.DiffPlex
│ ├── Perf.DiffPlex.csproj
│ ├── Program.cs
│ └── SideBySideDiffBuilderBenchmark.cs
├── README.md
└── WebDiffer
├── appsettings.Development.json
├── appsettings.json
├── bower.json
├── bundleconfig.json
├── Controllers
│ └── DiffController.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Startup.cs
├── Views
│ ├── Diff
│ │ ├── Contact.cshtml
│ │ ├── DiffBar.cshtml
│ │ ├── Diff.cshtml
│ │ ├── DiffLine.cshtml
│ │ ├── DiffPane.cshtml
│ │ └── Index.cshtml
│ ├── Shared
│ │ ├── Error.cshtml
│ │ └── _Layout.cshtml
│ ├── _ViewImports.cshtml
│ └── _ViewStart.cshtml
├── WebDiffer.csproj
└── wwwroot
├── css
│ ├── diff.css
│ ├── site.css
│ └── site.min.css
├── favicon.ico
├── images
│ ├── banner1.svg
│ ├── banner2.svg
│ ├── banner3.svg
│ └── banner4.svg
├── js
│ ├── site.js
│ └── site.min.js
└── lib
├── bootstrap
│ ├── bower.json
│ ├── CHANGELOG.md
│ ├── dist
│ │ ├── css
│ │ │ ├── bootstrap.css
│ │ │ ├── bootstrap.css.map
│ │ │ ├── bootstrap.min.css
│ │ │ ├── bootstrap.min.css.map
│ │ │ ├── bootstrap-theme.css
│ │ │ ├── bootstrap-theme.css.map
│ │ │ ├── bootstrap-theme.min.css
│ │ │ └── bootstrap-theme.min.css.map
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ └── glyphicons-halflings-regular.woff2
│ │ └── js
│ │ ├── bootstrap.js
│ │ ├── bootstrap.min.js
│ │ └── npm.js
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── grunt
│ │ ├── bs-commonjs-generator.js
│ │ ├── bs-glyphicons-data-generator.js
│ │ ├── bs-lessdoc-parser.js
│ │ ├── bs-raw-files-generator.js
│ │ ├── change-version.js
│ │ ├── configBridge.json
│ │ ├── npm-shrinkwrap.json
│ │ └── sauce_browsers.yml
│ ├── Gruntfile.js
│ ├── ISSUE_TEMPLATE.md
│ ├── js
│ │ ├── affix.js
│ │ ├── alert.js
│ │ ├── button.js
│ │ ├── carousel.js
│ │ ├── collapse.js
│ │ ├── dropdown.js
│ │ ├── modal.js
│ │ ├── popover.js
│ │ ├── scrollspy.js
│ │ ├── tab.js
│ │ ├── tooltip.js
│ │ └── transition.js
│ ├── less
│ │ ├── alerts.less
│ │ ├── badges.less
│ │ ├── bootstrap.less
│ │ ├── breadcrumbs.less
│ │ ├── button-groups.less
│ │ ├── buttons.less
│ │ ├── carousel.less
│ │ ├── close.less
│ │ ├── code.less
│ │ ├── component-animations.less
│ │ ├── dropdowns.less
│ │ ├── forms.less
│ │ ├── glyphicons.less
│ │ ├── grid.less
│ │ ├── input-groups.less
│ │ ├── jumbotron.less
│ │ ├── labels.less
│ │ ├── list-group.less
│ │ ├── media.less
│ │ ├── mixins
│ │ │ ├── alerts.less
│ │ │ ├── background-variant.less
│ │ │ ├── border-radius.less
│ │ │ ├── buttons.less
│ │ │ ├── center-block.less
│ │ │ ├── clearfix.less
│ │ │ ├── forms.less
│ │ │ ├── gradients.less
│ │ │ ├── grid-framework.less
│ │ │ ├── grid.less
│ │ │ ├── hide-text.less
│ │ │ ├── image.less
│ │ │ ├── labels.less
│ │ │ ├── list-group.less
│ │ │ ├── nav-divider.less
│ │ │ ├── nav-vertical-align.less
│ │ │ ├── opacity.less
│ │ │ ├── pagination.less
│ │ │ ├── panels.less
│ │ │ ├── progress-bar.less
│ │ │ ├── reset-filter.less
│ │ │ ├── reset-text.less
│ │ │ ├── resize.less
│ │ │ ├── responsive-visibility.less
│ │ │ ├── size.less
│ │ │ ├── tab-focus.less
│ │ │ ├── table-row.less
│ │ │ ├── text-emphasis.less
│ │ │ ├── text-overflow.less
│ │ │ └── vendor-prefixes.less
│ │ ├── mixins.less
│ │ ├── modals.less
│ │ ├── navbar.less
│ │ ├── navs.less
│ │ ├── normalize.less
│ │ ├── pager.less
│ │ ├── pagination.less
│ │ ├── panels.less
│ │ ├── popovers.less
│ │ ├── print.less
│ │ ├── progress-bars.less
│ │ ├── responsive-embed.less
│ │ ├── responsive-utilities.less
│ │ ├── scaffolding.less
│ │ ├── tables.less
│ │ ├── theme.less
│ │ ├── thumbnails.less
│ │ ├── tooltip.less
│ │ ├── type.less
│ │ ├── utilities.less
│ │ ├── variables.less
│ │ └── wells.less
│ ├── LICENSE
│ ├── nuget
│ │ ├── bootstrap.less.nuspec
│ │ ├── bootstrap.nuspec
│ │ └── MyGet.ps1
│ ├── package.js
│ ├── package.json
│ └── README.md
├── jquery
│ ├── dist
│ │ ├── jquery.js
│ │ ├── jquery.min.js
│ │ └── jquery.min.map
│ └── LICENSE.txt
├── jquery-validation
│ ├── dist
│ │ ├── additional-methods.js
│ │ ├── additional-methods.min.js
│ │ ├── jquery.validate.js
│ │ └── jquery.validate.min.js
│ └── LICENSE.md
└── jquery-validation-unobtrusive
├── jquery.validate.unobtrusive.js
└── jquery.validate.unobtrusive.min.js
51 directories, 321 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论