Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在visual studio模板中使用$if$_C#_Vsix_Visual Studio Templates - Fatal编程技术网

C# 在visual studio模板中使用$if$

C# 在visual studio模板中使用$if$,c#,vsix,visual-studio-templates,C#,Vsix,Visual Studio Templates,您好,我正在根据教程创建vsix扩展。如果变量值为True,我需要在某处放置一个代码,如果变量值为False 在本例中,Microsoft使用了此$if$命令 $if$ ($targetframeworkversion$ >= 3.5)using System.Linq; $endif$using System.Text; 我写了一个类似的命令,但它不起作用 Console.WriteLine("$custommessage$"); // this line work fine and

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

在本例中,Microsoft使用了此$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$
现在我期待这段代码

WriteLine($custommessage$“+”这是真的“)


要在创建新项目时生成,但没有代码

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

意思是,(data.Equals(“True”)未运行或执行

处理模板时,仅计算宏,如$targetframeworkversion$或其他可能已通过自定义IWizard.RunStarted方法添加到替换词典的宏


Ed…

如果你这样做会发生什么<代码>$if$(“$custommessage$”.Equals(“True”))?也许它存储在一个不起作用的中间变量中。@PalleDue它在Nx中不起作用,那么我该怎么做呢?有什么办法吗?$if$(“$custommessage$”==“True”)控制台。WriteLine(“$custommessage$”+“这是True”)#endif$Caveat,我没有测试它:-)