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)功能

  • 相关阅读:
    poj 3243 Clever Y(BabyStep GiantStep)
    poj 2417 Discrete Logging
    poj 3481 Double Queue
    hdu 4046 Panda
    hdu 2896 病毒侵袭
    poj 1442 Black Box
    hdu 2815 Mod Tree
    hdu 3065 病毒侵袭持续中
    hdu 1576 A/B
    所有控件
  • 原文地址:https://www.cnblogs.com/arcsinw/p/6227375.html
Copyright © 2011-2022 走看看