zoukankan      html  css  js  c++  java
  • [Note] 使用Code Snippet简化编码

     使用NewtonSoft.Json写实体类时大量格式一致的代码出现 ,这时可以使用Code snippet来加快编码速度

    [JsonProperty(PropertyName = "message"]
    
    public string Message { get; set;}

    我把这个代码片段叫做jsonp , 要输入这两行代码时输入 jsonp 然后按 Tab就搞定了,还可以继续按Tab修改属性的名字

    Snippet文件如下

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
    <Header>
    <Title>jsonp</Title>
    <Shortcut>jsonp</Shortcut>
    <Description>Code snippet for JsonProperty</Description>
    <Author>x wang</Author>
    <SnippetTypes>
    <SnippetType>Expansion</SnippetType>
    </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>type</ID>
          <Default>string</Default>
          <Function/>
        </Literal>
        <Literal Editable="true">
          <ID>field</ID>
          <Default>fieldname</Default>
          <Function/>
        </Literal>
        <Literal Editable="true">
          <ID>Property</ID>
          <Default>PropertyName</Default>
          <Function/>
        </Literal>
      </Declarations>
    <Code Language="csharp"><![CDATA[
    [JsonProperty(PropertyName = "$field$")]
    public $type$ $Property$ { get; set;}
    ]]>
    </Code>
    </Snippet>
    </CodeSnippet>
    </CodeSnippets>

    参考链接

    Visual Studio 的代码片段(Code Snippet)功能

  • 相关阅读:
    测试打印功能
    绘图
    图片验证码
    图片防盗
    图片水印
    surface 译
    ViewManager 译
    WindowId 译
    Display
    LayoutParams
  • 原文地址:https://www.cnblogs.com/arcsinw/p/6227375.html
Copyright © 2011-2022 走看看