Last change
on this file since 14042 was
7473,
checked in by abeham, 13 years ago
|
#1722: Updated event snippets to allow modifier to be set (in sealed classes you'll want to change it to private instead of protected virtual (which is the default). Also using "var" instead of the concrete class name as type for the handler variable and compacted code.
|
File size:
1.2 KB
|
Line | |
---|
1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
---|
3 | <CodeSnippet Format="1.0.0">
|
---|
4 | <Header>
|
---|
5 | <SnippetTypes>
|
---|
6 | <SnippetType>Expansion</SnippetType>
|
---|
7 | </SnippetTypes>
|
---|
8 | <Title>HL3.DefineEvent</Title>
|
---|
9 | <Author>Erik Pitzer</Author>
|
---|
10 | <Description>Defines a new event and a corresponding firing method.</Description>
|
---|
11 | <Shortcut>hl3DefineEvent</Shortcut>
|
---|
12 | </Header>
|
---|
13 | <Snippet>
|
---|
14 | <Declarations>
|
---|
15 | <Literal Editable="true">
|
---|
16 | <ID>EventName</ID>
|
---|
17 | <ToolTip>EventName</ToolTip>
|
---|
18 | <Default>EventName</Default>
|
---|
19 | <Function>
|
---|
20 | </Function>
|
---|
21 | </Literal>
|
---|
22 | <Literal Editable="true">
|
---|
23 | <ID>Modifier</ID>
|
---|
24 | <ToolTip>Visibility modifier</ToolTip>
|
---|
25 | <Default>protected virtual</Default>
|
---|
26 | <Function>
|
---|
27 | </Function>
|
---|
28 | </Literal>
|
---|
29 | </Declarations>
|
---|
30 | <Code Language="csharp"><![CDATA[public event EventHandler $EventName$;
|
---|
31 | $Modifier$ void On$EventName$() {
|
---|
32 | var handler = $EventName$;
|
---|
33 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
34 | }]]></Code>
|
---|
35 | </Snippet>
|
---|
36 | </CodeSnippet>
|
---|
37 | </CodeSnippets>
|
---|
Note: See
TracBrowser
for help on using the repository browser.