Thursday, November 20, 2008     •  Login
 
   
 
   
   
   
 
 
     
 
   Welcome to my blog! Minimize
Oct 2

Written by: Daniel Balla
Mon, 02 Oct 2006 21:55:16 GMT

Indeed, most times you write the events at a time, maybe in a region and the trigger methods afterwards in another region; but then you do the same with local fields and properties, and yet the prop snippet comes in handy. Therefore I thought a simple event code snippet would be useful. You can download it here and then copy it to your Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#\ directory

or, copy/paste from below:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>event</Title>
<Shortcut>event</Shortcut>
<Description>Code snippet to created and document an event</Description>
<Author>Daniel Balla</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>event</ID>
<ToolTip>Event name</ToolTip>
<Default>MyEvent</Default>
</Literal>
<Literal>
<ID>eventArgs</ID>
<ToolTip>Event arguments type</ToolTip>
<Default>EventArgs</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[#region Event Handler $event$ ($eventArgs$)
/// <summary>
/// This event is fired when |
/// </summary>
public event EventHandler $event$;
#endregion
#region Event notification $event$
/// <summary>
/// Notifies the listeners of the $event$ event
/// </summary>
/// <param name="e">The argument to send to the listeners</param>
protected virtual void On$event$($eventArgs$ e) {
if($event$ != null) {
$event$(this,e);
}
}
#endregion$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  
 
 
     
     
 
   Archives Minimize
 
 
     
     
 
   Search Blog Minimize