用DateTime.Now自定义代码片段
问题描述:
我想在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>
我有什么做的插入片断插入代码的日期?
答
这不幸的是不是真的可能。 Visual Studio片段体系结构不支持替换宏,例如当前日期/时间
+0
噢好吧,因为我看到了一些关于功能的东西,但并不完全知道如何使用它们,并认为这样做会起作用 – mattgcon 2012-01-28 21:19:47
这是不可能的。你需要一个宏来代替。 – 2012-01-28 21:09:56