Tag: VisualStudio2010/コードスニペット

目次

参考情報

基本

C#用

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propnch</Title>
      <Shortcut>propnch</Shortcut>
      <Description>Code snippet for property and backing field and ensure that it invokes INotifyPropertyChanigng and INotifyPropertyChanged</Description>
      <Author>Abhishek</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)
            {
                $field$ = value;
	        NotifyPropertyChanged("$property$");
            }
        }
    }
    $end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>notifypc</Title>
      <Shortcut>notifypc</Shortcut>
      <Description>Code snippet for NotifyPropertyChanged</Description>
      <Author>mt</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp">
        <![CDATA[
    public void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null) 
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    $end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>obs</Title>
      <Shortcut>obs</Shortcut>
      <Description>ObservableCollection</Description>
      <Author>mt</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property type</ToolTip>
          <Default>string</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[ObservableCollection<$type$>$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propobs</Title>
      <Shortcut>propobs</Shortcut>
      <Description>ObservableCollection Property</Description>
      <Author>mt</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property type</ToolTip>
          <Default>string</Default>
        </Literal>
	<Literal>
          <ID>field</ID>
          <ToolTip>The variable backing this property</ToolTip>
          <Default>myVar</Default>
	</Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
        public ObservableCollection<$type$> $field$ {get; set; }
$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS