140 likes | 249 Views
Visual Studio 2005 Code Snippets. BabulalK @ G-C-I.COM. What the heck is this?. BabulalK @ G-C-I.COM. Code Snippets. Are blocks of code. IntelliSense Code Snippets are reusable. Task-oriented.
E N D
Visual Studio 2005 Code Snippets BabulalK @ G-C-I.COM
What the heck is this? BabulalK @ G-C-I.COM
Code Snippets Are blocks of code. • IntelliSense Code Snippets are reusable. • Task-oriented. Visual Studio 2005 includes code snippets covering tasks ranging from creating a custom exception, to sending an e-mail message, to drawing a circle. BabulalK @ G-C-I.COM
Code Snippets Or Ctrl + K , X BabulalK @ G-C-I.COM
Code Snippets – Demo 1 BabulalK @ G-C-I.COM
Creating Custom Code Snippets Two Elements • <Header> • <Snippet> <Header> <Title>Singleton</Title> <Shortcut>Singleton</Shortcut> <Description>Code snippet singleton class</Description> <Author>Babulal K R</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> BabulalK @ G-C-I.COM
<Snippet> Sub-element to specify the basic code. Contains 4 sub elements like < References > -- To add assembly references. < Imports > -- To import the Namespaces. < Declarations> -- Define the variables or type. < Code> -- Info for Code generation. Continued… BabulalK @ G-C-I.COM
<References> <References> <Reference> <Assembly>System.dll</Assembly> </Reference> </References> OR <References> <Reference> <Assembly>System.xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089 </Assembly> </Reference> </References> Demo… BabulalK @ G-C-I.COM
<Imports> <Imports> <Import> <Namespace>System. Collections</Namespace> </Import> </Imports> Demo… BabulalK @ G-C-I.COM
<Declarations> <Declarations> <Literal> <ID>type</ID> <ToolTip>Property type</ToolTip> <Default>String</Default> </Literal> <Literal> <ID>property</ID> <ToolTip>Property name</ToolTip> <Default>MyProperty</Default> </Literal> <Literal> <ID>field</ID> <ToolTip>The variable backing this property</ToolTip> <Default>_myPropertyr</Default> </Literal> </Declarations> Demo… BabulalK @ G-C-I.COM
<Code> • Language supported • CSharp • VB • VJSharp • XML <CodeLanguage="CSharp"> <![CDATA[private $type$ $field$; public $type$ $property$ { get { return $field$;} set { $field$ = value;} } $end$]]> </Code> BabulalK @ G-C-I.COM
Demo BabulalK @ G-C-I.COM
Q & A BabulalK @ G-C-I.COM
More reading… • http://msdn2.microsoft.com/en-us/library/9ybhaktf(VS.80).aspx. • http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx • http://www.developer.com/net/vb/article.php/10926_3505156_1 • http://dotnetjunkies.com/Article/C95AC204-DE44-4D4A-A2B7-1EB1BE14A8A1.dcik And of-course in my blog http://bazu.wordpress.com BabulalK @ G-C-I.COM