我正在为Visual Studio开发一个projet模板,该模板将显示一个向导,以允许开发人员选择要创建的itens(类)。
我的问题是模板没有任何Itens(类,表单,文件夹...),所有Itens都将基于select Itens动态创建。
选择后如何将项目动态添加到项目中。
用于选择项目的向导如下所示。
namespace Primavera.Extensibility.Wizard
{
public class WizardImplementation : IWizard
{
private Modules frm;
private string customMessage;
// This method is called before opening any item that
// has the OpenInEditor attribute.
public void BeforeOpeningFile(ProjectItem projectItem)
{
}
public void ProjectFinishedGenerating(Project project)
{
}
// This method is only called for item templates,
// not for project templates.
public void ProjectItemFinishedGenerating(ProjectItem
projectItem)
{
}
// This method is called after the project is created.
public void RunFinished()
{
}
public void RunStarted(object automationObject,
Dictionary<string, string> replacementsDictionary,
WizardRunKind runKind, object[] customParams)
{
try
{
// Display a form to the user. The form collects the classes checked
frm = new Modules();
frm.ShowDialog();
customMessage = Modules.CustomMessage;
replacementsDictionary.Add("$custommessage$",
customMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
// This method is only called for item templates,
// not for project templates.
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
}
}