Udostępnij za pośrednictwem


Templates with Multiple IWizard Implementations

Visual Studio supports chaining, which enables a single template to have multiple IWizard implementations. These implementations are called sequentially, so you can create templates that have rich, flexible functionality.

Implementation Details

A Microsoft-implemented VsTemplate wizard is invoked to process a template by reading its .vstemplate file. A VsTemplate can list one or more assemblies that have an IWizard implementation that will be called to participate in processing the template. To take advantage of chaining, all the wizards must be listed in the template's .xml file in the order in which they should be called.

A Dictionary object can act as a parameter replacement list by enabling a template to pass parameters to an IWizard implementation, and also enabling one IWizard implementation to pass parameters to another. A reference to the Dictionary that is passed to RunStarted can be saved by the IWizard. Any changes that were made by the IWizard in notification callbacks are persisted.

Replacement parameters (such as $MyVariable) are global in scope and may be accessed from any IWizard. Make sure to uniquely name any replacement variables that you do not want other IWizards to accidentally use or change. We recommend that you document any replacement parameters for your wizards, so that other users know what they are used for.

IWizard contains a boolean property named ShouldAddItem. This property notifies a wizard whether it should add the indicated files. If ShouldAddItem is set to false, then none of the wizards that follow the current wizard will load the item.

See Also

Tasks

How to: Substitute Parameters in a Template

How to: Use Wizards with Project Templates