sorry - directory should be
C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
This should do what you want
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets
xmlns="
http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>prope</Title>
<Shortcut>prope</Shortcut>
<Description>Code snippet for property and backing field with
event</Description>
<Author>Dotnet Consulting Ltd</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</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>myVar</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[private $type$ $field$;
public $type$ $property$
{
get { return $field$;}
set
{
if( $field$ == value )
return;
$field$ = value;
if( $property$Changed != null )
$property$Changed(this, EventArgs.Empty);
}
}
public event EventHandler $property$Changed;
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
put it in a file (say prope.snippet) and put it in the
C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets
directory
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
I would like to write a template / snippet for property, as they more or
less all follow the same verbose template.
Or maybe I just would like to edit the existing one?
Anyway I would like to have this (psedo-code) template
<object> <varname>;
public <object> <Propname>
{
get { return <varname>; }
set
{
if(<varname> == value)
return;
<varname> = value;
if(<Propname>Changed != null)
<Propname>Changed(this, EventArgs.Empty);
}
}
public event <EventHandler> <Propname>Changed;
how do I do that? what file shoulf I change?
--
There are 10 kinds of people in this world. Those who understand binary
and
those who don't.
[microsoft.public.dotnet.framework]
[microsoft.public.dotnet.framework]