[英]how to add item template in visual studio 2017 using Wizard
Description: I'm developing a solution in which I'll call a template item with the form I want it to add. 说明:我正在开发一种解决方案,在该解决方案中,我将使用要添加的表单来调用模板项。
And I wonder if this is the best solution to use or has another method. 我想知道这是不是最好的解决方案,还是有另一种方法。
my project
我的项目
Code: calss1.vstemplate 代码:calss1.vstemplate
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>class1.cs</DefaultName>
<Name>Myproject class1</Name>
<Description>Myproject Class</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>Myprojectclass1.png</Icon>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Linq</Assembly>
</Reference>
<Reference>
<Assembly>System.Threading.Tasks</Assembly>
</Reference>
</References>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">class1.cs</ProjectItem>
<CustomParameters>
<CustomParameter Name="$username$" Value="$safeitemrootname$"/>
<CustomParameter Name="$rootnamespace$" Value="$safeitemrootname$"/>
<CustomParameter Name="$registeredorganization$" Value="$safeitemrootname$"/>
</CustomParameters>
</TemplateContent>
//Call my Form
<WizardExtension>
<Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f7a1fcb8d457e160</Assembly>
<FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
Is this method valid? 这种方法有效吗? Is there another method?
还有其他方法吗?
I created a new method to call the item template using the "WizardRunKind". 我创建了一个新方法来使用“ WizardRunKind”调用项目模板。
This is the code I created: 这是我创建的代码:
public void RunStarted(object automationObject,
Dictionary<string, string> replacementsDictionary,
WizardRunKind runKind, object[] customParams)
{
if (runKind.HasFlag(WizardRunKind.AsNewItem))
{
inputForm = new MyProjectModulo();
inputForm.ShowDialog();
}
Note: Just call the item with the key.snk 注意:只需使用key.snk调用该项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.