You can use these code snippets to quickly generate code in some common scenarios during Orchard Core module and theme development. The snippets follow Orchard naming conventions. Check out this demo video for a quick overview of our snippets.
To effectively use this collection of VS snippets just point the Snippets Manager to where you cloned or downloaded this folder. To do this go under Tools → Code Snippets Manager → select the C# language → Add and Add the whole folder. For Razor snippets to also work select the HTML Language and do the same. Do note that Razor snippets will only be suggested when you hit Ctrl + space first.
The snippets also automatically add the necessary namespaces.
We've taken care to place the
$end$ terminating symbol to a place where one most possibly wants to follow up with coding. Thus if you exit snippets by hitting enter the cursor will be placed where you most likely want to write next.
These snippets are constantly used at Lombiq and updated according to our experiences.
- controller: Empty ASP.NET MVC controller class.
- ctorinject: Constructor with an injected dependency and a corresponding
- pbcon: Public constant field that returns its own name.
- privr: Private
- propv: Virtual auto-implemented property.
- servsc: Scoped service registration.
Orchard Core snippets
Orchard Core snippets are prefixed with "oc" for distinction.
- ocadminmenu: Admin
AlterTable()call and a CreateIndex() inside.
- occontentmigrations: Migrations class that configures content types or content parts.
- ocfield: Empty content field.
- ocfielddriverfull: Full
ContentFieldDisplayDriverimplementation with display/edit/update methods.
- ocjqueryblock: Razor script block for jQuery-using JS code.
- ocmigrations: Simple
- ocpart: Empty content part.
- ocpartdriverfull: Full
ContentPartDisplayDriverimplementation with display/edit/update methods.
Startupclass for an extension's feature.
This page and many others here are part of the open-source, portable package of Orchard Core goodies: the Orchard Dojo Library. The Library is freely accessible by anyone; just go to its repository to download its full content (you can even download the textual content of the Library as a big concatenated document in HTML), file issues or fork it! You can even edit it online on Bitbucket, just click on the Edit link in the upper right corner!
Note that the Library also has an Orchard 1.x version, check it out here!