zoukankan      html  css  js  c++  java
  • VS代码片段

    VS代码片段官方说明:

    https://docs.microsoft.com/zh-cn/visualstudio/ide/visual-csharp-code-snippets?view=vs-2019


    可以通过箭头地址将常用的代码搞成自定义的代码片段放到vs里面,可以提高部分编码速度。

    用法:以下xml节点放片段快捷键,然后按两次Tab代码就快速生成。

    WPF

    • 注册依赖属性代码片段:propdpa.snippet
    <?xml version="1.0" encoding="UTF-8"?>
    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
      <CodeSnippet Format="1.0.0">
        <Header>
          <Title>propdpa</Title>
          <Author>Microsoft Corporation</Author>
          <Description>注册附加的依赖属性.</Description>
          <Shortcut>propdpa</Shortcut>
          <SnippetTypes>
            <SnippetType>Expansion</SnippetType>
          </SnippetTypes>
        </Header>
        <Snippet>
          <Declarations>
            <Literal>
              <ID>propertyType</ID>
              <ToolTip>替换为属性的类型.</ToolTip>
              <Default>int</Default>
            </Literal>
            <Literal>
              <ID>propertyName</ID>
              <ToolTip>替换为属性的名称.</ToolTip>
              <Default>MyProperty</Default>
            </Literal>
            <Literal>
              <ID>defaultValue</ID>
              <ToolTip>替换为属性的默认值.</ToolTip>
              <Default>0</Default>
            </Literal>
             <Object>
              <ID>ownertype</ID>
              <Type>Control</Type>
              <ToolTip>替换为要添加此代码段的类的名称.</ToolTip>
              <Default>ownerclass</Default>
            </Object>
          </Declarations>
          <Code Language="csharp">
            <![CDATA[
              /// <summary>
              /// 
              /// </summary>
              public static readonly DependencyProperty $propertyName$Property = DependencyProperty.RegisterAttached("$propertyName$", typeof($propertyType$), typeof($ownertype$), new PropertyMetadata($defaultValue$));
    
              /// <summary>
              /// 
              /// </summary>
              /// <param name="element"></param>
              /// <param name="value"></param>
              public static void Set$propertyName$(DependencyObject element, $propertyType$ value)
              {
                  element.SetValue($propertyName$Property, value);
              }
    
              /// <summary>
              /// 
              /// </summary>
              /// <param name="element"></param>
              /// <returns></returns>
              public static $propertyType$ Get$propertyName$(DependencyObject element)
              {
                  return ($propertyType$)element.GetValue($propertyName$Property);
              }
              $end$]]>
          </Code>
        </Snippet>
      </CodeSnippet>
    </CodeSnippets>
    
  • 相关阅读:
    arp攻击 (可查看同一局域网他人手机照片)
    SQL注入(转载)
    常见文件文件头文件尾格式总结及各类文件头
    CTF
    Base64,Base32,Base16进制的区别
    Maven学习总结(二):安装
    Maven学习总结(一):基本概念
    Myeclipse下集成SVN插件
    Windows下多个JDK版本之间的切换
    java线程的常用方法
  • 原文地址:https://www.cnblogs.com/wgx0428/p/13617661.html
Copyright © 2011-2022 走看看