Copying Properties from the Parent Template

You may want to share properties between a master template and sub-templates. For example, suppose you are working with a set of database-oriented templates, and each template defines a string property named Server. When you prompt for this property in the master template, only the master template's copy of the property receives a value.

To set the property in the sub-template, you use the CopyPropertiesTo method of the master template. This method matches properties from the master template to the sub-template on the basis of name and type. If it finds an exact match, it copies the value from the master template to the sub-template. This code snippet shows how you can use this method:

// instantiate the sub-template
Header header = this.Create<Header>();

// copy all properties with matching name and type to the sub-template instance
this.CopyPropertiesTo(header);