1
I am creating an extension for the visual studio that aims to create a project based on the options that the programmer wants. In this case a Wizard will be created where it will choose the entity(s) it wants to create, and based on this selection will be created the respecivas classes.
I already created the template (in my empty case) and respective Wizard for the selection of entities. The entity selection Wizard that is displayed when the user creates the project is in the image below. The goal is that when doing OK a project is created with the classes he chose, for example "Consolidacaosaldos" should give rise to a class within an "Accounting" folder"
Doubt is how to create classes dynamically based on selection.
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;
}
}
}
Congratulations on doing something above average, I wanted people to be creative in doing things to make their lives easier. I don’t even know if this is the case, if I wouldn’t have a better solution, but anyway, it’s cool, even if there’s one thing I don’t like in the code. All you had to do was ask what the doubt is.
– Maniero
@Maniero already reworked the question. The question is to dynamically create the classes/folders in the project based on the selection.
– Sérgio Sereno