Before we start looking at building our own template with a
Wizard, I would like to explain some elements of the IWizard interface.
IWizard interface allows us to define the logic for a
template. You have to create a class by implementing the IWizard interface.
The IWizard interface has the following methods.
BeforeOpeningFile - Runs custom wizard logic before opening
an item in the template.
ProjectFinishedGenerating - Runs custom wizard logic when a
project has finished generating.
ProjectItemFinishedGenerating - Runs custom wizard logic
when a project item has finished generating.
RunFinished - Runs custom wizard logic when the wizard has
completed all tasks.
RunStarted - Runs custom wizard logic at the beginning of a
template wizard run.
ShouldAddProjectItem - Indicates whether the specified
project item should be added to the project.
Based on your Wizard template requirements you can code any
of the above events. In this article I will code the RunStarted event.
The majority of the time the templates are required to
replace a few words when the project is created. For example, if you wanted to
assign the connectionstring in Web.Config file based on user input, then you
would create the Web.Config connectionstrings section as the following.
<add name="LocalSqlServer" connectionString="$LocalHostString$"
The Wizard Interface will be tasked with replacing the
$LocalHostString$ value. The way the Wizard replaces this string is by using
the System.Collections.Generic.Dictionary object.