|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionClockWork Script Builder is a .NET library (2.0) to make the building of scripts more readable and structured. An extendible architecture lets developers add script building blocks (Script Items) for languages such as the ones provided in the download for JavaScript (Js) and XML (Xs). BackgroundRecently I started playing with ExtJs and I ended up needing to build large chunks of JavaScript from .NET code. I've never found a nice way to construct scripts in C# so this time I decided to write a library to help. Using the Code(CHM documentation is available from Tony's Wibbles.) In its simplest form, it is a way to join a bunch of Script script = Sb.Script(
"line 1;",
"line 2;",
"line 3;"
);
string result = script.Render();
Console.WriteLine(result);
It results in the following output: line 1;
line 2;
line 3;
However there's a lot more to it. Scripts don't just understand This example demonstrates the use of some core layout items. Script script = Sb.Script(
Sb.Line("1","2","3","4","5",";"),
Sb.Line("1","2","3","4","5",";"),
Sb.Indent(
Sb.Line("indented ","1","2","3","4","5",";"),
Sb.Line("indented ","1","2","3","4","5",";"),
Sb.Script(
Sb.Line("Some objects"),
Sb.Line("Number = ", 47),
Sb.Line("True = ", true),
Sb.Line("Now is = ", DateTime.Now)
)
)
);
string result = script.Render();
Console.WriteLine(result);
This results in the following output: 12345;
12345;
indented 12345;
indented 12345;
Some objects
Number = 47
True = True
Now is = 23/08/2008 11:23:00 AM
You will have noticed all the Script items are created using " Script LanguagesI have currently developed the following sets of script items to help in writing scripts:
Points of InterestDOM & RenderingAll objects added to a script are stored as-is (like a DOM). The If an Rendering is performed using a ScriptLayoutMost items have the option to select a layout mode ( ScriptIfThis item will do an A collection based Objects can implement the History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||