Code snippets are meant as small region of reusable code. Which allow you to use intellisense to insert set of code N number of times. Below are the content you will cover in lecture. Using code snippets can save a lot of time and effort. Also help in distributing common standard code among team.
• Code Snippets – Introduction
• Ways to insert code snippets
• Custom Code Snippets
• XML File walkthrough
• Examples
• Using the custom snippets
• Ready made code fragments
• Two types
• Expansion code snippet
• Surround with code snippet
Custom code snippets:
• Steps to create custom code snippet
• Create an XML file with extension .snippet
• Import the snippets in Visual Studio
• XML File boilerplate
XML used for custom code snippet in video is:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/CodeSnippet">
<CodeSnippet Format="1.0.0">
<!-- The header contains metadata about the snippet -->
<Header>
<!-- The Title of the snippet, this will be shown in the snippets manager -->
<Title></Title>
<!-- The description of the snippet -->
<Description></Description>
<!-- The author of the snippet -->
<Author></Author>
<!-- The set of characters that must be keyed in to insert the snippet -->
<Shortcut></Shortcut>
<!-- Snippet type - Expansion, SurroundsWith -->
<SnippetTypes>
<SnippetType></SnippetType>
</SnippetTypes>
</Header>
<!-- Snippet code and literals, if any -->
<Snippet>
<!-- Specify the code language and the actual snippet content. -->
<Code Language="CSharp">
<![CDATA[
ACTUAL SNIPPET CODE
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>