Phillip Burch
Phillip Burch

Reputation: 459

Using Reflection in Templating engines

I'm looking into hacking a templating engine together. How can I convert a string that looks like this:

System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Core/css")

Into an actual method call using Reflection.

Thanks in advance.

Upvotes: 1

Views: 82

Answers (1)

M.Babcock
M.Babcock

Reputation: 18965

It is possible (I once had code that did it) but it is hardly worth the effort once you encounter (and try to patch) all of the possible edge cases. In the end, it almost always results in a code base that is nearly impossible to maintain.

I'd recommend picking up one of the more mature template engines (StringTemplate, Vici, Razor, etc) and use them. They could provide a good learning tool even if you can't use them directly.

Upvotes: 1

Related Questions