【问题标题】:Custom Snippet with DateTime.Now带有 DateTime.Now 的自定义代码段
【发布时间】:2012-02-21 08:09:23
【问题描述】:

我正在尝试在 VS2010 中为我的 C# 代码创建一个小的自定义 sn-p。它基本上插入一个注释块以供参考。在这段代码中,虽然我希望在插入 sn-p 时自动插入当前日期。

这是我当前的 sn-p:

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

我需要做什么才能在代码中插入 sn-p 的日期?

【问题讨论】:

  • 这是不可能的。你需要一个宏来代替。

标签: c# visual-studio-2010 datetime code-snippets


【解决方案1】:

不幸的是,这是不可能的。 Visual Studio sn-p 架构不支持当前日期/时间等项目的替换宏

【讨论】:

  • 哦,好吧,因为我看到了一些关于函数的东西,但不太知道如何使用它们,并认为这会起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-14
相关资源
最近更新 更多