Как добавить шаблон элемента в Visual Studio 2017 с помощью мастера - PullRequest
0 голосов
/ 13 ноября 2018

Описание: Я разрабатываю решение, в котором я назову элемент шаблона с формой, которую я хочу добавить.

И мне интересно, если это лучшее решение для использования или есть другой метод.

my project мой проект

Код: 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>

Этот метод действителен? Есть ли другой метод?

1 Ответ

0 голосов
/ 14 ноября 2018

Я создал новый метод для вызова шаблона элемента, используя «WizardRunKind».

Это код, который я создал:

    public void RunStarted(object automationObject,
    Dictionary<string, string> replacementsDictionary,
    WizardRunKind runKind, object[] customParams)
{
    if (runKind.HasFlag(WizardRunKind.AsNewItem))
    {
        inputForm = new MyProjectModulo();
        inputForm.ShowDialog();

    }

Примечание: просто позвоните пункту с ключом.snk

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...