在 Visual Studio 模板中使用 $if$

用户11453013

嗨,我正在根据教程创建一个 vsix 扩展如果变量值为True我需要在某处放置一个代码,如果变量值为False,需要放置另一个代码

在这个例子中,微软使用了这个$if$命令

$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;

我写了一个类似的命令,但没有用

Console.WriteLine("$custommessage$"); // this line work fine and return a True value


string data = "$custommessage$"; // we have True value in data

$if$ (data.Equals("True"))
    Console.WriteLine("$custommessage$" + " This is True");
$endif$

现在我期待这段代码

Console.WriteLine("$custommessage$" + " 这是真的");

新建项目时生成,但是没有代码

埃德·多尔

模板处理不执行模板中的代码。

意思是, (data.Equals("True")) 没有运行或执行。

处理模板时,只评估像 $targetframeworkversion$ 或其他您可能通过自定义 IWizard.RunStarted 方法添加到替换字典的宏。

埃德....

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章