Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

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);
  • No labels