Jonathan Allen
Jonathan Allen

Reputation: 70287

Code Generation from XML Files in Visual Studio

I have xml files called 1.template, 2.template, 3.template, etc. (The number refers to the application's ID number inside our company.)

I want to be able to generate a strongly typed class that inherits from ConfigurationReader and exposes properties named for the keys in the XML template file. The template files have enough information to know what data type the properties should be.

What feature, product, or technology would you recommend?

Upvotes: 0

Views: 433

Answers (2)

marc_s
marc_s

Reputation: 754258

If you can live with the T4 templates, then that's probably your best bet.

However, T4 templates are somewhat limited - there's certain scenarios you can't easily handle. In that case, I would recommend CodeSmith. It's a fairly inexpensive and very exhaustive set of code generation tools and templates, which are a lot more powerful than T4. Especially the XML Support is outstanding - you can easily import an XML file with a XSD schema and use it's field as properties in your code generation templates. See also their video tutorials - most helpful!

Marc

Upvotes: 1

Ben M
Ben M

Reputation: 22492

T4 templates.

Upvotes: 1

Related Questions