C#自定义代码段功能 [英] C# Custom Code Snippet Functions

查看:135
本文介绍了C#自定义代码段功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似这样的代码片段结构:

I have a code snippet structures like so:

    private $type$ $lowercaseName$;
    public $type$ $uppercaseName$
    {
        get { return $lowercaseName$; }
        set { $lowercaseName$ = value; }
    }

它会生成以下内容:

    private string randomValue;
    public string RandomValue
    {
        get { return randomValue; }
        set { randomValue = value; }
    }

那是一个过于简化的版本……实际上要复杂得多。 ..及其要输入的更多信息。如果您可以输入 $ uppercaseName $ ,然后自定义代码段函数将值分配给 $ lowercaseName $ ....

Thats a very oversimplified version... its really a lot more complicated... and its just that much more information to type in. It would be nice if you could type in $uppercaseName$, and then a custom snippet function would assign a value to $lowercaseName$....

但是有可能编写自定义代码段功能吗?在文档中,我什么都没有看到 ...

But is it even possible to write custom snippet functions? I don't see anything about this in the documentation...

如果可能...如何?

推荐答案

尚不可能。请参阅2010年被拒绝的建议。

It is not yet possible. See this suggestion for 2010 that was denied.

http://connect.microsoft.com/VisualStudio/feedback/details/523601/allow-custom-code-snippet-functions

似乎在引入代码片段时建议使用此功能,并且已针对每个版本重新建议了该功能,并拒绝说它们没有足够的时间。

It seems this feature was suggested when snippets were introduced, and has been re-suggested every version, and shot down saying they don't have enough time.

这篇关于C#自定义代码段功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆