Saturday, April 28, 2007

 

Code Creator - a C# based mini PHP

Creating code dyanamically is a very strong requirement for any advanced programming tasks. Code Creator source will be available in the near future. The software and data files presented at Demo Camp on Apr 30th can be found here. A PowerPoint presentation that is also available.

Also see Creating as SilverLight Control with CodeCreator for an example on using CodeCreator.

Code Creator supports the creation of almost any type of code including XML.
Code Creator competes very well with PHP in the .net environment simply because it leverages .net's power. Above all Code Creator is small and simple.

An example of CodeCreator creating C# code segment.
// In a real system "nameUC" and "name" would get data
// from a database or XML data file.
// "nameUC" and "name" are
// passed as parameters to Code Generator.
//

string[] nameUC = new string[]{"NAME", "SYSTEM", "ADMINISTRATOR"};
string[] name = new string[] {"Name", "System", "Administrator"};
...
// The next few lines of code are passed to Code Generator
// as a string.
//
//<Repeat> -- note that Code Creator commands are
// hidden in comments.

public const string NAME = "name";
//<Replace>public const string $nameUC$ = "$name$";</Replace>
//</Repeat>
Will result in code be generated below:
public const string NAME = "Name";
public const string SYSTEM = "System";
public const string ADMINISTRATOR = "Administrator";
CodeCreator Uses
-Create typed classes from a database schema
---example C# classes where enumerations, string constants and properties are created dynamically
-Build powerful HTML controls easily
---example create JavaScript and HTML code dynamically from CLR objects
-Build WPE/E (SilverLight) controls

Code Creator details:
- less than 1000 lines of C# code
- few basic functions – Replace, Repeat, Declare, Evaluate
- Accepts data from XML or CLR objects (very much like WPF).
- Built primarily on
--> “StringBuilder” class.
--> Tiny Interpreter class.

Tiny Interpreter (C#)
- Implementation of “Gang of 4” interpreter class
- Uses 80 line method employing REGEX to tokenize string
- Less 1000 lines of code
- Evaluates mathematical and logical expressions
- Example:
<Evaluate>XCoord = XCoord + (30 * Height);</Evaluate>


Demonstrated at Ottawa Demo Camp

Labels:


Comments: Post a Comment





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]