Aidan
Aidan

Reputation: 27

IWizard with multi project template

I have created a multi project template but I would like to edit some values stored in each of the projects based on the user input I got this to work through the Wizard template for a single project, but unable to do for multiple projects.

This is the wizard class under RunStarted method

 wizardFrm = new WizardForm();
 wizardFrm.ShowDialog();
 // call property from wizard form to read user input values
 strProjectPrefix = wizardFrm.ProjectPrefix;
 strwebCall = wizardFrm.WebCall;
 strPrefix = wizardFrm.Prefix;
 strServiceName = wizardFrm.ServiceName;
 strTransmit = wizardFrm.Transmit; 
 strService = wizardFrm.Service; 
 strUniqueID = wizardFrm.UniqueID; 
 strRecordID = wizardFrm.RecordID;
 strQueued = wizardFrm.Queued;
 strEmailSubject = wizardFrm.EmailSubject;
 strEmailCat = wizardFrm.EmailCat;
 strMethod = wizardFrm.Method;
 strTemplate = wizardFrm.Template;
 // sets the Values
 replacementsDictionary.Add(key: "$WebCall$", value: strwebCall);
 replacementsDictionary.Add(key: "$projectPrefix$", value: strProjectPrefix);
 replacementsDictionary.Add(key: "$prefix$", value: strPrefix);
 replacementsDictionary.Add(key: "$serviceName$", value: strServiceName);
 replacementsDictionary.Add(key: "$transmitted$", value: strTransmit);
 replacementsDictionary.Add(key: "$service$", value: strService);
 replacementsDictionary.Add(key: "$uniqueID$", value: strUniqueID);
 replacementsDictionary.Add(key: "$recordID$", value: strRecordID);
 replacementsDictionary.Add(key: "$queued$", value: strQueued);
 replacementsDictionary.Add(key: "$emailSubject$", value: strEmailSubject);
 replacementsDictionary.Add(key: "$Category$", value: strEmailCat);
 replacementsDictionary.Add(key: "$method$", value: strMethod);
 replacementsDictionary.Add(key: "$uriTemplate$", value: strTemplate);

This is one of the values that I want to change in one of the projects

public const string PREFIX = "$prefix$";

Would I need to create a Wizard template per project? or is there a way to do this with one Wizard?

Regards

Aidan

Upvotes: 0

Views: 312

Answers (1)

Aidan
Aidan

Reputation: 27

I managed to get this working i needed to add a childWizard.cs to the WizardTemplate project which then has the values to set for the sub projects.

This is the code needed to create a global dictionary under the main template wizard class.

 globalDictionary = new Dictionary<string, string>();
 globalDictionary.Add(key: "$WebCall$", value: strwebCall);

And in the child wizard that implements the IWizard interface

replacementsDictionary.Add(key: "$WebCallchild$", value: WizardClass.globalDictionary["$WebCall$"].ToString());

Once i added the $WebCallchild$ in the project classes where i wanted to update a value and add the below to the .vstemplate file for each project

<WizardExtension>
    <Assembly>
        LayerTemplateWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ea9d885401b51155
    </Assembly>
    <FullClassName>LayerTemplateWizard.IWizardChild</FullClassName>
</WizardExtension>

Then it allowed me to change all the values needed.

Hope this helps someone else

Aidan

Upvotes: 1

Related Questions