views:

76

answers:

2

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 have one XML template file per application and rarely have more that one application in a solution.
  • I have a generic configuration reader called "ConfigurationReader".
  • I have projects in both C# and VB.

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?

+1  A: 

T4 templates.

Ben M
+1  A: 

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

marc_s