Skip to main content

Posts

Showing posts from February, 2012

CanML– Creating simple Markup language using XML + T4 for drawing shapes in HTML5 Canvas in your ASP.NET/C# applications

In this post, we’ll explore how to create a simple Xml based markup language for defining shapes for HTML5 Canvas. We’ll achieve this by generating JavaScript code from the Xml definition, and this post is intended to be a pointer towards how you can leverage scaffolding and meta programming to simplify a lot of scenarios.  If you don’t have a lot of kids to look after, modify this to create your own version of full fledged CanML (take that name) and let me know Coming back - We’ll be using my Elastic Object Nuget package and T4 templates for code generation as I explained in my last post [Using AmazedSaint.ElasticObject Nuget Package for code generation], so reading that post will help for sure. I also suggest you to read quickly this Basic Canvas tutorial in MDN[+] Source code -Download ASP.NET MVC zipped example From Skydrive and keep it handyWhat we are going to achieve?You’ll be able to declare your canvas shapes using XML, for example see how I’m declaring a Heart shape and a Tr…

XML Driven C#/T4 Code Generation with ElasticObject Nuget Package For Minimalists ;)

Code generation should be simple, and I wanted to do it by using a simple XML file as my model from with in Visual Studio. So, here is a quick wrapper I’ve created for Xml driven code generation for minimalists/minimal scenarios.Starting Super Simple XML driven code generation – Now with NugetHere we go – this is based on my ElasticObject implementation to generate code using Text Templates (TT/T4), by using simple XML files as a model. It is so simple that it won’t support the entire XML schema -  But I’ll live with that for now. So, the steps are simple.Step 1 - Get the ElasticObject Nuget PackageInstall AmazedSaint.ElasticObject, run the following command in the Package Manager ConsolePM> Install-Package AmazedSaint.ElasticObjectOr you can install this via the Nuget Package manager, it is your choice.Step 2 – EnjoyThis should add the reference to ElasticObject library, and will add an Xml model file and a T4 template in the Solution Explorer (See the image). The xml file can be…