Convert to CSHTML snippet types

pull/5553/head
Scott Addie 2018-02-25 20:47:20 -06:00 committed by GitHub
parent 5266352590
commit e7c7e7a61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ The HTML form used to update these preferences includes dropdown lists for three
These lists are populated by a service that has been injected into the view:
[!code-csharp[](../../mvc/views/dependency-injection/sample/src/ViewInjectSample/Views/Profile/Index.cshtml?highlight=4,16,17,21,22,26,27)]
[!code-cshtml[](../../mvc/views/dependency-injection/sample/src/ViewInjectSample/Views/Profile/Index.cshtml?highlight=4,16,17,21,22,26,27)]
The `ProfileOptionsService` is a UI-level service designed to provide just the data needed for this form:
@ -74,7 +74,7 @@ In addition to injecting new services, this technique can also be used to overri
As you can see, the default fields include `Html`, `Component`, and `Url` (as well as the `StatsService` that we injected). If for instance you wanted to replace the default HTML Helpers with your own, you could easily do so using `@inject`:
[!code-html[](../../mvc/views/dependency-injection/sample/src/ViewInjectSample/Views/Helper/Index.cshtml?highlight=3,11)]
[!code-cshtml[](../../mvc/views/dependency-injection/sample/src/ViewInjectSample/Views/Helper/Index.cshtml?highlight=3,11)]
If you want to extend existing services, you can simply use this technique while inheriting from or wrapping the existing implementation with your own.