简体   繁体   English

带有DateTime.Now的自定义代码段

[英]Custom Snippet with DateTime.Now

I am trying to create a small custom snippet for my C# code in VS2010. 我正在尝试为VS2010中的C#代码创建一个小的自定义代码段。 It basically inserts a comment block for informational purposes. 它基本上插入了一个注释块以供参考。 Within this code though I want the current date to be automatically inserted when the snippet is inserted. 虽然我希望在插入代码段时自动插入当前日期,但在此代码中。

Here is the current snippet I have: 这是我目前的片段:

<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>

What do I have to do to insert the date that the snippet was inserted into the code? 如何插入代码片段插入代码的日期,我该怎么做?

This is unfortunately not really possible. 遗憾的是,这不太可能。 The Visual Studio snippet architecture doesn't support replacement macros for items such as the current date / time Visual Studio代码段架构不支持替换宏,例如当前日期/时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM