实例介绍
R4MVC是一个针对ASP.NET MVC Core应用的Roslyn基础代码生成器,它创建了强类型的帮助程序,这些程序消除了在许多地方使用字面字符串的需求。它是针对ASP.NET Core项目的T4MVC的重新实现。
R4MVC可以在dotnet cli或Visual Studio 2017中运行,并支持ASP.NET Core MVC 1 和 2。
优势:
使用R4MVC,您可以避免使用如下代码:
@Html.ActionLink("Dinner Details", "Details", "Dinners", new { id = Model.DinnerID }, null)
而是写成:
@Html.ActionLink("Dinner Details", MVC.Dinners.Details(Model.DinnerID))
当您使用标签帮助程序时,不再需要:
<a asp-action="Details" asp-controller="Dinners" asp-route-id="@Model.DinnerID">Dinner Details</a>
您可以这样写(在_ViewImports.cshtml中注册R4Mvc标签帮助程序后):
<a mvc-action="MVC.Dinners.Details(Model.DinnerID)">Dinner Details</a>
这只是开始!
【实例截图】
【核心代码】
文件清单
└── R4MVC-56aea7bfcda135e6afed116ae109a980d43d7473
├── appveyor.yml
├── build.cmd
├── CHANGELOG.md
├── LICENSE
├── makefile.shade
├── R4MVC.sln
├── README.md
├── RunGenerate.bat
├── samples
│ ├── AspNetFeatureFolders
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Areas
│ │ │ ├── Members
│ │ │ │ ├── Features
│ │ │ │ │ └── Manage
│ │ │ │ │ ├── Index.cshtml
│ │ │ │ │ ├── IndexViewModel.cs
│ │ │ │ │ ├── ManageController.cs
│ │ │ │ │ └── ManageController.generated.cs
│ │ │ │ └── MembersAreaAttribute.cs
│ │ │ └── Products
│ │ │ ├── ProductsAreaAttribute.cs
│ │ │ └── Search
│ │ │ ├── Index.cshtml
│ │ │ ├── IndexViewModel.cs
│ │ │ ├── SearchController.cs
│ │ │ └── SearchController.generated.cs
│ │ ├── AspNetFeatureFolders.csproj
│ │ ├── bundleconfig.json
│ │ ├── Features
│ │ │ ├── Calculator
│ │ │ │ ├── CalculatorController.cs
│ │ │ │ ├── CalculatorController.generated.cs
│ │ │ │ ├── Index.cshtml
│ │ │ │ └── IndexViewModel.cs
│ │ │ ├── Shared
│ │ │ │ ├── _Layout.cshtml
│ │ │ │ └── _ValidationScriptsPartial.cshtml
│ │ │ ├── _ViewImports.cshtml
│ │ │ └── _ViewStart.cshtml
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── R4Mvc.cs
│ │ ├── R4Mvc.generated.cs
│ │ ├── r4mvc.json
│ │ ├── Startup.cs
│ │ └── wwwroot
│ │ ├── 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
│ │ │ ├── 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
│ │ │ └── LICENSE
│ │ ├── 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
│ ├── AspNetSimple
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Areas
│ │ │ └── Members
│ │ │ ├── Controllers
│ │ │ │ ├── ManualAreaController.cs
│ │ │ │ ├── ManualAreaController.generated.cs
│ │ │ │ ├── SecureController.cs
│ │ │ │ ├── SecureController.generated.cs
│ │ │ │ ├── TestsController.cs
│ │ │ │ └── TestsController.generated.cs
│ │ │ ├── MembersAreaAttribute.cs
│ │ │ └── Views
│ │ │ └── Tests
│ │ │ └── Index.cshtml
│ │ ├── AspNetSimple.csproj
│ │ ├── bundleconfig.json
│ │ ├── ControllerExtensions
│ │ │ └── TestsController.cs
│ │ ├── Controllers
│ │ │ ├── DebugControllerBase.cs
│ │ │ ├── HomeController.cs
│ │ │ ├── HomeController.generated.cs
│ │ │ ├── SecureController.cs
│ │ │ ├── SecureController.generated.cs
│ │ │ ├── TestsController.cs
│ │ │ ├── TestsController.generated.cs
│ │ │ ├── WebApiController.cs
│ │ │ └── WebApiController.generated.cs
│ │ ├── Models
│ │ │ ├── ErrorViewModel.cs
│ │ │ └── Product.cs
│ │ ├── Pages
│ │ │ ├── Categories
│ │ │ │ ├── Details.cshtml
│ │ │ │ ├── Details.cshtml.cs
│ │ │ │ ├── Details.cshtml.generated.cs
│ │ │ │ ├── Inner
│ │ │ │ │ ├── NoModel.cshtml
│ │ │ │ │ ├── NoModel.cshtml.cs
│ │ │ │ │ └── NoModel.cshtml.generated.cs
│ │ │ │ ├── NoModel.cshtml
│ │ │ │ ├── NoModel.cshtml.cs
│ │ │ │ └── NoModel.cshtml.generated.cs
│ │ │ ├── Default.cshtml
│ │ │ ├── Default.cshtml.cs
│ │ │ ├── Default.cshtml.generated.cs
│ │ │ ├── NoDirectChildPages
│ │ │ │ └── AnotherEmptyLayer
│ │ │ │ └── NestedPages
│ │ │ │ ├── Index.cshtml
│ │ │ │ ├── Index.cshtml.cs
│ │ │ │ └── Index.cshtml.generated.cs
│ │ │ ├── NoModel.cshtml
│ │ │ ├── NoModel.cshtml.cs
│ │ │ ├── NoModel.cshtml.generated.cs
│ │ │ └── NotARazorPage.cshtml
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── R4Mvc.cs
│ │ ├── R4Mvc.generated.cs
│ │ ├── r4mvc.json
│ │ ├── Startup.cs
│ │ ├── Views
│ │ │ ├── Home
│ │ │ │ ├── About.cshtml
│ │ │ │ ├── Contact.cshtml
│ │ │ │ └── Index.cshtml
│ │ │ ├── Shared
│ │ │ │ ├── Error.cshtml
│ │ │ │ ├── _Layout.cshtml
│ │ │ │ └── _ValidationScriptsPartial.cshtml
│ │ │ ├── _ViewImports.cshtml
│ │ │ └── _ViewStart.cshtml
│ │ └── wwwroot
│ │ ├── 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
│ │ │ ├── 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
│ │ │ └── LICENSE
│ │ ├── 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
│ ├── AspNetSimple.NetCore2
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── AspNetSimple.NetCore2.csproj
│ │ ├── Controllers
│ │ │ ├── HomeController.cs
│ │ │ └── HomeController.generated.cs
│ │ ├── Models
│ │ │ └── ErrorViewModel.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── R4Mvc.cs
│ │ ├── R4Mvc.generated.cs
│ │ ├── r4mvc.json
│ │ ├── Startup.cs
│ │ ├── Views
│ │ │ ├── Home
│ │ │ │ ├── Index.cshtml
│ │ │ │ └── Privacy.cshtml
│ │ │ ├── Shared
│ │ │ │ ├── Error.cshtml
│ │ │ │ ├── _Layout.cshtml
│ │ │ │ └── _ValidationScriptsPartial.cshtml
│ │ │ ├── _ViewImports.cshtml
│ │ │ └── _ViewStart.cshtml
│ │ └── wwwroot
│ │ ├── css
│ │ │ └── site.css
│ │ ├── favicon.ico
│ │ ├── js
│ │ │ └── site.js
│ │ └── lib
│ │ ├── bootstrap
│ │ │ ├── dist
│ │ │ │ ├── css
│ │ │ │ │ ├── bootstrap.css
│ │ │ │ │ ├── bootstrap.css.map
│ │ │ │ │ ├── bootstrap-grid.css
│ │ │ │ │ ├── bootstrap-grid.css.map
│ │ │ │ │ ├── bootstrap-grid.min.css
│ │ │ │ │ ├── bootstrap-grid.min.css.map
│ │ │ │ │ ├── bootstrap.min.css
│ │ │ │ │ ├── bootstrap.min.css.map
│ │ │ │ │ ├── bootstrap-reboot.css
│ │ │ │ │ ├── bootstrap-reboot.css.map
│ │ │ │ │ ├── bootstrap-reboot.min.css
│ │ │ │ │ └── bootstrap-reboot.min.css.map
│ │ │ │ └── js
│ │ │ │ ├── bootstrap.bundle.js
│ │ │ │ ├── bootstrap.bundle.js.map
│ │ │ │ ├── bootstrap.bundle.min.js
│ │ │ │ ├── bootstrap.bundle.min.js.map
│ │ │ │ ├── bootstrap.js
│ │ │ │ ├── bootstrap.js.map
│ │ │ │ ├── bootstrap.min.js
│ │ │ │ └── bootstrap.min.js.map
│ │ │ └── LICENSE
│ │ ├── 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
│ │ └── LICENSE.txt
│ └── SampleModels
│ ├── SampleModels.csproj
│ └── TestViewModel.cs
├── src
│ ├── R4Mvc
│ │ ├── IR4ActionResult.cs
│ │ ├── IR4MvcActionResult.cs
│ │ ├── IR4PageActionResult.cs
│ │ ├── ModelUnbinderHelpers.cs
│ │ ├── ModelUnbinders
│ │ │ ├── DefaultModelUnbinder.cs
│ │ │ ├── IModelUnbinder.cs
│ │ │ ├── IModelUnbinderProvider.cs
│ │ │ ├── ModelUnbinderProviders.cs
│ │ │ └── ModelUnbinders.cs
│ │ ├── R4Mvc.csproj
│ │ ├── R4MVCExcludeAttribute.cs
│ │ ├── Rendering
│ │ │ ├── HtmlHelperExtensions.cs
│ │ │ └── UrlHelperExtensions.cs
│ │ ├── T4Extensions.cs
│ │ └── TagHelpers
│ │ ├── AnchorTagHelper.cs
│ │ ├── FormTagHelper.cs
│ │ ├── ImageTagHelper.cs
│ │ ├── LinkTagHelper.cs
│ │ └── ScriptTagHelper.cs
│ ├── R4Mvc.Tools
│ │ ├── CodeGen
│ │ │ ├── BodyBuilder.cs
│ │ │ ├── ClassBuilder.cs
│ │ │ ├── CodeFileBuilder.cs
│ │ │ ├── ConstructorMethodBuilder.cs
│ │ │ ├── MethodBuilder.cs
│ │ │ └── SimpleLiteral.cs
│ │ ├── Commands
│ │ │ ├── Core
│ │ │ │ ├── CommandResolver.cs
│ │ │ │ ├── ICommand.cs
│ │ │ │ └── ICommandRunner.cs
│ │ │ ├── GenerateCommand.cs
│ │ │ ├── HelpCommand.cs
│ │ │ ├── RemoveCommand.cs
│ │ │ └── VSInstancesCommand.cs
│ │ ├── Constants.cs
│ │ ├── ControllerDefinition.cs
│ │ ├── ControllerRewriter.cs
│ │ ├── Extensions
│ │ │ ├── SimpleExtensions.cs
│ │ │ └── SyntaxNodeHelpers.cs
│ │ ├── init.ps1
│ │ ├── IView.cs
│ │ ├── Locators
│ │ │ ├── DefaultRazorPageViewLocator.cs
│ │ │ ├── DefaultRazorViewLocator.cs
│ │ │ ├── DefaultStaticFileLocator.cs
│ │ │ ├── FeatureFolderRazorViewLocator.cs
│ │ │ ├── IFileLocator.cs
│ │ │ ├── IPageViewLocator.cs
│ │ │ ├── IStaticFileLocator.cs
│ │ │ ├── IViewLocator.cs
│ │ │ └── PhysicalFileLocator.cs
│ │ ├── PageDefinition.cs
│ │ ├── PageRewriter.cs
│ │ ├── PageView.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ └── launchSettings.json
│ │ ├── R4MVC.psd1
│ │ ├── R4MVC.psm1
│ │ ├── R4Mvc.Tools.csproj
│ │ ├── Services
│ │ │ ├── ControllerGeneratorService.cs
│ │ │ ├── ControllerRewriterService.cs
│ │ │ ├── FilePersistService.cs
│ │ │ ├── GeneratedFileTesterService.cs
│ │ │ ├── IControllerGeneratorService.cs
│ │ │ ├── IControllerRewriterService.cs
│ │ │ ├── IFilePersistService.cs
│ │ │ ├── IGeneratedFileTesterService.cs
│ │ │ ├── IPageGeneratorService.cs
│ │ │ ├── IPageRewriterService.cs
│ │ │ ├── IStaticFileGeneratorService.cs
│ │ │ ├── PageGeneratorService.cs
│ │ │ ├── PageRewriterService.cs
│ │ │ ├── R4MvcGeneratorService.cs
│ │ │ └── StaticFileGeneratorService.cs
│ │ ├── Settings.cs
│ │ ├── StaticFile.cs
│ │ └── View.cs
│ └── R4Mvc.Tools.Cli
│ ├── Program.cs
│ └── R4Mvc.Tools.Cli.csproj
└── test
├── AspNetSimple.Test
│ ├── AspNetSimple.Test.csproj
│ └── Controllers
│ └── TestsControllerTests.cs
└── R4Mvc.Test
├── CodeGen
│ ├── BodyBuilderTests.cs
│ ├── ClassBuilderTests.cs
│ ├── ConstructorMethodBuilderTests.cs
│ ├── MethodBuilderTests.cs
│ └── ModifierHelpers.cs
├── Commands
│ ├── CommandTests.cs
│ └── GenerateCommandTests.cs
├── ControllerDefinitionTests.cs
├── ControllerRewriterTests.cs
├── Extensions
│ └── SimpleExtensionsTests.cs
├── Locators
│ ├── DefaultRazorViewLocatorTests.cs
│ ├── DefaultStaticFileLocatorTests.cs
│ ├── FeatureFolderRazorViewLocatorTests.cs
│ ├── RazorViewLocatorTestsBase.cs
│ ├── VirtualFileLocator.cs
│ └── VirtualFileLocatorTests.cs
├── r4mvc.empty.json
├── r4mvc.json
├── R4Mvc.Test.csproj
├── Services
│ ├── R4MvcGeneratorServiceTests.cs
│ └── StaticFileGeneratorServiceTests.cs
├── SettingsTests.cs
└── TestExtensions.cs
106 directories, 326 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论