I'll need at least a day to digest this. Anders has written an XmlSerializer in JavaScript using the Javascript equivalent of Declarative Attributes called annotations. He's used the Java syntax for attributes, as he says "JavaScript has a closer relation to the Java language than .NET."
(Which isn't really true, as Netscape's LiveScript begat JavaScript begat ECMAScript. Java is in the name only for sex appeal.)
He's built a Javascript Reflection subsystem that parses the comments and gives a reflection-style API and feel. The XmlSerializer is built on top of that Reflection system. To implement "properties" you create get accessors for your fields.
Example:
Calculator.square=function(num) {/** *@Version(“1.0.0”) *@Modifiers(modifiers=Modifier.static|Modifier.public) *@Returns(type=”number”,description=”The square of the given number”)*/ return num*num;}
Kudos to you Anders!
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List