2012-01-28 53 views
4

我想在VS2010中爲我的C#代碼創建一個小的自定義代碼片段。它基本上插入了一個註釋塊來提供信息。在這段代碼中,雖然我希望在插入片段時自動插入當前日期。用DateTime.Now自定義代碼片段

這裏是當前片斷我:

<CodeSnippet Format="1.0.0"> 
    <Header> 
     <Title> 
      C# Class Comments 
     </Title> 
     <Shortcut>ccom</Shortcut> 
    </Header> 
    <Snippet> 
     <Declarations> 
      <Object> 
       <ID>DateTime</ID> 
       <Type>System.DateTime</Type> 
       <Function>DateTime.Now()</Function> 
      </Object> 
      <Literal> 
       <ID>Author</ID> 
       <ToolTip>Replace with name creator of class.</ToolTip> 
       <Default>"Author name"</Default> 
      </Literal> 
      <Literal> 
       <ID>Date</ID> 
       <ToolTip>Replace with date class was created</ToolTip> 
       <Default>"Date"</Default> 
      </Literal> 
      <Literal> 
       <ID>Modified</ID> 
       <ToolTip>Replace with modified date of class</ToolTip> 
       <Default>"Modified"</Default> 
      </Literal> 
      <Literal> 
       <ID>Description</ID> 
       <ToolTip>Replace with a short description of what the class is used for</ToolTip> 
       <Default>"Description"</Default> 
      </Literal> 
     </Declarations> 
     <Code Language="CSharp"> 
      <![CDATA[ 
      //*******************************************************************************; 
      // Author:   $Author$ 
      // Created Date: $DateTime$ 
      // Modified Date: $Modified$ 
      // Description:  $Description$ 
      //*******************************************************************************; 
      ]]> 
     </Code> 
    </Snippet> 
</CodeSnippet> 

我有什麼做的插入片斷插入代碼的日期?

+0

這是不可能的。你需要一個宏來代替。 – 2012-01-28 21:09:56

回答

6

這不幸的是不是真的可能。 Visual Studio片段體系結構不支持替換宏,例如當前日期/時間

+0

噢好吧,因爲我看到了一些關於功能的東西,但並不完全知道如何使用它們,並認爲這樣做會起作用 – mattgcon 2012-01-28 21:19:47