CodeSnippet
- 路由事件
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>路由事件代码段</Title>
<Author>衆尋</Author>
<Shortcut>roue</Shortcut>
<Description>生成默认的路由事件</Description>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>属性类型</ToolTip>
<Default>EventHandler</Default>
</Literal>
<Literal>
<ID>RoutedEventName</ID>
<ToolTip>属性名</ToolTip>
<Default>MyEvent</Default>
</Literal>
</Declarations>
<Code Language="XML">
<![CDATA[
public event $type$ $RoutedEventName$
{
add{ AddHandler($RoutedEventName$Event, value); }
remove{ RemoveHandler($RoutedEventName$Event, value); }
}
public static readonly RoutedEvent $RoutedEventName$Event=EventManager.RegisterRoutedEvent(
"$RoutedEventName$",RoutingStrategy.Bubble,typeof($type$),typeof(myclass));
]]>
</Code>
</Snippet>
</CodeSnippet>
代码效果
RoutedEventArgs routedEvent = new RoutedEventArgs(OutPutChangedEvent);
RaiseEvent(routedEvent);
- Devexpress 通知属性
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propdx</Title>
<Shortcut>propdx</Shortcut>
<Description>属性和支持字段的代码片段</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>属性类型</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>属性名</ToolTip>
<Default>MyProperty</Default>
</Literal>
<Literal>
<ID>field</ID>
<ToolTip>支持此属性的变量</ToolTip>
<Default>myVar</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
public $type$ $property$
{
get { return GetProperty(() => $property$);}
set { SetProperty(() => $property$, value); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>