Codesmith practical skills (7): copying attributes from a parent Template

Source: Internet
Author: User
In use Codesmith ProceedCodeDuring generation, you may need to share attributes between the subtemplate and the parent template. For example, to write a template that generates code based on the database, each template defines a template named Server . When you use this attribute in the parent template, its value only takes effect for the parent template. To set this value to a subtemplate, you can use it in the parent template. Copypropertiesto Method. When this attribute is used in the parent template, its value is sent to the subtemplate. The following code shows how to use this method: // Instantiate the sub-template
Header =   New Header ();
// Copy all properties with matching name and type to the sub-template instance
This . Copypropertiesto (header );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.