<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:idx="urn:atom-extension:indexing" xmlns:gr="http://www.google.com/schemas/reader/atom/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" idx:index="no"><!--
Content-type: Preventing XSRF in IE.

--><generator uri="http://www.google.com/reader">Google Reader</generator><id>tag:google.com,2005:reader/user/07946391749317373099/state/com.google/broadcast</id><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><title>Jamie's shared items in Google Reader</title><gr:continuation>CL2Otriq1ZwC</gr:continuation><author><name>Jamie</name></author><updated>2009-11-09T09:58:31Z</updated><link rel="self" href="http://feeds.feedburner.com/JamiesDelphiClippings" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry gr:crawl-timestamp-msec="1257760711488"><id gr:original-id="tag:blogger.com,1999:blog-1802200272789527087.post-2609018460569232760">tag:google.com,2005:reader/item/581c27769e83c524</id><category term="Delphi" scheme="http://www.blogger.com/atom/ns#" /><category term="Newbie" scheme="http://www.blogger.com/atom/ns#" /><category term="Design Patterns" scheme="http://www.blogger.com/atom/ns#" /><title type="html">The Observer Design Pattern in Delphi – Pull</title><published>2009-11-08T21:14:00Z</published><updated>2009-11-08T23:45:44Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/tCRdtmkEtHQ/observer-design-pattern-in-delphi-pull.html" type="text/html" /><summary xml:base="http://tdelphihobbyist.blogspot.com/" type="html">As mentioned in the previous article The Observer Design Pattern in Delphi – Push I intended to do a “Pull” article to show, what I think is, a significant “feature” of this pattern and one that I thought was underplayed in the Head First Design Patterns book that I’m learning from.  I wrote code for this article a couple of times and in the end simply refactored the code from the previous&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/tCRdtmkEtHQ" height="1" width="1"/&gt;</summary><author><name>TDelphiHobbyist</name></author><source gr:stream-id="feed/http://tdelphihobbyist.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://tdelphihobbyist.blogspot.com/feeds/posts/default</id><title type="html">TDelphiHobbyist</title><link rel="alternate" href="http://tdelphihobbyist.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://tdelphihobbyist.blogspot.com/2009/11/observer-design-pattern-in-delphi-pull.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1257760711284"><id gr:original-id="http://www.dzone.com/links/283719.html">tag:google.com,2005:reader/item/d1c0b88467b85efe</id><category term=".net" /><category term="java" /><title type="html">Dependency Injection For Dummies</title><published>2009-11-09T08:26:44Z</published><updated>2009-11-09T08:26:44Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/hLr9Pmr-Oj4/dependency_injection_for_dummies.html" type="text/html" /><content xml:base="http://www.dzone.com/links/" type="html">&lt;a href="http://www.dzone.com/links/rss/dependency_injection_for_dummies.html"&gt;&lt;img src="http://cdn.dzone.com/images/thumbs/120x90/283719.jpg" style="width:120;height:90;float:left;vertical-align:top;border:1px solid #ccc"&gt;&lt;/a&gt;&lt;p style="margin-left:130px"&gt;The goal of this series is to introduce programming patterns and practices to developers who have little to no familiarity with them. This series does not intend to dive into the intricacies of each pattern / practice, but to give a brief overview that will (hopefully) inspire developers to learn more about them. &lt;br&gt;&lt;br&gt;&lt;a href="http://www.dzone.com/links/rss/dependency_injection_for_dummies.html"&gt;&lt;img src="http://www.dzone.com/links/voteCountImage?linkId=283719" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dzone/frontpage/~4/7KGLv_VpDVM" height="1" width="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/hLr9Pmr-Oj4" height="1" width="1"/&gt;</content><author><name>gsoir</name></author><source gr:stream-id="feed/http://www.dzone.com/links/feed/frontpage/rss.xml"><id>tag:google.com,2005:reader/feed/http://www.dzone.com/links/feed/frontpage/rss.xml</id><title type="html">dzone.com: latest front page</title><link rel="alternate" href="http://www.dzone.com/links/" type="text/html" /></source><feedburner:origLink>http://feeds.dzone.com/~r/dzone/frontpage/~3/7KGLv_VpDVM/dependency_injection_for_dummies.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1256753933223"><id gr:original-id="tag:blogger.com,1999:blog-6222893893652665733.post-352597110982034319">tag:google.com,2005:reader/item/ad506380528bebab</id><title type="html">Share Your Unicode Migration Story</title><published>2009-10-28T17:26:00Z</published><updated>2009-10-28T17:53:03Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/V96iAc4DBP8/share-your-unicode-migration-story.html" type="text/html" /><content xml:base="http://caryjensen.blogspot.com/" type="html">&lt;p&gt;Delphi developers everywhere (and I am including C++Builder developers here), I am asking for your help in preparing a white paper that I hope will serve the greater community for a long time to come. I have been asked to assemble a white paper on Unicode migration for Delphi and C++ developers, and I want to hear your story.&lt;/p&gt;&lt;p&gt;When Senior Director of Delphi Solutions Mike Rozlog originally approached me about putting together this paper, I was enthusiastic. However, there was a slight problem. &lt;/p&gt;&lt;p&gt;While I can easily write about issues concerning the size of PChars or the ins-and-outs of the new UnicodeString type, I felt that this white paper was too important to simply repeat the obvious. Instead, I really wanted to go for an “in the real world this is what you have to do” approach. And while it is a noble goal, it is simply too much for one developer. We each have our specializations, and each of us, if we do run into migration problems, is going to do so in our particular domain.&lt;/p&gt;&lt;p&gt;For example, I am primarily a database developer, and I often work at a pretty high level; querying databases, building user interfaces, generating reports, you know, the bread-and-butter kind of stuff. And as far as Unicode migration goes, I’ve got it easy. Several of my larger applications have converted with few or no problems. &lt;/p&gt;&lt;p&gt;But some of you work much closer to the metal, making extensive use of calls to the operating system API, using sophisticated third-party libraries, manipulating data at the bit and byte level, and generally working in a world where the size of characters and strings matters. If so, your Unicode migration has likely encountered challenges, some incidental and some significant, that you’ve had to solve along the way. It’s these real world stories that I want to hear about.&lt;/p&gt;&lt;p&gt;Now, you might be wondering, why have I been asked to write this white paper, given that I don’t normally have to deal with some of the more serious Unicode migration issues? It’s a valid question, and there is an equally valid answer. Another of my skills, beyond software development, is the ability to communicate clearly and simply about complex topics. With your input, I intend to produce a white paper that is organized, clear, and helpful to those whose Unicode migration is not yet started or complete. And, I want the paper to reflect the wealth of experience of the collective Delphi community on the subject, not just my own experience.&lt;/p&gt;&lt;p&gt;Here is what I am looking for. If you have solved a Unicode-related challenge in converting existing code or techniques to Delphi 2009 or later, I want your input. The basic input that I need is your name and email address (so I can contact you if I have questions), the company you work for (if you are willing to share that), a description of the problem, and a description of the solution. Code samples that demonstrate the problem and solution are preferred (though we do not want anything that is proprietary or non-disclosable).&lt;/p&gt;&lt;p&gt;If your solution is included in the white paper, you will be recognized for your contribution by name, unless you specifically request to remain anonymous.&lt;/p&gt;&lt;p&gt;You can email your contribution to Tim Del Chiaro at &lt;a href="mailto:Tim.DelChiaro@embarcadero.com"&gt;Tim.DelChiaro@embarcadero.com&lt;/a&gt;. Alternatively, you can submit your contribution using the Get Published interface at the Embarcadero Developer Network (EDN). A detailed description of how to submit your contribution can be found in the EDN article located &lt;a href="http://edn.embarcadero.com/article/40018"&gt;http://edn.embarcadero.com/article/40018&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Of course, you can also send questions or contributions to me at &lt;a href="mailto:cjensen@jensendatasystems.com"&gt;cjensen@jensendatasystems.com&lt;/a&gt;. Please include the words “Unicode migration” in the subject line. Please also feel free to contact me if you need help putting together your story. &lt;/p&gt;&lt;p&gt;We are looking to release this white paper as soon as possible, so we necessarily have to set a deadline for contributions. Please submit your Unicode migration story by 5:00pm (GMT-8), November 27&lt;sup&gt;th&lt;/sup&gt;, 2009.&lt;/p&gt;&lt;p&gt;Now, finally, a few words to please the Lawyers. Any Unicode migration contribution you send to me, Tim Del Chiaro, or upload to the Get Published interface, will be interpreted as explicit permission from you for Embarcadero Technologies to include your contribution, or descriptions of it, in the Unicode migration white paper, as well as in any other form, and that you have the right to grant this permission. &lt;/p&gt;&lt;p&gt;Thank you for your consideration. I sincerely hope to hear from many of you with your stories, and look forward to producing a paper that will help all Delphi developers with their Unicode migration challenges.&lt;/p&gt;&lt;p&gt;Copyright © 2009 Cary Jensen. All Rights Reserved&lt;/p&gt;&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/6222893893652665733-352597110982034319?l=caryjensen.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/V96iAc4DBP8" height="1" width="1"/&gt;</content><author><name>Cary Jensen</name></author><source gr:stream-id="feed/http://caryjensen.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://caryjensen.blogspot.com/feeds/posts/default</id><title type="html">Cary Jensen  &amp;quot;Let&amp;#39;s Get Technical&amp;quot;</title><link rel="alternate" href="http://caryjensen.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://caryjensen.blogspot.com/2009/10/share-your-unicode-migration-story.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1256513550566"><id gr:original-id="tag:blogger.com,1999:blog-29331675.post-5087920686311562851">tag:google.com,2005:reader/item/58e5c7532c8cbe7a</id><category term="Delphi" scheme="http://www.blogger.com/atom/ns#" /><category term="source code" scheme="http://www.blogger.com/atom/ns#" /><category term="The Delphi Magazine" scheme="http://www.blogger.com/atom/ns#" /><title type="html">TDM Rerun #14: A Portable XML</title><published>2009-10-25T21:59:00Z</published><updated>2009-10-25T21:59:50Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/QCUqCXXtamo/tdm-rerun-14-portable-xml.html" type="text/html" /><content xml:base="http://17slon.com/blogs/gabr/blogger.html" type="html">&lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The code unit, OmniXML.pas, which contains the XML representation interfaces, parser and writer, was written by a single programmer, Miha Remec (he is also the guy behind the &lt;/em&gt;&lt;a href="http://www.omnixml.com"&gt;www.omnixml.com&lt;/a&gt;&lt;em&gt;&lt;/em&gt;&lt;em&gt; website). He started writing it in 2000, because he was missing a native Delphi DOM parser, one that would represent the DOM the same way as it was designed. The best Delphi parser around at that time was OpenXML, but it used classes to represent XML elements, not interfaces. OmniXML uses interfaces, derived from the IXMLNode (as specified by the DOM). That also makes it almost completely compatible with the MSXML parser, which uses the same approach.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;- A Portable XML, The Delphi Magazine 105, May 2004&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In the 2004 May issue I wrote about &lt;a href="http://www.omnixml.com"&gt;OmniXML&lt;/a&gt;, a native Delphi XML parser. I described the OmniXML approach and wrote few short pieces of code that demonstrated its use. &lt;/p&gt;  &lt;p&gt;Today, five years later, OmniXML is still strong and I’m still using it, as you can see in my &lt;a href="http://17slon.com/blogs/gabr/labels/XML.html"&gt;Fluent XML&lt;/a&gt; series.&lt;/p&gt;  &lt;p&gt;Links: &lt;a title="TDM 105: A Portable XML [article]" href="http://17slon.com/blogs/gabr/TDM/tdm105-gp.pdf"&gt;article&lt;/a&gt; (PDF, 45 KB), &lt;a title="TDM 105: A Portable XML [source code]" href="http://17slon.com/blogs/gabr/TDM/tdm105-gp.zip"&gt;source code&lt;/a&gt; (ZIP, 795 KB).&lt;/p&gt;  &lt;div&gt;&lt;font size="-2"&gt;---&lt;br&gt;Published under the &lt;a href="http://creativecommons.org/licenses/by/3.0/"&gt;Creative Commons Attribution 3.0&lt;/a&gt; license&lt;/font&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/29331675-5087920686311562851?l=17slon.com%2Fblogs%2Fgabr%2Fblogger.html"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/QCUqCXXtamo" height="1" width="1"/&gt;</content><author><name>gabr</name></author><source gr:stream-id="feed/http://17slon.com/blogs/gabr/atom.xml"><id>tag:google.com,2005:reader/feed/http://17slon.com/blogs/gabr/atom.xml</id><title type="html">The Delphi Geek</title><link rel="alternate" href="http://17slon.com/blogs/gabr/blogger.html" type="text/html" /></source><feedburner:origLink>http://17slon.com/blogs/gabr/2009/10/tdm-rerun-14-portable-xml.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1256408216351"><id gr:original-id="http://wings-of-wind.com/?p=454">tag:google.com,2005:reader/item/50b029bfe5bf38aa</id><category term="News" /><category term="Polls" /><category term="Delphi" /><category term="People" /><title type="html">Delphi Legends 2009 Community Award</title><published>2009-10-24T16:58:48Z</published><updated>2009-10-24T16:58:48Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/lbB_DRDYZz4/" type="text/html" /><media:group><media:content url="http://0.gravatar.com/avatar/4d6b8e37fba46fdb2b7718b5cdf32c8b?s=96&amp;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&amp;r=G" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/delphi-spirit.png" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/gold-helmet.jpg" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/silver-helmet.jpg" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/nobility.jpg" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/bronze-helmet.jpg" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/community-nominee.jpg" /></media:group><media:group><media:content url="http://windwings.files.wordpress.com/2009/10/pie-chart.png" /></media:group><summary xml:base="http://wings-of-wind.com/" type="html">We reached at the final of our poll and we are ready to present the one who will receive the “Delphi Legends Community Award” this year.
First of all, a big thank you for all which voted (you are approx. 500 coders who voted). We should also be grateful to the Team members who passed by [...]&lt;img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wings-of-wind.com&amp;amp;blog=8811281&amp;amp;post=454&amp;amp;subd=windwings&amp;amp;ref=&amp;amp;feed=1"&gt;&lt;img src="http://feeds.feedburner.com/~r/WingsOfWindSoftware/~4/jOj854u4eTk" height="1" width="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/lbB_DRDYZz4" height="1" width="1"/&gt;</summary><author><name>Wings of Wind</name></author><source gr:stream-id="feed/http://feeds.feedburner.com/WingsOfWindSoftware"><id>tag:google.com,2005:reader/feed/http://feeds.feedburner.com/WingsOfWindSoftware</id><title type="html">Wings of Wind Software</title><link rel="alternate" href="http://wings-of-wind.com" type="text/html" /></source><feedburner:origLink>http://feedproxy.google.com/~r/WingsOfWindSoftware/~3/jOj854u4eTk/</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255510833332"><id gr:original-id="http://dmagin.wordpress.com/?p=368">tag:google.com,2005:reader/item/f1f4817acdd3ec38</id><category term="Embarcadero (CodeGear) stuff" /><category term="iPhone" /><title type="html">Pascal on the iPhone</title><published>2009-10-13T18:03:23Z</published><updated>2009-10-13T18:03:23Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/nLjkrxvuX7w/" type="text/html" /><media:group><media:content url="http://1.gravatar.com/avatar/5b24a1db8dc39772dc69e653f81d8fe4?s=96&amp;d=identicon&amp;r=G" /></media:group><media:group><media:content url="http://dmagin.files.wordpress.com/2009/10/bildschirmfoto-2009-10-13-um-19-50-26.png" /></media:group><media:group><media:content url="http://dmagin.files.wordpress.com/2009/10/bildschirmfoto-2009-10-13-um-19-50-38.png" /></media:group><media:group><media:content url="http://dmagin.files.wordpress.com/2009/10/foto-am-13-10-2009-um-19-51.jpg" /></media:group><content xml:base="http://dmagin.wordpress.com/" type="html">&lt;div&gt;&lt;br&gt;&lt;p&gt;&lt;a href="http://www.monien.net/blog/"&gt;Olaf Monien&lt;/a&gt;, &lt;a href="http://www.flickdotnet.de/"&gt;Holger Flick &lt;/a&gt; and I (Daniel Magin) are playing in our free time with a beta version from &lt;a href="http://www.remobjects.com/"&gt;RemObjects&lt;/a&gt;. marc hoffman and his team did a &lt;strong&gt;great job&lt;/strong&gt; to integrate the Oxygene stuff now also to the apple mac side. I have developed a lot of stuff on Xcode with Objective C and (my personal opinion) this shows me why i love pascal.&lt;/p&gt;
&lt;p&gt;it was only some simple steps to produce a native iPhone Application in Delphi like style. Olaf and I have developed a test application to show the current location of our iPhone. &lt;strong&gt;Yeaaahhhh and all written in pascal (!).&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;for Design we use the original Apple Interface Builder. to develop the code in pascal remobjects is producing a pascal plugin in monotouch. also i use my original apple certificate in the IDE so i have deployed the application to my real iPhone. The iPhone App is full native compile. So it can be pushed later also to the iTunes appstore.&lt;/p&gt;
&lt;p&gt;so it is only some time to wait to have a public Pascal compiler for the iPhone.&lt;/p&gt;
&lt;p&gt;Here the Application on the iPhone Simulator&lt;/p&gt;
&lt;p&gt;&lt;img title="Application on iPhone Simulator" src="http://dmagin.files.wordpress.com/2009/10/bildschirmfoto-2009-10-13-um-19-50-26.png?w=393&amp;amp;h=743" alt="Application on iPhone Simulator" width="393" height="743"&gt;&lt;/p&gt;
&lt;p&gt;Here some Pascal Code&lt;/p&gt;
&lt;p&gt;&lt;img title="Some iPhone Pascal Code" src="http://dmagin.files.wordpress.com/2009/10/bildschirmfoto-2009-10-13-um-19-50-38.png?w=777&amp;amp;h=366" alt="Some iPhone Pascal Code" width="777" height="366"&gt;&lt;/p&gt;
&lt;p&gt;An here on my physical iPhone&lt;/p&gt;
&lt;p&gt;&lt;img title="My an my iPhone Pascal Application" src="http://dmagin.files.wordpress.com/2009/10/foto-am-13-10-2009-um-19-51.jpg?w=640&amp;amp;h=480" alt="My an my iPhone Pascal Application" width="640" height="480"&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;daniel&lt;/p&gt;
&lt;p&gt;btw: think delphi!&lt;/p&gt;
  &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmagin.wordpress.com/368/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmagin.wordpress.com/368/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmagin.wordpress.com/368/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmagin.wordpress.com/368/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmagin.wordpress.com/368/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmagin.wordpress.com/368/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmagin.wordpress.com/368/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmagin.wordpress.com/368/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmagin.wordpress.com/368/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmagin.wordpress.com/368/"&gt;&lt;/a&gt; &lt;img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmagin.wordpress.com&amp;amp;blog=1813584&amp;amp;post=368&amp;amp;subd=dmagin&amp;amp;ref=&amp;amp;feed=1"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/nLjkrxvuX7w" height="1" width="1"/&gt;</content><author><name>dmagin</name></author><source gr:stream-id="feed/http://dmagin.wordpress.com/feed/"><id>tag:google.com,2005:reader/feed/http://dmagin.wordpress.com/feed/</id><title type="html">Daniel Magin&amp;#39;s Weblog</title><link rel="alternate" href="http://dmagin.wordpress.com" type="text/html" /></source><feedburner:origLink>http://dmagin.wordpress.com/2009/10/13/pascal-on-the-iphone/</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255368013936"><id gr:original-id="http://blog.gurock.com/?p=730">tag:google.com,2005:reader/item/6fd7780178c74a12</id><category term="DelphiFeeds.com" /><category term="Programming" /><category term="SmartInspect" /><category term="si-article" /><title type="html">Working with Delphi’s new Exception.StackTrace</title><published>2009-10-12T16:30:16Z</published><updated>2009-10-12T16:30:16Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/XcYeNyeZYWc/" type="text/html" /><content xml:base="http://blog.gurock.com/" type="html">&lt;p&gt;One feature I often miss when using Delphi is the support for proper exception stack traces at run-time. You know, those useful stack traces that show you exactly where an exception occurred, ideally with the method name and line number of where the exception was raised. Both .NET and Java have excellent stack trace support built right into the framework and the Exception classes. You just call &lt;a href="http://msdn.microsoft.com/en-us/library/system.exception.stacktrace.aspx"&gt;Exception.StackTrace&lt;/a&gt; (.NET) or &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html#getStackTrace%28%29"&gt;Exception.getStackTrace&lt;/a&gt; (Java) and get a detailed analysis of where the exception was thrown and how it got passed to your exception handler.&lt;/p&gt;
&lt;p&gt;Unfortunately, Delphi never had good (built-in) run-time support for stack traces. The features for stack traces during debugging in the IDE are/were okay, but there were nothing in the language or framework which helped you to find out programmatically where an exception occurred at run-time and, more importantly, how it got passed to your exception handler (besides the original exception address, maybe). So, I was happy to see that Delphi 2009 finally introduced a new StackTrace property which, I hoped, would return a full-blown stack trace when you caught an exception.&lt;/p&gt;
&lt;p&gt;The initial happiness soon wore off when I realized that the StackTrace property was really just a placeholder to &lt;em&gt;return a stack trace from a possible stack trace provider&lt;/em&gt; rather than a real stack trace implementation. So, without such a provider (and there’s none that comes directly with Delphi), there is still no way to get a stack trace for your exceptions. Though a bit disappointing, the good thing is that there’s now finally a standardized way to get a stack trace, even if it’s not implemented by default.&lt;/p&gt;
&lt;p&gt;Exception reporting tools such as &lt;a href="http://www.eurekalog.com/"&gt;Eurekalog&lt;/a&gt; or &lt;a href="http://www.madshi.net/madExceptDescription.htm"&gt;madExcept&lt;/a&gt; or debug helpers such as the &lt;a href="http://sourceforge.net/projects/jcl/"&gt;JclDebug&lt;/a&gt; unit can register themselves as providers and use their engines to return a stack trace when an exception is raised. I’ve built a small unit which demonstrates this with the Jcl in combination with our logging tool &lt;a href="http://www.gurock.com/smartinspect/"&gt;SmartInspect&lt;/a&gt; and I’ve heard Fabio of Eurekalog is working on a similar feature for his component:&lt;/p&gt;
&lt;pre&gt;
unit StackTrace;

interface

uses
  SysUtils, Classes, JclDebug;

implementation

function GetExceptionStackInfoProc(P: PExceptionRecord): Pointer;
var
  LLines: TStringList;
  LText: String;
  LResult: PChar;
begin
  LLines := TStringList.Create;
  try
    JclLastExceptStackListToStrings(LLines, True, True, True, True);
    LText := LLines.Text;
    LResult := StrAlloc(Length(LText));
    StrCopy(LResult, PChar(LText));
    Result := LResult;
  finally
    LLines.Free;
  end;
end;

function GetStackInfoStringProc(Info: Pointer): string;
begin
  Result := string(PChar(Info));
end;

procedure CleanUpStackInfoProc(Info: Pointer);
begin
  StrDispose(PChar(Info));
end;

initialization
  // Start the Jcl exception tracking and register our Exception
  // stack trace provider.
  if JclStartExceptionTracking then
  begin
    Exception.GetExceptionStackInfoProc := GetExceptionStackInfoProc;
    Exception.GetStackInfoStringProc := GetStackInfoStringProc;
    Exception.CleanUpStackInfoProc := CleanUpStackInfoProc;
  end;

finalization
  // Stop Jcl exception tracking and unregister our provider.
  if JclExceptionTrackingActive then
  begin
    Exception.GetExceptionStackInfoProc := nil;
    Exception.GetStackInfoStringProc := nil;
    Exception.CleanUpStackInfoProc := nil;
    JclStopExceptionTracking;
  end;
end.
&lt;/pre&gt;
&lt;p&gt;The unit merely starts and stops the exception tracking of the Jcl, implements a minimal stack trace provider and registers for the Exception provider events. The GetExceptionStackInfoProc and CleanUpStackInfoProc functions are automatically called by the RTL to give the provider the opportunity to initialize and cleanup the stack trace after an exception occurred. GetStackInfoStringProc is called indirectly when you access the StackTrace property and is responsible for returning the actual stack trace. &lt;/p&gt;
&lt;p&gt;So, how do you use this unit? Let’s have a look at the following example:&lt;/p&gt;
&lt;pre&gt;
...

uses
  ..., StackTrace;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure SomeMethod;
  end;

implementation

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    SomeMethod;
  except
    // Log the exception: We use SmartInspect here because it has
    // built-in support for Exception.StackTrace but you could also
    // access the StackTrace property here directly.
    SiMain.LogException;
  end;
end;

procedure TForm1.SomeMethod;
begin
  raise Exception.Create('A test exception');
end;

...
&lt;/pre&gt;
&lt;p&gt;As you can see, using this unit is just a matter of adding it to our uses clause. It won’t get any simpler than that. The unit will take care of registering/unregistering itself as a stack trace provider and when you now access the StackTrace property of an Exception object, you will get a detailed stack trace. To include the method names and line numbers in the stack trace, make sure to let the linker include debug symbols into your application and to enable the ‘Use debug .dcus’ option in case you also want line numbers from the VCL and RTL methods.&lt;/p&gt;
&lt;div style="text-align:center"&gt;
&lt;a href="http://blog.gurock.com/wp-content/uploads/2009/10/delphi-stacktrace.png"&gt;&lt;br&gt;
&lt;img src="http://blog.gurock.com/wp-content/uploads/2009/10/delphi-stacktrace-small.png" alt="delphi-stacktrace-small" title="delphi-stacktrace-small" width="550" height="441"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The &lt;a href="http://www.gurock.com/smartinspect/"&gt;SmartInspect Console&lt;/a&gt; showing the stack trace of an exception&lt;/em&gt;
&lt;/div&gt;
&lt;p&gt;Now, when you use SmartInspect for logging and have a stack trace provider registered, all your logged exceptions automatically include the exception’s call stack. Pretty useful, isn’t it?&lt;/p&gt;
&lt;div style="float:right;margin-left:10px"&gt;&lt;a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.gurock.com%2Fpostings%2Fworking-with-delphis-new-exception-stacktrace%2F730%2F"&gt;&lt;img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.gurock.com%2Fpostings%2Fworking-with-delphis-new-exception-stacktrace%2F730%2F" height="61" width="51"&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/XcYeNyeZYWc" height="1" width="1"/&gt;</content><author><name>Tobias Gurock</name></author><source gr:stream-id="feed/http://blog.gurock.com/postings/category/delphi/feed/"><id>tag:google.com,2005:reader/feed/http://blog.gurock.com/postings/category/delphi/feed/</id><title type="html">Gurock Software Blog » DelphiFeeds.com</title><link rel="alternate" href="http://blog.gurock.com" type="text/html" /></source><feedburner:origLink>http://blog.gurock.com/postings/working-with-delphis-new-exception-stacktrace/730/</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255334594285"><id gr:original-id="tag:blogger.com,1999:blog-1802200272789527087.post-2274439970837406002">tag:google.com,2005:reader/item/e1fbcaaea131b3d6</id><category term="Newbie" scheme="http://www.blogger.com/atom/ns#" /><category term="Design Patterns" scheme="http://www.blogger.com/atom/ns#" /><title type="html">The Observer Design Pattern in Delphi – Push</title><published>2009-10-11T22:57:00Z</published><updated>2009-10-16T23:50:40Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/35Jupe1dQgw/observer-design-pattern-in-delphi-push.html" type="text/html" /><summary xml:base="http://tdelphihobbyist.blogspot.com/" type="html">A summary and [my rendition of] the Delphi code taken from the second chapter of the book, Head First Design Patterns from O’Reilly.  As I mentioned in the first post in this series, I’m studying Design Patterns using the Head First Design Patterns book from O’Reilly.   As part of this learning process I’m working through the existing examples written in Java and recreating them in Delphi.  This&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/35Jupe1dQgw" height="1" width="1"/&gt;</summary><author><name>TDelphiHobbyist</name></author><source gr:stream-id="feed/http://tdelphihobbyist.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://tdelphihobbyist.blogspot.com/feeds/posts/default</id><title type="html">TDelphiHobbyist</title><link rel="alternate" href="http://tdelphihobbyist.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://tdelphihobbyist.blogspot.com/2009/10/observer-design-pattern-in-delphi-push.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255016020860"><id gr:original-id="tag:blogger.com,1999:blog-3339459875755088113.post-4908481942746395583">tag:google.com,2005:reader/item/7c1fa51db27842c3</id><category term="Delphi" scheme="http://www.blogger.com/atom/ns#" /><category term="RTTI" scheme="http://www.blogger.com/atom/ns#" /><category term="XML" scheme="http://www.blogger.com/atom/ns#" /><title type="html">Xml Serialization - Basic Usage</title><published>2009-10-08T13:56:00Z</published><updated>2009-10-08T23:14:08Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/K0r4abEkplQ/xml-serialization-basic-usage.html" type="text/html" /><content xml:base="http://robstechcorner.blogspot.com/" type="html">This post relates to &lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/xmlserial.pas"&gt;XmlSerial.pas&lt;/a&gt; which provides XML serialization and de-serialization using the new RTTI in Delphi 2010.&lt;br&gt;&lt;br&gt;This class has been built to serialize any public and published property or Field.&lt;br&gt;This was done to mimic the behavior found in the .NET Xml Serialization with the goal of having a set of objects that can serialize in .NET using Delphi Prism and Win32 using Delphi 2010.   The complete goals of what I want to accomplish with &lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/xmlserial.pas"&gt;XmlSerial.pas&lt;/a&gt; look at the source code, I detailed out what still needs to be done.&lt;br&gt;&lt;br&gt;There are two ways to work with the Xml Serialization, one depends on a Pointer to the Type Information, the other uses Generics to get it form the type specified as a parameter.&lt;br&gt;&lt;pre&gt;&lt;br&gt;// Method 1:&lt;br&gt;var&lt;br&gt; o : TypeIWantToSerailze;&lt;br&gt; s : TXmlTypeSerializer;&lt;br&gt; x : TXmlDocument;&lt;br&gt; v : TValue;&lt;br&gt;begin&lt;br&gt;  s := TXmlTypeSerializer.create(TypeInfo(o));&lt;br&gt;  x := TXmlDocument.Create(Self); // NEVER PASS NIL!!!&lt;br&gt;  s.Serialize(x,o);&lt;br&gt;  x.SaveToFile('FileName.txt');&lt;br&gt;  v := s.Deserialize(x);&lt;br&gt;  o := v.AsType&amp;lt;TypeIWantToSerailze&amp;gt;;&lt;br&gt;  x.free;&lt;br&gt;  s.free;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;// Method 2:&lt;br&gt;var&lt;br&gt; o : TypeIWantToSerailze;&lt;br&gt; s : TXmlSerializer&amp;lt;TypeIWantToSerailze&amp;gt;;&lt;br&gt; x : TXmlDocument;&lt;br&gt;begin&lt;br&gt;  s := TXmlTypeSerializer&amp;lt;TypeIWantToSerailze&amp;gt;.create;&lt;br&gt;  x := TXmlDocument.Create(Self); // NEVER PASS NIL!!!&lt;br&gt;  s.Serialize(x,o);&lt;br&gt;  x.SaveToFile('FileName.txt');&lt;br&gt;  o := s.Deserialize(x);&lt;br&gt;  x.free;&lt;br&gt;  s.free;&lt;br&gt;end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;And here is the full code showing how to do this using the generic version.&lt;br&gt;&lt;pre&gt;&lt;br&gt;unit uPerson;&lt;br&gt;interface&lt;br&gt;&lt;br&gt;type&lt;br&gt;  TPerson = class(TObject)&lt;br&gt;  private&lt;br&gt;    FLastName: String;&lt;br&gt;    FBirthday: TDateTime;&lt;br&gt;    FMiddleName: String;&lt;br&gt;    FFirstName: String;&lt;br&gt;    function GetFullName: String;&lt;br&gt;   published&lt;br&gt;   public&lt;br&gt;     property FirstName : String read FFirstName write FFirstName;&lt;br&gt;     property LastName  : String read FLastName  write FLastName;&lt;br&gt;     property MiddleName : String read FMiddleName write FMiddleName;&lt;br&gt;     property FullName : String read GetFullName;&lt;br&gt;     property Birthday : TDateTime read FBirthday write FBirthday;&lt;br&gt;     procedure Save(FileName : String);&lt;br&gt;     class function Load(FileName : String) : TPerson;&lt;br&gt;   end;&lt;br&gt;&lt;br&gt;&lt;br&gt;implementation&lt;br&gt;uses&lt;br&gt; XmlDoc,&lt;br&gt; Classes,&lt;br&gt; XmlSerial;&lt;br&gt;&lt;br&gt;{ TPerson }&lt;br&gt;&lt;br&gt;function TPerson.GetFullName: String;&lt;br&gt;begin&lt;br&gt; result := FFirstName + ' ' + FMiddleName + ' ' + FLastName;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;class function TPerson.Load(FileName: String): TPerson;&lt;br&gt;var&lt;br&gt;  lSerialize : TXmlSerializer&amp;lt;TPerson&amp;gt;;&lt;br&gt;  lOwner : TComponent;&lt;br&gt;  lDoc   : TxmlDocument;&lt;br&gt;begin&lt;br&gt;  lOwner := TComponent.Create(nil);  // Required to make TXmlDocument work!&lt;br&gt;  try&lt;br&gt;    lDoc := TXmlDocument.Create(lOwner);  // will be freed with lOwner.Free&lt;br&gt;    lDoc.LoadFromFile(FileName);&lt;br&gt;    lSerialize := TXmlSerializer&amp;lt;TPerson&amp;gt;.Create;&lt;br&gt;    try&lt;br&gt;      result := lSerialize.Deserialize(lDoc);&lt;br&gt;    finally&lt;br&gt;      lSerialize.Free;&lt;br&gt;    end;&lt;br&gt;  finally&lt;br&gt;    lOwner.Free;&lt;br&gt;  end;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure TPerson.Save(FileName: String);&lt;br&gt;var&lt;br&gt;  lSerialize : TXmlSerializer&amp;lt;TPerson&amp;gt;;&lt;br&gt;  lOwner : TComponent;&lt;br&gt;  lDoc   : TxmlDocument;&lt;br&gt;begin&lt;br&gt;  lOwner := TComponent.Create(nil);  // Required to make TXmlDocument work!&lt;br&gt;  try&lt;br&gt;    lDoc := TXmlDocument.Create(lOwner);  // will be freed with lOwner.Free&lt;br&gt;    lSerialize := TXmlSerializer&amp;lt;TPerson&amp;gt;.Create;&lt;br&gt;    try&lt;br&gt;      lSerialize.Serialize(lDoc,Self);&lt;br&gt;      lDoc.SaveToFile(FileName);&lt;br&gt;    finally&lt;br&gt;      lSerialize.Free;&lt;br&gt;    end;&lt;br&gt;  finally&lt;br&gt;    lOwner.Free;&lt;br&gt;  end;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;end.&lt;br&gt;&lt;/pre&gt;&lt;br&gt;The project that shows how to use this object.&lt;br&gt;&lt;pre&gt;&lt;br&gt;program Project12;&lt;br&gt;&lt;br&gt;{$APPTYPE CONSOLE}&lt;br&gt;&lt;br&gt;uses&lt;br&gt;  SysUtils,&lt;br&gt;  Windows,&lt;br&gt;  XmlSerial,&lt;br&gt;  Forms,&lt;br&gt;  uPerson in 'uPerson.pas';&lt;br&gt;&lt;br&gt;var&lt;br&gt;  P : TPerson;&lt;br&gt;&lt;br&gt;begin&lt;br&gt;  Application.Initialize;&lt;br&gt;  P := TPerson.Create;&lt;br&gt;  try&lt;br&gt;   P.FirstName := 'John';&lt;br&gt;   P.MiddleName := 'C';&lt;br&gt;   P.LastName := 'Doe';&lt;br&gt;   P.Birthday := EncodeDate(1995,2,14);&lt;br&gt;   P.Save('C:\test.xml');&lt;br&gt;  finally&lt;br&gt;    P.Free;&lt;br&gt;  end;&lt;br&gt;&lt;br&gt;  p := TPerson.Load('C:\test.xml');&lt;br&gt;  try&lt;br&gt;    writeln(P.FullName);&lt;br&gt;    Writeln(DateToStr(P.Birthday));&lt;br&gt;    Readln;&lt;br&gt;  finally&lt;br&gt;    p.Free;&lt;br&gt;  end;&lt;br&gt;end.&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Output:&lt;br&gt;&lt;pre&gt;&lt;br&gt;John C Doe&lt;br&gt;2/14/1995&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Current output of the XML file, notice the Date, it's something I want to change, if you check the roadmap in the xmlserial.pas source.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;&amp;lt;TPerson&amp;gt;&lt;br&gt;   &amp;lt;FirstName&amp;gt;John&amp;lt;/FirstName&amp;gt;&lt;br&gt;   &amp;lt;LastName&amp;gt;Doe&amp;lt;/LastName&amp;gt;&lt;br&gt;   &amp;lt;MiddleName&amp;gt;C&amp;lt;/MiddleName&amp;gt;&lt;br&gt;   &amp;lt;Birthday&amp;gt;34744&amp;lt;/Birthday&amp;gt;&lt;br&gt;&amp;lt;/TPerson&amp;gt;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Hopefully this covers enough of how to use this to get you started.&lt;br&gt;I will show how to customize the behavior using attributes in a future post.&lt;br&gt;&lt;br&gt;&lt;a href="http://robstechcorner.blogspot.com/2009/09/so-what-is-rtti-rtti-is-acronym-for-run.html"&gt;RTTI Article List&lt;/a&gt;&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/3339459875755088113-4908481942746395583?l=robstechcorner.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/K0r4abEkplQ" height="1" width="1"/&gt;</content><author><name>Robert Love</name></author><source gr:stream-id="feed/http://robstechcorner.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://robstechcorner.blogspot.com/feeds/posts/default</id><title type="html">Rob’s Technology Corner</title><link rel="alternate" href="http://robstechcorner.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://robstechcorner.blogspot.com/2009/10/xml-serialization-basic-usage.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255012327915"><id gr:original-id="tag:blogger.com,1999:blog-3339459875755088113.post-3829330674743610371">tag:google.com,2005:reader/item/13434d43e5eb3b49</id><category term="Delphi" scheme="http://www.blogger.com/atom/ns#" /><category term="RTTI" scheme="http://www.blogger.com/atom/ns#" /><title type="html">INI persistence the RTTI way</title><published>2009-10-08T12:05:00Z</published><updated>2009-10-08T16:58:59Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/Dtzk0rP6UHc/ini-persistence-rtti-way.html" type="text/html" /><content xml:base="http://robstechcorner.blogspot.com/" type="html">This post is based around the &lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/IniPersist.pas"&gt;IniPersit.pas&lt;/a&gt; code that I just released.&lt;br&gt;&lt;br&gt;I commonly create configuration classes to create a common and easy way to access information stored in INI, Registry, or XML.  In these examples I will show how I used the new RTTI and Attributes in Delphi 2010 to provide a new way of creating a configuration class that access information stored in an INI file.&lt;br&gt;&lt;br&gt;Lets first start off showing how to use the New Unit, then we can pull back the covers and show how it works.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;unit ConfigSettings;&lt;br&gt;interface&lt;br&gt;uses&lt;br&gt;  IniPersist;&lt;br&gt;&lt;br&gt;type&lt;br&gt;  TConfigSettings = class (TObject)&lt;br&gt;  private&lt;br&gt;    FConnectString: String;&lt;br&gt;    FLogLevel: Integer;&lt;br&gt;    FLogDirectory: String;&lt;br&gt;    FSettingsFile: String;&lt;br&gt;  public&lt;br&gt;    constructor create;&lt;br&gt;    // Use the IniValue attribute on any property or field&lt;br&gt;    // you want to show up in the INI File.&lt;br&gt;    [IniValue('Database','ConnectString','')]&lt;br&gt;    property ConnectString : String read FConnectString write FConnectString;&lt;br&gt;    [IniValue('Logging','Level','0')]&lt;br&gt;    property LogLevel : Integer read FLogLevel write FLogLevel;&lt;br&gt;    [IniValue('Logging','Directory','')]&lt;br&gt;    property LogDirectory : String read FLogDirectory write FLogDirectory;&lt;br&gt;&lt;br&gt;    property SettingsFile : String read FSettingsFile write FSettingsFile;&lt;br&gt;    procedure Save;&lt;br&gt;    procedure Load;&lt;br&gt;&lt;br&gt;  end;&lt;br&gt;&lt;br&gt;implementation&lt;br&gt;uses SysUtils;&lt;br&gt;&lt;br&gt;{ TApplicationSettings }&lt;br&gt;&lt;br&gt;constructor TConfigSettings.create;&lt;br&gt;begin&lt;br&gt;  FSettingsFile := ExtractFilePath(ParamStr(0)) +  'settings.ini';&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure TConfigSettings.Load;&lt;br&gt;begin&lt;br&gt;// This loads the INI File Values into the properties.&lt;br&gt;   TIniPersist.Load(FSettingsFile,Self);&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure TConfigSettings.Save;&lt;br&gt;begin&lt;br&gt;// This saves the properties to the INI&lt;br&gt;   TIniPersist.Save(FSettingsFile,Self);&lt;br&gt;end;&lt;br&gt;&lt;br&gt;end.&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;program Project13;&lt;br&gt;&lt;br&gt;{$APPTYPE CONSOLE}&lt;br&gt;&lt;br&gt;uses&lt;br&gt;  SysUtils,&lt;br&gt;  IniPersist,&lt;br&gt;  ConfigSettings;&lt;br&gt;&lt;br&gt;var&lt;br&gt;  Settings : TConfigSettings;&lt;br&gt;&lt;br&gt;begin&lt;br&gt;    Settings := TConfigSettings.Create;&lt;br&gt;    try&lt;br&gt;      Settings.ConnectString := '\\127.0.0.1\DB:2032';&lt;br&gt;      Settings.LogLevel := 3;&lt;br&gt;      Settings.LogDirectory := 'C:\Log';&lt;br&gt;      Settings.Save;&lt;br&gt;    finally&lt;br&gt;      Settings.Free;&lt;br&gt;    end;&lt;br&gt;&lt;br&gt;    Settings := TConfigSettings.Create;&lt;br&gt;    try&lt;br&gt;    Settings.Load;&lt;br&gt;    WriteLn(Settings.ConnectString);&lt;br&gt;    Writeln(Settings.LogLevel);&lt;br&gt;    Writeln(Settings.LogDirectory);&lt;br&gt;    finally&lt;br&gt;      Settings.Free;&lt;br&gt;    end;&lt;br&gt;    Readln;&lt;br&gt;end.&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Output:&lt;br&gt;&lt;pre&gt;&lt;br&gt;\\127.0.0.1\DB:2032&lt;br&gt;3&lt;br&gt;C:\Log&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Resulting INI File:&lt;br&gt;&lt;pre&gt;&lt;br&gt;[Database]&lt;br&gt;ConnectString=\\127.0.0.1\DB:2032&lt;br&gt;[Logging]&lt;br&gt;Level=3&lt;br&gt;Directory=C:\Log&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;As you can see by the above code there really is not much too it, if you want a field or a property to be stored in the INI File, you just need to add the IniValue Attribute.&lt;br&gt;&lt;pre&gt;&lt;br&gt;  TExampleClass = class (TObject)&lt;br&gt;  private&lt;br&gt;    FConnectString: String;&lt;br&gt;  public&lt;br&gt;    [IniValue('Database','ConnectString')]&lt;br&gt;    property ConnectString : String read FConnectString write FConnectString;&lt;br&gt;  end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;The constructor of the INIValue allows you to specify the Section, Name you the field or Property stored in.   It also allows you to specify a default value if the name &amp;amp; section did not exist in the INI File.&lt;br&gt;&lt;pre&gt;&lt;br&gt;  IniValueAttribute = class(TCustomAttribute)&lt;br&gt;  private&lt;br&gt;    FName: string;&lt;br&gt;    FDefaultValue: string;&lt;br&gt;    FSection: string;&lt;br&gt;  published&lt;br&gt;     constructor Create(const aSection : String;const aName : string;const aDefaultValue : String = '');&lt;br&gt;     property Section : string read FSection write FSection;&lt;br&gt;     property Name : string read FName write FName;&lt;br&gt;     property DefaultValue : string read FDefaultValue write FDefaultValue;&lt;br&gt;  end;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;constructor IniValueAttribute.Create(const aSection, aName, aDefaultValue: String);&lt;br&gt;begin&lt;br&gt;  FSection := aSection;&lt;br&gt;  FName := aName;&lt;br&gt;  FDefaultValue := aDefaultValue;&lt;br&gt;end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;So the magic is really contained in TIniPersist&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;  TIniPersist = class (TObject)&lt;br&gt;  private&lt;br&gt;    class procedure SetValue(aData : String;var aValue : TValue);&lt;br&gt;    class function GetValue(var aValue : TValue) : String;&lt;br&gt;    class function GetIniAttribute(Obj : TRttiObject) : IniValueAttribute;&lt;br&gt;  public&lt;br&gt;    class procedure Load(FileName : String;obj : TObject);&lt;br&gt;    class procedure Save(FileName : String;obj : TObject);&lt;br&gt;  end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;The load and save methods are nearly identical, so lets take a look at load.&lt;br&gt;&lt;pre&gt;&lt;br&gt;class procedure TIniPersist.Load(FileName: String; obj: TObject);&lt;br&gt;var&lt;br&gt; ctx : TRttiContext;&lt;br&gt; objType : TRttiType;&lt;br&gt; Field : TRttiField;&lt;br&gt; Prop  : TRttiProperty;&lt;br&gt; Value : TValue;&lt;br&gt; IniValue : IniValueAttribute;&lt;br&gt; Ini : TIniFile;&lt;br&gt; Data : String;&lt;br&gt;begin&lt;br&gt; ctx := TRttiContext.Create;&lt;br&gt; try&lt;br&gt;   Ini := TIniFile.Create(FileName);&lt;br&gt;   try&lt;br&gt;     objType := ctx.GetType(Obj.ClassInfo); &lt;br&gt;     for Prop in objType.GetProperties do&lt;br&gt;     begin&lt;br&gt;       IniValue := GetIniAttribute(Prop);&lt;br&gt;       if Assigned(IniValue) then&lt;br&gt;       begin&lt;br&gt;          Data := Ini.ReadString(IniValue.Section,IniValue.Name,IniValue.DefaultValue);&lt;br&gt;          Value := Prop.GetValue(Obj);&lt;br&gt;          SetValue(Data,Value);&lt;br&gt;          Prop.SetValue(Obj,Value);&lt;br&gt;       end;&lt;br&gt;     end;&lt;br&gt;     for Field in objType.GetFields do&lt;br&gt;     begin&lt;br&gt;       IniValue := GetIniAttribute(Field);&lt;br&gt;       if Assigned(IniValue) then&lt;br&gt;       begin&lt;br&gt;          Data := Ini.ReadString(IniValue.Section,IniValue.Name,IniValue.DefaultValue);&lt;br&gt;          Value := Field.GetValue(Obj);&lt;br&gt;          SetValue(Data,Value);&lt;br&gt;          Field.SetValue(Obj,Value);&lt;br&gt;       end;&lt;br&gt;     end;&lt;br&gt;   finally&lt;br&gt;     Ini.Free;&lt;br&gt;   end;&lt;br&gt; finally&lt;br&gt;   ctx.Free;&lt;br&gt; end;&lt;br&gt;end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;So you can see we basically loop through all the properties and field check for an Attribute, if it exists we get the current value which sets the TypeInfo in the TValue object.    Then we assign the string returned from the INI file into the TValue and call SetValue() &lt;br&gt;&lt;br&gt;Lets look at the two methods called.&lt;br&gt;&lt;pre&gt;&lt;br&gt;  class procedure SetValue(aData : String;var aValue : TValue);&lt;br&gt;  class function GetIniAttribute(Obj : TRttiObject) : IniValueAttribute;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Lets look first at SetValue().   You will see that it depends on the TypeInfo being present in the TValue being passed in.  We check the TValue and perform the conversions required to convert the String to the Correct Type before storing it&lt;br&gt;into the TValue.&lt;br&gt;&lt;pre&gt;&lt;br&gt;class procedure TIniPersist.SetValue(aData: String;var aValue: TValue);&lt;br&gt;var&lt;br&gt; I : Integer;&lt;br&gt;begin&lt;br&gt; case aValue.Kind of&lt;br&gt;   tkWChar,&lt;br&gt;   tkLString,&lt;br&gt;   tkWString,&lt;br&gt;   tkString,&lt;br&gt;   tkChar,&lt;br&gt;   tkUString : aValue := aData;&lt;br&gt;   tkInteger,&lt;br&gt;   tkInt64  : aValue := StrToInt(aData);&lt;br&gt;   tkFloat  : aValue := StrToFloat(aData);&lt;br&gt;   tkEnumeration:  aValue := TValue.FromOrdinal(aValue.TypeInfo,GetEnumValue(aValue.TypeInfo,aData));&lt;br&gt;   tkSet: begin&lt;br&gt;             i :=  StringToSet(aValue.TypeInfo,aData);&lt;br&gt;             TValue.Make(@i, aValue.TypeInfo, aValue);&lt;br&gt;          end;&lt;br&gt;   else raise EIniPersist.Create('Type not Supported');&lt;br&gt; end;&lt;br&gt;end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;Now lets take a look at GetIniAttribute() the goal of this method is to check to see if a given TRttimember (Field or Property) has the IniValue attribute, and if it does return it, otherwise return NIL.&lt;br&gt;&lt;pre&gt;&lt;br&gt;class function TIniPersist.GetIniAttribute(Obj: TRttiObject): IniValueAttribute;&lt;br&gt;var&lt;br&gt; Attr: TCustomAttribute;&lt;br&gt;begin&lt;br&gt; for Attr in Obj.GetAttributes do&lt;br&gt; begin&lt;br&gt;    if Attr is IniValueAttribute then&lt;br&gt;    begin&lt;br&gt;      exit(IniValueAttribute(Attr));  // Exit with a parameter new in Delphi 2010&lt;br&gt;    end;&lt;br&gt; end;&lt;br&gt; result := nil;&lt;br&gt;end;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;So all in all, its really not much code, and it make usage simple.  Now granted TIniValue is not all that complex, but this situation could be applied to a variety of other applications.&lt;br&gt;&lt;br&gt;&lt;a href="http://robstechcorner.blogspot.com/2009/09/so-what-is-rtti-rtti-is-acronym-for-run.html"&gt;RTTI Article List&lt;/a&gt;&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/3339459875755088113-3829330674743610371?l=robstechcorner.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/Dtzk0rP6UHc" height="1" width="1"/&gt;</content><author><name>Robert Love</name></author><source gr:stream-id="feed/http://robstechcorner.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://robstechcorner.blogspot.com/feeds/posts/default</id><title type="html">Rob’s Technology Corner</title><link rel="alternate" href="http://robstechcorner.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://robstechcorner.blogspot.com/2009/10/ini-persistence-rtti-way.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1255008820962"><id gr:original-id="tag:blogger.com,1999:blog-3339459875755088113.post-5113980516733916921">tag:google.com,2005:reader/item/08c8f3774217246c</id><category term="Delphi" scheme="http://www.blogger.com/atom/ns#" /><category term="CodeRage" scheme="http://www.blogger.com/atom/ns#" /><category term="RTTI" scheme="http://www.blogger.com/atom/ns#" /><title type="html">RTTI - Practical Examples</title><published>2009-10-08T11:51:00Z</published><updated>2009-10-08T12:04:48Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/d_rbEHypILs/rtti-practical-examples.html" type="text/html" /><content xml:base="http://robstechcorner.blogspot.com/" type="html">Well it took a lot longer than I wanted to get this code out.&lt;br&gt;&lt;br&gt;There were many more rough edges than I wanted, but after some gentle and firm requests I realized I needed to get this out before the rough edges are finished.&lt;br&gt;&lt;br&gt;Specifically the &lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/xmlserial.pas"&gt;XmlSerial.pas&lt;/a&gt; has a road map in source code detailing what I still need to get done.&lt;br&gt;&lt;br&gt;What is released:&lt;br&gt;&lt;ul&gt;&lt;br&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/IniPersist.pas"&gt;IniPersist.pas&lt;/a&gt; Allows easy mapping of properties and fields to an INI File.&lt;/li&gt;&lt;br&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/xmlserial.pas"&gt;XmlSerial.pas&lt;/a&gt; Object and Record Serialization and De-serialization to XML&lt;/li&gt;&lt;br&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/ObjDS.pas"&gt;ObjDs.pas&lt;/a&gt;  Read-only mapping of Objects to TClientDataSets.&lt;br&gt;&lt;/li&gt;&lt;br&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/robstechcorner/source/browse/trunk/Delphi/rtti/RttiUtils.pas"&gt;RttiUtils.pas&lt;/a&gt;  Things to help with common RTTI needs.&lt;/li&gt;&lt;br&gt;&lt;/ul&gt;&lt;br&gt;&lt;br&gt;How to get the code:&lt;br&gt;  Follow the above links to each unit, or just use &lt;a href="http://code.google.com/p/robstechcorner/source/checkout"&gt;SVN&lt;/a&gt;. &lt;br&gt;&lt;br&gt;I am now working on some blog posts to show the how to use this code.&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/3339459875755088113-5113980516733916921?l=robstechcorner.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/d_rbEHypILs" height="1" width="1"/&gt;</content><author><name>Robert Love</name></author><source gr:stream-id="feed/http://robstechcorner.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://robstechcorner.blogspot.com/feeds/posts/default</id><title type="html">Rob’s Technology Corner</title><link rel="alternate" href="http://robstechcorner.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://robstechcorner.blogspot.com/2009/10/rtti-practical-examples.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1254301394162"><id gr:original-id="tag:blogger.com,1999:blog-6222893893652665733.post-573737848359417196">tag:google.com,2005:reader/item/d75a31de595db6d5</id><title type="html">In-Memory DataSets: ClientDataSet and .NET DataTable Compared: Part 1 Overview</title><published>2009-09-30T08:04:00Z</published><updated>2009-09-30T09:48:27Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/_LrPiQ_TDRM/in-memory-datasets-clientdataset-and.html" type="text/html" /><content xml:base="http://caryjensen.blogspot.com/" type="html">As some of you know, I have been a big fan of Delphi's ClientDataSets since they were first introduced in Delphi 3 (that's way back in 1997). When .NET shipped, its data access framework, ADO.NET, also included an in-memory dataset, named the DataTable. (.NET also includes the DataSet class, but in most cases, the DataTable class bears the strongest resemblance to the ClientDataSet.)&lt;br&gt;&lt;br&gt;Both ClientDataSets and DataTables are in-memory datasets, and as such, share a lot of features in common. On the other hand, they are radically different in a number of interesting ways. In this series of articles, which begins with this one, I will examine the general features of in-memory datasets, and provide a direct comparison between ClientDataSets and .NET DataTables.&lt;br&gt;&lt;br&gt;This article begins with a introduction to in-memory datasets in general. In future posts I will provide explicit code examples of how to perform various tasks with these two datasets, including how to create them in code, reading and writing data, sorting, filtering, persisting, navigating, and so on.&lt;br&gt;&lt;br&gt;I hope you enjoy.&lt;br&gt;&lt;br&gt;&lt;span style="font-size:130%"&gt;&lt;strong&gt;Developing with Disconnected Datasets&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;Disconnected datasets are database table-like structures that are stored in memory. These types of datasets are sometimes referred to as cached datasets or in-memory datasets. In this series they will be referred to as in-memory datasets.&lt;br&gt;&lt;br&gt;In-memory datasets are structured, high-performance, self-describing data structures temporarily stored in memory. A significant feature of in-memory datasets is that they maintain, and can persist, a change log. The change log permits you to programmatically determine what changes have been made to the data since some point in time, often when the data was originally loaded into the dataset. This information is essential if you need to persist these changes back to an original source, such as a Web service, underlying database, or other persistence mechanism.&lt;br&gt;&lt;br&gt;Data persistance in the .NET framework is based on in-memory datasets, and Delphi has included this capability since Delphi 3 in the form of the ClientDataSet.&lt;br&gt;&lt;br&gt;This series begins with an overview of the features that make in-memory datasets so useful, including their self-descriptive nature, ability to hold sophisticated relational data structures, their close association with XML, and their persistence and management of change information. How these features are surfaced in both ClientDataSets and .NET datasets is discussed in this section.&lt;br&gt;&lt;br&gt;In-memory datasets are the cornerstone of modern software development. Nothing confirms this statement as much as Microsoft's commitment to in-memory datasets as a central aspect of the database framework in .NET, ADO.NET.&lt;br&gt;&lt;br&gt;While most developers consider in-memory datasets for the presentation layer in applications, this use represents only a fraction of the possibilities for these powerful data structures. As this series will demonstrate, the characteristics of in-memory datasets make them a valuable tool for many different aspects of application development. The following are the essential feature of in-memory datasets:&lt;br&gt;&lt;br&gt;&lt;ul&gt;&lt;br&gt;&lt;li&gt;High performance&lt;/li&gt;&lt;br&gt;&lt;li&gt;Self describing&lt;/li&gt;&lt;br&gt;&lt;li&gt;Flexible&lt;/li&gt;&lt;br&gt;&lt;li&gt;Change log managing&lt;/li&gt;&lt;br&gt;&lt;li&gt;Persistable&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;Individually, these characteristics provide a compelling argument for using in-memory datasets in your applications. But it is the combination of these features in a single, easy to use class that makes them so valuable for a wide range of software features. The following sections look at each of these features in greater depth.&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="font-size:130%"&gt;High Performance&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;In-memory datasets reside entirely in RAM (random access memory). Consequently, operations on the data they contain, including searches, filters, and sorts, are very fast. This is particularly true with respect to ClientDataSets, since these can have indexes on this data as well. But even for .NET datasets, which currently support a single index at any given moment (the primary index), data-related operations are many times faster than those that require disk reads (as is the case with a physical database).&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="font-size:130%"&gt;Self Describing&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;In-memory datasets are formally designed around the concept of a database table. Unlike an array or sequence, whose data elements have a data type, and that's about it, the fields of a data table each have a name, a data type, and sometimes a data size (for example, the size of a text field or precision of a floating point number).&lt;br&gt;&lt;br&gt;In addition, the fields of a data table may have constraints, such as a required field constraint, or referential integrity constraints when two or more in-memory tables are related. This information is typically referred to as metadata, which is data about data.&lt;br&gt;&lt;br&gt;In ClientDataSets, you access the metadata of a dataset using the Fields property of the dataset, which contains a collection of TField instances. In .NET data tables, you access this information using the Columns property, which contains a collection of DataColumn instances.&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="font-size:130%"&gt;Flexible&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;In-memory datasets are designed to hold nearly any kind of data that might be stored in a physical database. This includes primitive data values, such as integers, strings, real numbers, and date/time values. But it also includes variable length objects, such as memos and Blobs (binary large objects). As a result, an in-memory dataset can hold the pages of a Web site, PDF files, and even executables (.EXEs and .DLLs). If it can be stored in a file on disk, it can be stored in an in-memory dataset (obviously, subject to the limits imposed by your available RAM).&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="font-size:130%"&gt;Change Log Managing&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Both ClientDataSets and .NET DataTables have a change log. The change log permits you to manage the unresolved changes that have been posted to the dataset's data since you loaded it into memory. This management includes the ability to determined precisely what changes have occurred (which records were inserted, deleted, and field-level modifications), revert changes to their prior state, cancel all changes, or commit those changes permanently, thereby erasing the change log. With ClientDataSets, this change log if held in the Delta property. For .NET DataTables, you use the RowStateFilter of a DataView to access the change log.&lt;br&gt;&lt;br&gt;To manage the change log for a ClientDataSet, you use its methods, such as RevertRecord, UndoLastChange, CancelChanges, and ApplyUpdates. In addition, you can use the RecordStatus, StatusFilter, and Fields properties to examine the change log contents.&lt;br&gt;&lt;br&gt;With .NET DataTables, you use the methods of the DataTable and DataView classes to control the change log, including NewRow, DeleteRow, AcceptChanges, and RejectChanges. To examine the change log, you use the RowStateFilter and Rows properties.&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="font-size:130%"&gt;Persistable&lt;br&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;Of all the features supported by in-memory datasets, the ability to persist state is arguably the most powerful. Not only can you save an in-memory dataset's data, but you can save its change log as well. Specifically, it is possible to save the current state of an in-memory dataset to a file, Web service, or memo field of a database, and then to restore that dataset at a later time to its exact prior state. In short, there is absolutely no difference between the in-memory dataset prior to, and following, its persistence.&lt;br&gt;&lt;br&gt;Consider the following scenario: After loading data into memory, and making several edits to an in-memory dataset, that dataset can be written to a file. At a future time, that dataset can be restored from the file, and the edits that were previously performed can be examined and rejected or accepted.&lt;br&gt;&lt;br&gt;Furthermore, since the change log is restored to its exact prior state, that information can be used to resolve those edits to the underlying database from which the data was originally loaded. No information is lost during the time that the dataset is in storage, no matter how long its state was persisted.&lt;br&gt;&lt;br&gt;Copyright (c) 2009 Cary Jensen. All Rights Reserved&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/6222893893652665733-573737848359417196?l=caryjensen.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/_LrPiQ_TDRM" height="1" width="1"/&gt;</content><author><name>Cary Jensen</name></author><source gr:stream-id="feed/http://caryjensen.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://caryjensen.blogspot.com/feeds/posts/default</id><title type="html">Cary Jensen  &amp;quot;Let&amp;#39;s Get Technical&amp;quot;</title><link rel="alternate" href="http://caryjensen.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://caryjensen.blogspot.com/2009/09/in-memory-datasets-clientdataset-and.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1254261452247"><id gr:original-id="tag:blogger.com,1999:blog-29331675.post-4334483656343415506">tag:google.com,2005:reader/item/ee684cab50502b1e</id><category term="unlabeled" scheme="http://www.blogger.com/atom/ns#" /><title type="html">Unhibernating – with a T-shirt</title><published>2009-09-29T18:35:00Z</published><updated>2009-09-29T18:39:59Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/M3VZpvG8DVE/unhibernating-with-t-shirt.html" type="text/html" /><content xml:base="http://17slon.com/blogs/gabr/blogger.html" type="html">&lt;p&gt;Dear reader,&lt;/p&gt;  &lt;p&gt;I’m fully aware that I was silent for a long long time.&lt;/p&gt;  &lt;p&gt;That’s how life goes. Sometimes you have time to think and write and sometimes software has bugs, children are growing, house is telling you that it shouldn’t be in the “fixer-upper” mode anymore and the body starts warning that the guaranty has expired. Plus the days suddenly have only 24 hours and not 28 as it was customary for the last ten years.&lt;/p&gt;  &lt;p&gt;In short – I had no time. Life was going on. And around. And over me. Especially over me.&lt;/p&gt;  &lt;p&gt;Luckily, everything is turning out fine and I will again write about my Delphi adventures.&lt;/p&gt;  &lt;p&gt;Today I visited the RAD Studio 2010 presentation organized by Embarcadero and Slovenian Delphi dealer, &lt;a href="http://www.marand.si"&gt;Marand&lt;/a&gt;. Mark Barrington and Pawel Glowacki were showing RAD Studio 2010, Embarcadero’s database tools and All-Access. Sadly, I only had time to attend the Delphi session which was very good and informative. (Thumbs up, Pawel!)&lt;/p&gt;  &lt;p&gt;There were also T-shirts and I was lucky to get one.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://17slon.com/blogs/gabr/files/UnhibernatingwithaTshirt_12076/P1090662.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px" title="P1090662" border="0" alt="P1090662" src="http://17slon.com/blogs/gabr/files/UnhibernatingwithaTshirt_12076/P1090662_thumb.jpg" width="454" height="364"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Nice T-shirt but it’s even better if you look closer at the code.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://17slon.com/blogs/gabr/files/UnhibernatingwithaTshirt_12076/P1090665.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px" title="P1090665" border="0" alt="P1090665" src="http://17slon.com/blogs/gabr/files/UnhibernatingwithaTshirt_12076/P1090665_thumb.jpg" width="274" height="364"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Parallel Erathostenes sieve! That’s definitely the code I can appreciate!&lt;/p&gt;  &lt;p&gt;[For the OTL fans – OTL is alive and well and I will publish next version sometime in October. And then I’ll write the documentation. Promise.]&lt;/p&gt;  &lt;div&gt;&lt;font size="-2"&gt;---&lt;br&gt;Published under the &lt;a href="http://creativecommons.org/licenses/by/3.0/"&gt;Creative Commons Attribution 3.0&lt;/a&gt; license&lt;/font&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/29331675-4334483656343415506?l=17slon.com%2Fblogs%2Fgabr%2Fblogger.html"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/M3VZpvG8DVE" height="1" width="1"/&gt;</content><author><name>gabr</name></author><source gr:stream-id="feed/http://17slon.com/blogs/gabr/atom.xml"><id>tag:google.com,2005:reader/feed/http://17slon.com/blogs/gabr/atom.xml</id><title type="html">The Delphi Geek</title><link rel="alternate" href="http://17slon.com/blogs/gabr/blogger.html" type="text/html" /></source><feedburner:origLink>http://17slon.com/blogs/gabr/2009/09/unhibernating-with-t-shirt.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1252877083206"><id gr:original-id="http://alex.ciobanu.org/?p=258">tag:google.com,2005:reader/item/5e7540cf3d4aa9e3</id><category term="Programming" /><category term="delphi" /><category term="EMBT" /><category term="Help" /><category term="LinkedIn" /><category term="RTL" /><title type="html">Class constructors and Generics</title><published>2009-09-13T10:39:32Z</published><updated>2009-09-13T10:39:32Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/HkvxKIWgNZI/" type="text/html" /><content xml:base="http://alex.ciobanu.org/" type="html">&lt;p&gt;The new great addition to the Delphi language in &lt;strong&gt;Delphi 2010&lt;/strong&gt; is the possibility to specify a &lt;a href="http://docwiki.embarcadero.com/RADStudio/en/Methods#Class_Constructors"&gt;class constructor&lt;/a&gt; and a &lt;a href="http://docwiki.embarcadero.com/RADStudio/en/Methods#Class_Destructors"&gt;class destructor&lt;/a&gt; to your class/record. I will not describe this feature in this post since you can see the online documentation for it on the&lt;em&gt; Embarcadero Doc Wiki&lt;/em&gt;. The part I am interested in is the combination of class constructors and generics. As you might already know generic types aren’t really “run-time entities” but rather “compile-time” ones. This makes the initialization of “static” members of the type a bit more complicated. See for example this record:&lt;/p&gt;
&lt;pre&gt;
type
  TMyType&amp;lt;T&amp;gt; = record
  private class var
    FSomeList: TList&amp;lt;T&amp;gt;;

  public
    ...
    ...
  end;
&lt;/pre&gt;
&lt;p&gt;In this case the static &lt;strong&gt;FSomeList&lt;/strong&gt; variable needs to be initialized to make sense. Normally, in non-generic classes, you would use the “&lt;em&gt;initialization&lt;/em&gt;” and “&lt;em&gt;finalization&lt;/em&gt;” sections to create and then destroy that variable. In generic classes this is impossible though. You have to get some workarounds (like initializing the list lazily), but you still cannot destroy the list on finalization.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Well, not anymore!&lt;/strong&gt; Using class constructors and destructors allows you to easily initialize any static member of a type:&lt;/p&gt;
&lt;pre&gt;
type
  TMyType&amp;lt;T&amp;gt; = record
  private class var
    FSomeList: TList&amp;lt;T&amp;gt;;

    class constructor Create;
    class destructor Destroy;
  public
    ...
    ...
  end;

class constructor TMyType&amp;lt;T&amp;gt;.Create;
begin
  // Executed on application initialization.
  FSomeList := TList&amp;lt;T&amp;gt;.Create();
end;

class destructor TMyType&amp;lt;T&amp;gt;.Destroy;
begin
  // Freed on application termination.
  FSomeList.Free;
end;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;There is a catch tough.&lt;/strong&gt; Since generic types are compile-time entities, any unit that uses a specialized generic type basically defines that type in itself. For example if you use &lt;em&gt;TList&amp;lt;String&amp;gt;&lt;/em&gt; in four of your units, all four units will internally declare the &lt;em&gt;TList&amp;lt;String&amp;gt;&lt;/em&gt; class. This results in the &lt;em&gt;TList&amp;lt;T&amp;gt;&lt;/em&gt;’s class constructor to be executed four times – once per unit. This is expected behavior since each type specialization has different static members. For example:&lt;/p&gt;
&lt;pre&gt;
type
  TDistinctType&amp;lt;T&amp;gt; = record
  private class var
    FMarker: Integer;

    class constructor Create;
  end;
&lt;/pre&gt;
&lt;p&gt;If &lt;em&gt;TDistinctType&amp;lt;String&amp;gt;&lt;/em&gt; is used in multiple units, each unit’s version has it own FMarker, which means it needs to be initialized for each unit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The conclusion — be aware that class constructors and destructors for generic types may execute multiple times.&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/HkvxKIWgNZI" height="1" width="1"/&gt;</content><author><name>alex</name></author><source gr:stream-id="feed/http://alex.ciobanu.org/?feed=rss2"><id>tag:google.com,2005:reader/feed/http://alex.ciobanu.org/?feed=rss2</id><title type="html">YAPB</title><link rel="alternate" href="http://alex.ciobanu.org" type="text/html" /></source><feedburner:origLink>http://alex.ciobanu.org/?p=258</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1252770379500"><id gr:original-id="http://edn.embarcadero.com/article/39936">tag:google.com,2005:reader/item/643d661552f6bd2d</id><title type="html">What's New In RAD Studio 2010 With Mike Rozlog</title><published>2009-09-11T23:46:27Z</published><updated>2009-09-11T23:46:27Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/u_iO-jZiRu0/39936" type="text/html" /><author gr:unknown-author="true"><name>(author unknown)</name></author><source gr:stream-id="feed/http://edn.embarcadero.com/delphi/rss"><id>tag:google.com,2005:reader/feed/http://edn.embarcadero.com/delphi/rss</id><title type="html">EDN Delphi Feed</title><link rel="alternate" href="http://edn.embarcadero.com/delphi" type="text/html" /></source><summary type="html">&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/u_iO-jZiRu0" height="1" width="1"/&gt;</summary><feedburner:origLink>http://edn.embarcadero.com/article/39936</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1252569606750"><id gr:original-id="">tag:google.com,2005:reader/item/a17ae85df344ba17</id><title type="html">Aspect Oriented Programming with Delphi Prism</title><published>2009-09-10T08:00:06Z</published><updated>2009-09-10T08:00:06Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/MC2VWlnYtsY/39306" type="text/html" /><summary xml:base="http://blogs.embarcadero.com/nickhodges" type="html">I’ve created a short, eleven minute video showing the basics of Aspect Oriented Programming with Delphi Prism.  AOP is a really cool, powerful, and easy to use language feature of Delphi Prism.   You can read more about AOP  and how it works on Wikipedia.  You can read more ...&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/MC2VWlnYtsY" height="1" width="1"/&gt;</summary><author gr:unknown-author="true"><name>(author unknown)</name></author><source gr:stream-id="feed/http://blogs.codegear.com/nickhodges/rss"><id>tag:google.com,2005:reader/feed/http://blogs.codegear.com/nickhodges/rss</id><title type="html">Nick Hodges</title><link rel="alternate" href="http://blogs.embarcadero.com/nickhodges" type="text/html" /></source><feedburner:origLink>http://blogs.embarcadero.com/nickhodges/2009/09/09/39306</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1252569606578"><id gr:original-id="">tag:google.com,2005:reader/item/325b084809599e9c</id><title type="html">A visit with Delphi 1 (redux)</title><published>2009-09-10T08:00:06Z</published><updated>2009-09-10T08:00:06Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/A4TP80-ktS0/24826" type="text/html" /><summary xml:base="http://blogs.embarcadero.com/medington" type="html">When last we met[1], I was reminiscing about my reunion with the very first release of Delphi.  I still get a thrill running "delphi.exe" and watching it just instantly appear.

Of course time marches on, and today I'm sad to report that my old pal no longer runs on my current ...&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/A4TP80-ktS0" height="1" width="1"/&gt;</summary><author gr:unknown-author="true"><name>(author unknown)</name></author><source gr:stream-id="feed/http://blogs.codegear.com/medington/rss"><id>tag:google.com,2005:reader/feed/http://blogs.codegear.com/medington/rss</id><title type="html">Mark Edington&amp;#39;s Delphi Blog</title><link rel="alternate" href="http://blogs.embarcadero.com/medington" type="text/html" /></source><feedburner:origLink>http://blogs.embarcadero.com/medington/2009/09/09/24826</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1252015879008"><id gr:original-id="http://www.danieleteti.it/?p=146">tag:google.com,2005:reader/item/5abfcfcf3c0d4119</id><category term="Delphi 2010" /><category term="Programming" /><category term="RTTI" /><category term="Uncategorized" /><category term="ITDevCon" /><category term="JSON" /><category term="Marshalling" /><category term="UnMarshalling" /><title type="html">Custom Marshalling/UnMarshalling in Delphi 2010</title><published>2009-09-01T20:43:26Z</published><updated>2009-09-01T20:43:26Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/uMDO_DfJhoY/" type="text/html" /><content xml:base="http://www.danieleteti.it/" type="html">&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Some days ago, Embarcadero has presented the new version of RAD Studio, 2010.&lt;br&gt;
The are many new features, but you can find in a lot places around the web, so&lt;br&gt;
I won’t repeat them here.&lt;/p&gt;
&lt;p&gt;One of the things widely requested from all Delphi programmers all over the world over the past few years, including myself, is&lt;br&gt;
certainly a new and more powerful RTTI.&lt;/p&gt;
&lt;p&gt;The new system of RTTI has finally arrived, and pave the way for a large number of applications.&lt;br&gt;
One area that has benefited from the new RTTI is for sure the marshaled objects.&lt;/p&gt;
&lt;p&gt;Marshaling is defined as follows:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;“In computer science, marshalling (similar to serialization) is the process of&lt;br&gt;
transforming the memory representation of an object to a data format suitable for&lt;br&gt;
storage or transmission. It is typically used when data must be moved between&lt;br&gt;
different parts of a computer program or from one program to another.&lt;br&gt;
The opposite, or reverse, of marshalling is called unmarshalling (demarshalling) (similar to deserialization).”&lt;br&gt;
–WikiPedia&lt;br&gt;
&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In Delphi 2010 the process of serialization and deserialization is handled respectively by a Marshaller and an Unmarshaller.&lt;/p&gt;
&lt;p&gt;The built-in format for the serialization of any Delphi object is &lt;a href="http://www.json.org"&gt;JSON&lt;/a&gt;.&lt;br&gt;
There are 2 main classes responsible for serializing objects into JSON, both present in the unit DBXJSONReflect:&lt;br&gt;
- TJSONMarshal&lt;br&gt;
- TJSONUnMarshal&lt;/p&gt;
&lt;p&gt;Let’s say you have an object defined as follow:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;type&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  TKid &lt;span&gt;=&lt;/span&gt; &lt;span&gt;class&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    FirstName&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    LastName&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Age&lt;span&gt;:&lt;/span&gt; &lt;span&gt;Integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;To serialize and deserialize an instance of TKid it requires the following steps:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;var&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  Mar&lt;span&gt;:&lt;/span&gt; TJSONMarshal&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//Serializer&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  UnMar&lt;span&gt;:&lt;/span&gt; TJSONUnMarshal&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//UnSerializer&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Kid&lt;span&gt;:&lt;/span&gt; TKid&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//The Object to serialize&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  SerializedKid&lt;span&gt;:&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//Serialized for of object&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Mar &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TJSONConverter&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Kid &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TKid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;FirstName&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;&amp;#39;Daniele&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;LastName&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;&amp;#39;Teti&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;      &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Age&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;29&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;      &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      SerializedKid &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; Mar&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Marshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Kid&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;FreeAndNil&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Kid&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Mar&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Output the JSON version of the Kid object&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;WriteLn&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;SerializedKid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ToString&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;   &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;// UnMarshalling Kid&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  UnMar &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONUnMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Kid &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; UnMar&lt;span&gt;.&lt;/span&gt;&lt;span&gt;UnMarshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;SerializedKid&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TKid&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;//now kid is the same as before marshalling&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;FirstName&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;&amp;#39;Daniele&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;LastName&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;&amp;#39;Teti&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Age&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;29&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Kid&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    UnMar&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Simple, isn’t it?&lt;br&gt;
To access the JSON string that is our object, we must call the method ToString.&lt;br&gt;
The JSON representation of this object SerializedKid can be saved to file,&lt;br&gt;
sent to a remote server, used by a Web page from a web service, stored on a database or sent into space (!!!).&lt;br&gt;
The Delphi application re-read the JSON string, you can recreate the object as it was at the time of serialization.&lt;br&gt;
But anyone with a JSON parser can still read the data in our object, even non Delphi client.&lt;br&gt;
These are the advantages of having used an open format and standard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So far the simple part …&lt;/strong&gt;&lt;br&gt;
How serialize a field differently from the default?&lt;/p&gt;
&lt;p&gt;Suppose we add the date of birth to our TKid:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;type&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  TKid &lt;span&gt;=&lt;/span&gt; &lt;span&gt;class&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    FirstName&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    LastName&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Age&lt;span&gt;:&lt;/span&gt; &lt;span&gt;Integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    BornDate&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Serialize a TDateTime, localized and that I have in JSON string is a float, because for Delphi TDateTime is a decimal number.&lt;br&gt;
If I read the data from another program Delphi, no problem, but if I wanted to read a script in JavaScript? or. NET? or Ruby?&lt;br&gt;
Then I use a format “DATA” to understand, even for these languages.&lt;br&gt;
The new engine provides the serialization too.&lt;br&gt;
Is needed, however, to tell the Marshaller and UnMarsheller how to represent and reconstruct a particular&lt;br&gt;
object field by two statements like the following:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;//marshaller&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TKid&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt; &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt; &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;AsType&lt;/span&gt;&amp;amp;lt&lt;span&gt;;&lt;/span&gt;TDateTime&amp;amp;gt&lt;span&gt;;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Result &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;FormatDateTime&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;yyyy-mm-dd hh:nn:ss&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;date&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;//UnMarshaller&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TKid&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;procedure&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Arg&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    datetime&lt;span&gt;:&lt;/span&gt;&lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    datetime &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; EncodeDateTime&lt;span&gt;(&lt;/span&gt;&lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                               &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                               &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;9&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                               &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;12&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                               &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;15&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                               &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;18&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;SetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;,&lt;/span&gt; datetime&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;The anonymous method is called when the marshaller serializes the field ‘BornDate’ is called “Converter” while Unmarshaller anonymous method that calls when he has to reconstruct the object from the JSON string is the “Reverter”.&lt;br&gt;
Thus serializing a TKid assure you that my object is readable both by Delphi from another language without loss of information.&lt;/p&gt;
&lt;p&gt;But what happens when I have to serialize a complex type?&lt;/p&gt;
&lt;p&gt;Suppose we extend TKid this:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;type&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  TTeenager &lt;span&gt;=&lt;/span&gt; &lt;span&gt;class&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TKid&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Phones&lt;span&gt;:&lt;/span&gt; TStringList&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;constructor&lt;/span&gt; Create&lt;span&gt;;&lt;/span&gt; &lt;span&gt;virtual&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;destructor&lt;/span&gt; Destroy&lt;span&gt;;&lt;/span&gt; &lt;span&gt;virtual&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;We must define a Converter and a Reverter for the TStringList class.&lt;br&gt;
We can do it this way:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;var&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  Marshaller&lt;span&gt;:&lt;/span&gt; TJSONMarshal&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  UnMarshaller&lt;span&gt;:&lt;/span&gt; TJSONUnMarshal&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Teenager&lt;span&gt;:&lt;/span&gt; TTeenager&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Value&lt;span&gt;,&lt;/span&gt; JSONTeenager&lt;span&gt;:&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Marshaller &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TJSONConverter&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TTeenager&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt; &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt; &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;AsType&lt;/span&gt;&amp;amp;lt&lt;span&gt;;&lt;/span&gt;TDateTime&amp;amp;gt&lt;span&gt;;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        Result &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;FormatDateTime&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;yyyy-mm-dd hh:nn:ss&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;date&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TStringList&lt;span&gt;,&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                              &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                i&lt;span&gt;,&lt;/span&gt; count&lt;span&gt;:&lt;/span&gt; &lt;span&gt;integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                              &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                count &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                &lt;span&gt;SetLength&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Result&lt;span&gt;,&lt;/span&gt; count&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                &lt;span&gt;for&lt;/span&gt; i &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt; &lt;span&gt;to&lt;/span&gt; count &lt;span&gt;-&lt;/span&gt; &lt;span&gt;1&lt;/span&gt; &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                  Result&lt;span&gt;[&lt;/span&gt;i&lt;span&gt;]&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;i&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                              &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//TStringList Converter &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Teenager &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TTeenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;CreateAndInitialize&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Value &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Marshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Teenager&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;// UnMarshalling Teenager&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  UnMarshaller &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONUnMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TTeenager&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;procedure&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Arg&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        datetime&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        datetime &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; EncodeDateTime&lt;span&gt;(&lt;/span&gt;&lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                   &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                   &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;9&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                   &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;12&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                   &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;15&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                   &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;18&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;SetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;,&lt;/span&gt; datetime&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TStringList&lt;span&gt;,&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                               &lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                 StrList&lt;span&gt;:&lt;/span&gt; TStringList&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                 &lt;span&gt;Str&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                               &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                 StrList &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                 &lt;span&gt;for&lt;/span&gt; &lt;span&gt;Str&lt;/span&gt; &lt;span&gt;in&lt;/span&gt; Data &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                   StrList&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Add&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Str&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                                 Result &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; StrList&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;                                               &lt;span&gt;end&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;  &lt;span&gt;//TStringList Reverter&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Teenager &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Unmarshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Value&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TTeenager&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;Daniele&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;FirstName&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;Teti&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;LastName&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;29&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Age&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;EncodeDate&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1979&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;11&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;BornDate&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;3&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER01&amp;#39;&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER02&amp;#39;&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER03&amp;#39;&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Teenager&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;There are different types of Converter and Reverter.&lt;br&gt;
In the the DBXJSONReflect there are 8 types of converters: &lt;/p&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a field in an object array&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TObjectsConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfObjects&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a field in a strings array&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TStringsConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a type in an objects array&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TTypeObjectsConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfObjects&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a type in a strings array  &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TTypeStringsConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a field in an object&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TObjectConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert a field in a string  &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TStringConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert specified type in an object&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TTypeObjectConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;//Convert specified type in a string  &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TTypeStringConverter &lt;span&gt;=&lt;/span&gt; reference &lt;span&gt;to&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Each of them deals with a particular conversion object representation in the final serialization, in our case we will use them to convert to JSON.&lt;/p&gt;
&lt;p&gt;Also in the DBXJSONReflect unit are defined  many “Reverter” dealing with retrieving&lt;br&gt;
the serialized version of the data and use it to reconstruct the object previously serialized.&lt;br&gt;
Because they are complementary to the Converter, I will not copy them here.&lt;/p&gt;
&lt;p&gt;As a final example, we derive from TProgrammer by TTeenager adding a list of Laptops in the properties.&lt;/p&gt;
&lt;p&gt;Is therefore necessary to introduce a new pair of Converter / Reverter.&lt;br&gt;
In this example I have defined all the converter and reverter in another unit in&lt;br&gt;
order to have more readable code:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;type&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;  TLaptop &lt;span&gt;=&lt;/span&gt; &lt;span&gt;class&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Model&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Price&lt;span&gt;:&lt;/span&gt; &lt;span&gt;Currency&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;constructor&lt;/span&gt; Create&lt;span&gt;(&lt;/span&gt;AModel&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; APrice&lt;span&gt;:&lt;/span&gt; &lt;span&gt;Currency&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TLaptops &lt;span&gt;=&lt;/span&gt; TObjectList&amp;amp;lt&lt;span&gt;;&lt;/span&gt;TLaptop&amp;amp;gt&lt;span&gt;;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  TProgrammer &lt;span&gt;=&lt;/span&gt; &lt;span&gt;class&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TTeenager&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Laptops&lt;span&gt;:&lt;/span&gt; TLaptops&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;constructor&lt;/span&gt; Create&lt;span&gt;;&lt;/span&gt; &lt;span&gt;override&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;destructor&lt;/span&gt; Destroy&lt;span&gt;;&lt;/span&gt; &lt;span&gt;override&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;class&lt;/span&gt; &lt;span&gt;function&lt;/span&gt; CreateAndInitialize&lt;span&gt;:&lt;/span&gt; TProgrammer&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;// Implementation code…&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Marshaller&lt;span&gt;:&lt;/span&gt; TJSONMarshal&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  UnMarshaller&lt;span&gt;:&lt;/span&gt; TJSONUnMarshal&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Programmer&lt;span&gt;:&lt;/span&gt; TProgrammer&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Value&lt;span&gt;,&lt;/span&gt; JSONProgrammer&lt;span&gt;:&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Marshaller &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TJSONConverter&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TProgrammer&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; ISODateTimeConverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TStringList&lt;span&gt;,&lt;/span&gt; StringListConverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterConverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TProgrammer&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;Laptops&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; LaptopListConverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Programmer &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TProgrammer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;CreateAndInitialize&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Value &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Marshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Programmer&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TJSONObject&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;// UnMarshalling Programmer&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    UnMarshaller &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TJSONUnMarshal&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TProgrammer&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;BornDate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; ISODateTimeReverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TStringList&lt;span&gt;,&lt;/span&gt; StringListReverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;RegisterReverter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TProgrammer&lt;span&gt;,&lt;/span&gt; &lt;span&gt;&amp;#39;Laptops&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; LaptopListReverter&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Programmer &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Unmarshal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Value&lt;span&gt;)&lt;/span&gt; &lt;span&gt;as&lt;/span&gt; TProgrammer&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;Daniele&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;FirstName&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;Teti&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;LastName&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;29&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Age&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;EncodeDate&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1979&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;11&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;BornDate&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;3&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER01&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER02&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;NUMBER03&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Phones&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;HP Presario C700&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Model&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1000&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Price&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;Toshiba Satellite Pro&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Model&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;800&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Price&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;IBM Travelmate 500&amp;#39;&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Model&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        &lt;span&gt;Assert&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1300&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Price&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;        Programmer&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      UnMarshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Marshaller&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Free&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Unit CustomConverter.pas contains all needed Converters/Reverts as anon methods.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;unit CustomConverter;&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;interface&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;uses&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  DBXJSONReflect&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  MyObjects&lt;span&gt;;&lt;/span&gt; &lt;span&gt;//Needed by converter and reverter for TLaptops&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  ISODateTimeConverter&lt;span&gt;:&lt;/span&gt; TStringConverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  ISODateTimeReverter&lt;span&gt;:&lt;/span&gt; TStringReverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  StringListConverter&lt;span&gt;:&lt;/span&gt; TTypeStringsConverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  StringListReverter&lt;span&gt;:&lt;/span&gt; TTypeStringsReverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  LaptopListConverter&lt;span&gt;:&lt;/span&gt; TObjectsConverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  LaptopListReverter&lt;span&gt;:&lt;/span&gt; TObjectsReverter&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;implementation&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;uses&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  SysUtils&lt;span&gt;,&lt;/span&gt; RTTI&lt;span&gt;,&lt;/span&gt; DateUtils&lt;span&gt;,&lt;/span&gt; Classes&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;initialization&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LaptopListConverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfObjects&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptops&lt;span&gt;:&lt;/span&gt; TLaptops&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  i&lt;span&gt;:&lt;/span&gt; &lt;span&gt;integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptops &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TProgrammer&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;SetLength&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Result&lt;span&gt;,&lt;/span&gt; Laptops&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;if&lt;/span&gt; Laptops&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Count&lt;/span&gt; &amp;amp;gt&lt;span&gt;;&lt;/span&gt; &lt;span&gt;0&lt;/span&gt; &lt;span&gt;then&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    &lt;span&gt;for&lt;/span&gt; I &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt; &lt;span&gt;to&lt;/span&gt; Laptops&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Count&lt;/span&gt; &lt;span&gt;-&lt;/span&gt; &lt;span&gt;1&lt;/span&gt; &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      Result&lt;span&gt;[&lt;/span&gt;I&lt;span&gt;]&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; Laptops&lt;span&gt;[&lt;/span&gt;i&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LaptopListReverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;procedure&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;String&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Args&lt;span&gt;:&lt;/span&gt; TListOfObjects&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  obj&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptops&lt;span&gt;:&lt;/span&gt; TLaptops&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptop&lt;span&gt;:&lt;/span&gt; TLaptop&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  i&lt;span&gt;:&lt;/span&gt; &lt;span&gt;integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptops &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TProgrammer&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Laptops&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Laptops&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Clear&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;for&lt;/span&gt; obj &lt;span&gt;in&lt;/span&gt; Args &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    laptop &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; obj &lt;span&gt;as&lt;/span&gt; TLaptop&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Laptops&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Add&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;TLaptop&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;laptop&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Model&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; laptop&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Price&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;StringListConverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  i&lt;span&gt;,&lt;/span&gt; count&lt;span&gt;:&lt;/span&gt; &lt;span&gt;integer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  count &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;SetLength&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Result&lt;span&gt;,&lt;/span&gt; count&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;for&lt;/span&gt; i &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt; &lt;span&gt;to&lt;/span&gt; count &lt;span&gt;-&lt;/span&gt; &lt;span&gt;1&lt;/span&gt; &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    Result&lt;span&gt;[&lt;/span&gt;i&lt;span&gt;]&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;i&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;StringListReverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; TListOfStrings&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  StrList&lt;span&gt;:&lt;/span&gt; TStringList&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;Str&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  StrList &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; TStringList&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Create&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;for&lt;/span&gt; &lt;span&gt;Str&lt;/span&gt; &lt;span&gt;in&lt;/span&gt; Data &lt;span&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;    StrList&lt;span&gt;.&lt;/span&gt;&lt;span&gt;Add&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Str&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Result &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; StrList&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ISODateTimeConverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt; &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt; &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;date&lt;/span&gt; &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;AsType&lt;/span&gt;&amp;amp;lt&lt;span&gt;;&lt;/span&gt;TDateTime&amp;amp;gt&lt;span&gt;;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  Result &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;FormatDateTime&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;yyyy-mm-dd hh:nn:ss&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;date&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ISODateTimeReverter &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;procedure&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;:&lt;/span&gt; &lt;span&gt;TObject&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Field&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt; Arg&lt;span&gt;:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  ctx&lt;span&gt;:&lt;/span&gt; TRttiContext&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  datetime &lt;span&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  &lt;span&gt;TDateTime&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  datetime &lt;span&gt;:&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; EncodeDateTime&lt;span&gt;(&lt;/span&gt;&lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;9&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;StrToInt&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;      &lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;12&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;15&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;StrToInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Arg&lt;span&gt;,&lt;/span&gt; &lt;span&gt;18&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;  ctx&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetType&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ClassType&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;GetField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Field&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;SetValue&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;Data&lt;span&gt;,&lt;/span&gt; datetime&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;end&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Last hint…&lt;/strong&gt;&lt;br&gt;
Every serialization/unserialization process can create “warnings”.&lt;br&gt;
Those warnings are collected into the “Warnings” property of the Ser/UnSer Object. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conclusions&lt;/strong&gt;&lt;br&gt;
In this post I tried to introduce the basics of the new serialization engine in Delphi 2010.&lt;br&gt;
During the next &lt;a href="http://www.itdevcon.it"&gt;ITDevCon&lt;/a&gt; to be held in Italy next November 11.12,  I’ll have a talk in which I will extensively talk about serialization and RTTI.&lt;br&gt;
All interested smart developers are invited &lt;img src="http://www.danieleteti.it/wp-includes/images/smilies/icon_smile.gif" alt=":-)"&gt; &lt;/p&gt;
&lt;p&gt;ITALIAN P.S.&lt;br&gt;
Se qualche programmatore italiano volesse avere la versione in italiano di questo post può lasciare un commento e vedrò di accontentarlo &lt;img src="http://www.danieleteti.it/wp-includes/images/smilies/icon_smile.gif" alt=":-)"&gt; &lt;/p&gt;
&lt;p&gt;You can find the DUnit project &lt;a href="http://www.danieleteti.it/wp-content/uploads/2009/09/marshall_unmarshall_in_d2010.zip"&gt;Source Code&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/uMDO_DfJhoY" height="1" width="1"/&gt;</content><author><name>Daniele Teti</name></author><gr:likingUser>09977811200591639273</gr:likingUser><source gr:stream-id="feed/http://www.danieleteti.it/?feed=rss2"><id>tag:google.com,2005:reader/feed/http://www.danieleteti.it/?feed=rss2</id><title type="html">while true do;</title><link rel="alternate" href="http://www.danieleteti.it" type="text/html" /></source><feedburner:origLink>http://www.danieleteti.it/?p=146</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1251977180619"><id gr:original-id="tag:blogger.com,1999:blog-6222893893652665733.post-6215869260230624289">tag:google.com,2005:reader/item/73e9c0ba0bf3ff8d</id><title type="html">Introduction to Language Integrated Query with Delphi Prism, Part 2</title><published>2009-07-30T21:45:00Z</published><updated>2009-09-21T18:53:24Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/6sP-ubR5n90/introduction-to-language-integrated.html" type="text/html" /><content xml:base="http://caryjensen.blogspot.com/" type="html">&lt;p&gt;In part 1 of this 2 part series I provided you with a basic introduction to Language Integrated Query, or LINQ. In this second part I take a look at several specific implementations of LINQ, including LINQ to Objects, LINQ to DataSets, and LINQ to XML. I also have an opportunity to introduce iterator methods, special methods that you implement to return a sequence for use by LINQ queries.&lt;/p&gt;&lt;h2&gt;LINQ to Objects&lt;/h2&gt;&lt;p&gt;LINQ to Objects is any version of LINQ that does not employ a LINQ provider. Consequently, all LINQ queries shown in part 1 of this series are examples of LINQ to Objects.&lt;/p&gt;&lt;p&gt;Here is another example.&lt;/p&gt;&lt;pre&gt;var Customers := GetCustomers;&lt;br&gt;var query := from c in Customers&lt;br&gt;  where (c.Age &amp;gt; 10)&lt;br&gt;  and (c.Age &amp;lt; 40)&lt;br&gt;  and (c.Active = true&amp;lt;) select c;&lt;br&gt;for each m in query do&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;    String.Format("Name: {0}, Age={1}",&lt;br&gt;                  [m.Name, m.Age]));&lt;/pre&gt;&lt;p&gt;Note: If you had wanted to create a query that produced a sequence of objects that only included the Name and Age members, you could have used the technique shown in part 1 where the select clause returned a newly created object (which was an anonymous object in that example, but could have been any compatible type).&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;In the preceding query, a sequence of Customer objects is returned by the GetCustomers function. This particular function is an example of an iterator method. Iterator methods are discussed in the following section.&lt;br&gt;&lt;br&gt;Granted, this is a simple example. However, there are many different methods in the .NET framework class library that return arrays, collections, and other queryable data sources. As a result, it is possible to use LINQ to perform a wide variety of useful tasks.&lt;/p&gt;&lt;p&gt;Examples of some of these uses can be found in the Windows SDK for .NET 3.5. For example, there are a number of examples of how to use LINQ to explore files and directories on the local file system. This is possible because the System.IO.Directory.GetFiles method returns an array of strings containing the names of the files in a given directory. Arrays, as you’ve seen, can be used in LINQ queries.&lt;/p&gt;&lt;h2&gt;Interator Methods and Yield Statements&lt;/h2&gt;&lt;p&gt;Iterators are special methods that return a sequence. You declare an iterator by including the iterator keyword in the method signature. Each element in the sequence is specifically returned by the iterator through a call to yield.&lt;/p&gt;&lt;p&gt;This is demonstrated in the following code sample. First, the iterator is declared using the following statement.&lt;/p&gt;&lt;pre&gt;method GetLowDigits: sequence of Integer; iterator;&lt;/pre&gt;&lt;p&gt;Next, the implementation of the iterator includes one or more calls to yield, which, like exit, can be used to return a value (though yield does not cause a return from the method in the same way that exit does).&lt;/p&gt;&lt;pre&gt;method MainForm.GetLowDigits: sequenbce of Integer;&lt;br&gt;&lt;p&gt;begin&lt;br&gt;&lt;/p&gt;&lt;p&gt;for i: Integer := 1 to 9 do&lt;br&gt;&lt;/p&gt;&lt;p&gt;  yield i;&lt;br&gt;&lt;/p&gt;&lt;p&gt;end;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;The following code demonstrates the use of this iterator. &lt;/p&gt;&lt;pre&gt;var numbers := GetLowDigits;&lt;br&gt;&lt;p&gt;for each n in numbers do&lt;br&gt;  MessageBox.Show(n.ToString);&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;Iterator methods are not executed when the sequence is assigned to a sequence reference. Specifically, the var declaration and initialization in the preceding code segment did not cause the GetLowDigits iterator to execute. Instead, it was the specific iteration over the sequence in the for each loop that caused the iterator to be executed. Furthermore, the iterator was not executed all at once. Instead, the iterator is executed up until it returns the first element of the sequence, that element is then used by the for each loop, which will then call back to the iterator to get the next value in the sequence, and so on.&lt;/p&gt;&lt;p&gt;The yield keyword can be used to return either a single element of the sequence or a reference to a sequence (which could be an array, a method that returns an array, or other similar reference).&lt;/p&gt;&lt;p&gt;Here is another example of an iterator and a sequence. This code requires a type declaration, which looks like the following.&lt;/p&gt;&lt;pre&gt;Customer = class&lt;br&gt;&lt;p&gt;private&lt;br&gt;&lt;/p&gt;&lt;p&gt;  FName: String;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  FAge: Integer;&lt;br&gt;&lt;/p&gt;&lt;p&gt;public&lt;br&gt;&lt;/p&gt;&lt;p&gt;  property Name: String read FName write FName;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  property Age: Integer read fAge write FAge;&lt;br&gt;end;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;Here is the declaration of the iterator.&lt;/p&gt;&lt;pre&gt;method GetCustomers: sequence of Customer; iterator;&lt;/pre&gt;&lt;p&gt;And here is the implementation of the iterator.&lt;/p&gt;&lt;pre&gt;method MainForm.GetCustomers: sequence of Customer;&lt;br&gt;&lt;p&gt;begin&lt;br&gt;&lt;/p&gt;&lt;p&gt;  yield new Customer(Name:= 'Allan', Age := 10);&lt;br&gt;&lt;/p&gt;&lt;p&gt;  yield new Customer(Name := 'Bob', Age := 25);&lt;br&gt;&lt;/p&gt;&lt;p&gt;  yield new Customer(Name := 'Craig', Age := 18);&lt;br&gt;end;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;Now that you understand the iterator, it is easy to see that the following LINQ query, which was introduced in the preceding section, populates the listbox named ResultList with the values Name: Bob, Age=25 and Name: Craig, Age=18.&lt;/p&gt;&lt;p&gt;var Customers := GetCustomers;&lt;br&gt;var query := from c in Customers&lt;br&gt;where (c.Age &amp;gt; 10) and (c.Age &amp;lt; 40) and (c.Active = true&amp;lt;) select c;&lt;br&gt;for each m in query do&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;    String.Format("Name: {0}, Age={1}", [m.Name, m.Age]));&lt;/p&gt;&lt;p&gt;The implementation of the iterator in this case used the named parameters feature of Delphi Prism’s nameless constructors to return each of the customers (which in reality would have probably been populated with data from an external source, such as a database). Also, the Customers type declaration used type inference to determine that Customers variable was a sequence of Customer.&lt;/p&gt;&lt;h2&gt;What is LINQ to DataSets&lt;/h2&gt;&lt;p&gt;LINQ to DataSets is a LINQ provider that permits you to use LINQ queries against DataTables, DataRows, and other classes in the ADO.NET framework. In order to use LINQ to DataSet, you must add the System.Data.DataSetExtensions assembly to the references section of your Delphi Prism project.&lt;/p&gt;&lt;p&gt;This section is designed to provide you with a brief introduction to LINQ to DataSet. As such, it does not go into ADO.NET, which is the data connectivity framework in .NET. &lt;/p&gt;&lt;p&gt;Note: LINQ to DataSet should really probably be called LINQ to DataTable or LINQ to DataRows, or even LINQ to ADO.NET. None of the operations in LINQ to DataSet are performed on instances of the DataSet class. Instead, they are performed on DataTables and DataRows.&lt;/p&gt;&lt;p&gt;As you learned earlier in this article, LINQ queries can be performed on any object that implements the IEnumerable&amp;lt;T&amp;gt; interface. DataTables (and DataRows) do not implement IEnumerable. However, they both have extension methods that support IEnumerable. These are defined in the DataTableExtensions class, which is located in the System.Data.DataSetExtensions namespace (which is why you must add this assembly to your project references folder).&lt;/p&gt;&lt;p&gt;There are only three extension methods in the DataSetExtensions class. These are AsDataView, AsEnumerable, and CopyToDataTable. For DataTables, the key method is AsEnumerable, which returns an enumerable collection of DataRows (records). &lt;/p&gt;&lt;p&gt;This is demonstrated in the following segment code.&lt;/p&gt;&lt;pre&gt;method MainForm.LINQToDataSet_Click(sender: System.Object;&lt;br&gt;  e: System.EventArgs);&lt;br&gt;var&lt;br&gt;  Connection: DataStoreConnection;&lt;br&gt;  Adapter: DataStoreDataAdapter;&lt;br&gt;  DataTable1: DataTable;&lt;br&gt;begin&lt;br&gt;  Connection := new DataStoreConnection(conStr);&lt;br&gt;  Connection.Open;&lt;br&gt;  try&lt;br&gt;    Adapter := new DataStoreDataAdapter(&lt;br&gt;      'SELECT * FROM   CUSTOMER', connection);&lt;br&gt;    DataTable1 := new DataTable;&lt;br&gt;    DataTable1.TableName := 'Customer';&lt;br&gt;    Adapter.Fill(DataTable1);&lt;br&gt;    var query :=&lt;br&gt;      from cust in DataTable1.AsEnumerable&lt;br&gt;      where cust['ON_HOLD'].Equals(DbNull.Value)&lt;br&gt;      and (cust.Field&amp;lt;string&amp;gt;(&amp;#39;STATE_PROVINCE&amp;#39;) = &amp;#39;CA&amp;#39;);&lt;br&gt;    for each c in query do&lt;br&gt;    begin&lt;br&gt;      ResultsList.Items.Add(&lt;br&gt;        String.Format('Customer Number: {0}' +&lt;br&gt;        ' Company Name: {1}', c['Cust_No'].ToString,&lt;br&gt;        c['Customer'].ToString));&lt;br&gt;    end;&lt;br&gt;  finally&lt;br&gt;    Connection.Close;&lt;br&gt;  end;&lt;br&gt;end;&lt;/pre&gt;&lt;p&gt;Once the DataTable has been populated with data from the SQL query, the AsEnumerable method of the DataTable is called, and this object is used in the LINQ query. Interestingly enough, the object returned from the AsEnumerable method is a generic IEnumerable&amp;lt;T&amp;gt;, where the type is a collection of DataRows.&lt;/p&gt;&lt;p&gt;As you consider this code segment, you might conclude that you would be better off using a SQL statement that performs the filtering of the results, rather than use a LINQ query. While that may be true in some instances, if you want to load a DataTable once, and perform numerous queries on the returned value, the LINQ query offers performance benefits. (Note that another alternative is to use a DataView to filter and sort the DataTable results.)&lt;/p&gt;&lt;p&gt;Note that in addition to LINQ to DataSet, the .NET framework provides the LINQ to SQL provider. Unlike LINQ to DataSet, which can be used against any database for which there is a .NET data provider, LINQ to SQL is specifically designed to work only with Microsoft SQL Server. LINQ to Entities is another LINQ provider that can be used against supported databases.&lt;/p&gt;&lt;h2&gt;What is LINQ to XML&lt;/h2&gt;&lt;p&gt;LINQ to XML provides a programming model, similar to XPath, with which you can create, edit, query, and save XML documents. LINQ to XML provides you an alternative to using the XML DOM (document object model), which is what is used by the XMLDocument class in the .NET framework. Like the DOM, LINQ to XML works with the XML document in memory. From there you can read, query, and write data to the XML document, after which you can stream it to a service or write it to a file, if you desire.&lt;/p&gt;&lt;p&gt;As is the case with the LINQ to DataSet topic that precedes this section, this discussion is designed to provide you with a basic introduction to LINQ to XML. It does not, however, cover general XML issues.&lt;/p&gt;&lt;p&gt;In fact, LINQ to XML is far more involved than LINQ to DataSet. This is because LINQ to XML not only supports features necessary for querying, but as mentioned earlier, an entire programming model for working with XML. As a result, this section will cover just enough information to get you started. &lt;/p&gt;&lt;p&gt;Unlike LINQ to DataSet, where most of the functionality is found in extension methods added to DataTable and DataRow, LINQ to XML, found in the System.Xml.Linq namespace, includes a large number of concrete classes that you can use to work with XML documents.&lt;/p&gt;&lt;p&gt;Of these classes, there are three that you are likely to use most often. These are XDocument and XElement, which descend from XNode, and XAttribute, which descends from XObject. (XNode, by the way, also descends from XObject.)&lt;/p&gt;&lt;p&gt;You can create a valid XML document using either XDocument or XElement, though XDocument provides a little more support for this. Specifically, there are certain advanced features of XML documents that you can access through the XDocument class which are unavailable through the XElement class. XAttribute, by comparison, is used to define attributes of XML elements.&lt;/p&gt;&lt;p&gt;But before you get started, at a minimum you will need to add the System.Xml.Linq namespace to your uses clause. In addition, you may have to add one or more of the following additional namespaces, depending on what features your code will use: System.Xml, System.Xml.Schema, System.Xml.XPath, and System.Xml.Xsl.&lt;/p&gt;&lt;h4&gt;Creating XML Documents using LINQ to XML&lt;/h4&gt;&lt;p&gt;As mentioned previously, you can create XML documents using either the XDocument or the XElement class. The following example demonstrates how to create an XML document using the XElement class.&lt;/p&gt;&lt;pre&gt;element := new XElement('customers',&lt;br&gt;               new XElement('customer',&lt;br&gt;                 new XAttribute('custno', 1001),&lt;br&gt;                 new XElement('name', 'John Doe'),&lt;br&gt;                 new XElement('address',&lt;br&gt;                   '101 Broadway Avenue'),&lt;br&gt;                 new XElement('city', 'New York'),&lt;br&gt;                 new XElement('state', 'NY'),&lt;br&gt;                 new XElement('zip',&lt;br&gt;                   '00123')                                            ),&lt;br&gt;              new XElement('customer',&lt;br&gt;                  new XAttribute('custno', 1002),&lt;br&gt;                  new XElement('name', 'John Doe'),&lt;br&gt;                  new XElement('address',&lt;br&gt;                    '1001 Main Street'),&lt;br&gt;                  new XElement('city', 'Los Angeles'),&lt;br&gt;                  new XElement('state', 'CA'),&lt;br&gt;                  new XElement('zip', '90123')&lt;br&gt;              )&lt;br&gt;          );&lt;br&gt;element.Save(XmlFileName);&lt;/pre&gt;&lt;p&gt;This code creates an XML file with a root element named customers. The root element has two child elements named customer. Each child element has one attribute and four child elements. The following is how the XML file created by this code looks.&lt;/p&gt;&lt;pre&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br&gt;&lt;p&gt;&amp;lt;customers&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt; &amp;lt;customer custno=&amp;quot;1001&amp;quot;&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;name&amp;gt;John Doe&amp;lt;/name&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;address&amp;gt;101 Broadway Avenue&amp;lt;/address&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;city&amp;gt;New York&amp;lt;/city&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;state&amp;gt;NY&amp;lt;/state&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;zip&amp;gt;00123&amp;lt;/zip&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt; &amp;lt;/customer&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt; &amp;lt;customer custno=&amp;quot;1002&amp;quot;&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;name&amp;gt;John Doe&amp;lt;/name&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;address&amp;gt;1001 Main Street&amp;lt;/address&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;city&amp;gt;Los Angeles&amp;lt;/city&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;state&amp;gt;CA&amp;lt;/state&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;zip&amp;gt;90123&amp;lt;/zip&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt; &amp;lt;/customer&amp;gt;&lt;br&gt;&amp;lt;/customers&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt; &lt;/p&gt;&lt;/pre&gt;&lt;p&gt;Creating this same file using an XDocument looks similar, though there are differences. &lt;/p&gt;&lt;p&gt;The documentation for LINQ with XML includes a large number of demonstrations of XML definition using declarations like the one provided previously. These declarations, however, are anything but flexible. In other words, they always create the same XML file, which is rarely useful.&lt;/p&gt;&lt;p&gt;The following example, which obtains its data from an ADO.NET data reader, produces an XML file similar in structure to the preceding one, except that its data is entirely based on the results of a SQL query.&lt;/p&gt;&lt;pre&gt;Connection := new DataStoreConnection(conStr);&lt;br&gt;Connection.Open;&lt;br&gt;try&lt;br&gt;  Command := Connection.CreateCommand;&lt;br&gt;  Command.CommandText := 'select cust_no, customer, ' +&lt;br&gt;    'address_line1, city, state_province, ' +&lt;br&gt;    'postal_code from customer';&lt;br&gt;  DataReader := Command.ExecuteReader;&lt;br&gt;  try  &lt;br&gt;    document := new XDocument(&lt;br&gt;      new XElement('customers'));&lt;br&gt;    while DataReader.Read do&lt;br&gt;    begin&lt;br&gt;      attribute := new XAttribute('custno',&lt;br&gt;        DataReader.GetString(0));&lt;br&gt;      element :=&lt;br&gt;        new XElement('customer',&lt;br&gt;          new XElement('name', DataReader.GetString(1)),&lt;br&gt;          new XElement('address',&lt;br&gt;            DataReader.GetString(2)),&lt;br&gt;          new XElement('city', DataReader.GetString(3)),&lt;br&gt;          new XElement('state',&lt;br&gt;            DataReader.GetString(4)),&lt;br&gt;          new XElement('zip',&lt;br&gt;            DataReader.GetString(5))&lt;br&gt;        );&lt;br&gt;      element.Add(attribute);&lt;br&gt;      document.Root.Add(element);                &lt;br&gt;    end;&lt;br&gt;  finally&lt;br&gt;    DataReader.Close;&lt;br&gt;  end;&lt;br&gt;  document.Save(XmlFileName);&lt;br&gt;finally&lt;br&gt;  connection.Close;&lt;br&gt;end;&lt;/pre&gt;&lt;h4&gt;Querying with LINQ to XML&lt;/h4&gt;&lt;p&gt;Querying using LINQ to XML is similar to other LINQ queries, though there are classes and methods that you use in LINQ to XML that are not found in other LINQ technologies. In short, once you have a reference to a queryable object (an IEnumerable, a sequence, or other similar construct), you use query statements to retrieve the data you are interested in. The following example demonstrates a LINQ to XML query.&lt;/p&gt;&lt;pre&gt;element := XElement.Load(XmlFileName);&lt;br&gt;var childList :=&lt;br&gt;  from el in element.Elements&lt;br&gt;  where String(el.Element('state')) = 'CA'&lt;br&gt;  order by String(el.Attribute('custno')) desc&lt;br&gt;  select new XElement('document',&lt;br&gt;    new XElement('CustomerName', el.Element('name')) ,&lt;br&gt;      new XElement('Address', el.Element('address')),&lt;br&gt;      new XElement('CityStateZip',&lt;br&gt;        el.Element('city').Value + ', ' +&lt;br&gt;        el.Element('state').Value + ' ' +&lt;br&gt;        el.Element('zip').Value));&lt;br&gt;for each e in childList do&lt;br&gt;begin&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;   e.Element("CustomerName").Value);&lt;br&gt;  ResultsList.Items.Add(e.Element("Address").Value);&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;    e.Element('CityStateZip').Value);&lt;br&gt;  ResultsList.Items.Add(String.Empty);&lt;br&gt;end;&lt;/pre&gt;&lt;p&gt;This query returns a sequence of XElement references, which have a structure similar to, though different than, the original XElements. For example, the new XElements are not named customer, they are named document. Furthermore, there are no attributes in the new XElements, and there are only three child nodes.&lt;/p&gt;&lt;p&gt;The preceding example demonstrated a query using the XElement class. The following code shows the same basic query, however an XDocument is used in this example.&lt;/p&gt;&lt;pre&gt;document := XDocument.Load(XmlFileName);&lt;br&gt;var childList :=&lt;br&gt;  from el in document.Descendants&lt;br&gt;  where String(el.Element('state')) = 'CA'&lt;br&gt;  order by String(el.Attribute('custno')) desc&lt;br&gt;  select new XElement('document',&lt;br&gt;    new XElement('CustomerName',&lt;br&gt;      el.Element('name')),&lt;br&gt;    new XElement('Address', el.Element('address')),&lt;br&gt;    new XElement('CityStateZip',&lt;br&gt;      el.Element('city').Value + ', ' +&lt;br&gt;      el.Element('state').Value + ', ' +&lt;br&gt;      el.Element('zip').Value));&lt;br&gt;for each e in childList do&lt;br&gt;begin&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;    e.Element("CustomerName").Value);&lt;br&gt;  ResultsList.Items.Add(e.Element("Address").Value);&lt;br&gt;  ResultsList.Items.Add(&lt;br&gt;    e.Element('CityStateZip').Value);&lt;br&gt;  ResultsList.Items.Add(String.Empty);&lt;br&gt;end;&lt;/pre&gt;&lt;h4&gt;Modifying Exiting XML using LINQ to XML&lt;/h4&gt;&lt;p&gt;Once XML is in memory, you can add elements or attributes, remove elements or attributes, as well as modify the data for elements or attributes. If you load the XML from an existing source, such as a file, make modifications, and then save the XML back to the original source, you have effectively changed the XML.&lt;/p&gt;&lt;p&gt;This is demonstrated in the following code.&lt;/p&gt;&lt;pre&gt;document := XDocument.Load(XmlFileName);&lt;br&gt;var childList :=&lt;br&gt;  from el in document.Descendants&lt;br&gt;  where String(el.Element('state')) = 'CA'&lt;br&gt;  order by String(el.Attribute('custno')) desc&lt;br&gt;  select el;&lt;br&gt;//make changes&lt;br&gt;for each e in childList do&lt;br&gt;begin&lt;br&gt;  e.Element('state').SetValue('California');&lt;br&gt;end;&lt;br&gt;//save the changes&lt;br&gt;document.Save(XmlFileName);&lt;/pre&gt;&lt;p&gt;There is an important characteristic of the preceding code that you should note. Specifically, the select clause of the LINQ to XML query returned a sequence of XElements from the original XDocument. While these represent a possible subset of all XElements returned by the Descendants method of the XDocument, they are still child elements of the original XDocument. &lt;/p&gt;&lt;p&gt;When changes are made to the items in the sequence returned by the query, those changes are actually being made to the corresponding XElements in the XDocument. This is why the changes are preserved when the subsequent call to XDocument.Save is made.&lt;/p&gt;&lt;p&gt;By comparison, if the select clause had created new XElements, similar to how the last query in the preceding section demonstrated, the subsequent changes would have been performed on the newly created objects, which are not child elements of the XDocument.&lt;/p&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;p&gt;This two part series has provided you with a brief introduction to LINQ with Delphi Prism. Here you have learned how to construct LINQ Queries, the nature of LINQ to Objects, define and implement iterators, and have been given a preview of LINQ to DataSets and LINQ to XML.&lt;/p&gt;&lt;p&gt;Copyright © 2009 Cary Jensen. All Rights Reserved&lt;/p&gt;&lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/6222893893652665733-6215869260230624289?l=caryjensen.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/6sP-ubR5n90" height="1" width="1"/&gt;</content><author><name>Cary Jensen</name></author><source gr:stream-id="feed/http://caryjensen.blogspot.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://caryjensen.blogspot.com/feeds/posts/default</id><title type="html">Cary Jensen  &amp;quot;Let&amp;#39;s Get Technical&amp;quot;</title><link rel="alternate" href="http://caryjensen.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://caryjensen.blogspot.com/2009/07/introduction-to-language-integrated.html</feedburner:origLink></entry><entry gr:crawl-timestamp-msec="1251977180256"><id gr:original-id="">tag:google.com,2005:reader/item/3999ed670d3be95d</id><title type="html">Introduction to Language Integrated Query with Delphi Prism: Part 1</title><published>2009-09-03T11:26:20Z</published><updated>2009-09-03T11:26:20Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/JamiesDelphiClippings/~3/0EtR0CQKfi0/introduction-to-language-integrated.html" type="text/html" /><link rel="related" href="http://caryjensen.blogspot.com/" title="Cary Jensen &quot;Let's Get Technical&quot;" /><content xml:base="http://caryjensen.blogspot.com/2009/06/introduction-to-language-integrated.html" type="html">&lt;p&gt;Language Integrated Query, or LINQ (pronounced link), is a declarative programming language developed by Microsoft for the .NET framework. In a declarative programming language you specify what result you want to achieve without needing to specify how those results are produced. &lt;/p&gt;  &lt;p&gt;SQL SELECT statements are an example of declarative programming. With a given SQL statement you specify what data you want returned. It is up to the SQL engine to determine how that data is derived.&lt;/p&gt;  &lt;p&gt;Traditional Delphi, on the other hand, is categorized as imperative programming. When writing Delphi code, you generally describe in detailed terms how you want the result obtained. You do this using control structures, expressions, and explicit calls to functions and procedures.&lt;/p&gt;  &lt;p&gt;This article is designed to provide you with a general overview of using LINQ with Delphi Prism, the latest .NET development tool from Embarcadero Technologies and RemObjects. For a more detailed discussion of LINQ and its related topics, refer to the latest version of the .NET framework SDK.&lt;/p&gt;  &lt;h2&gt;Overview of LINQ&lt;/h2&gt;  &lt;p&gt;Language Integrated Query comes in a variety of different flavors, depending on the version of the .NET framework you are compiling against. For example, there is LINQ to Objects, LINQ to DataSets, LINQ to SQL, and LINQ to XML. Each of these technologies, which were introduced in .NET 3.0, provides classes you can use in conjunction with LINQ to work with objects in various domains of the .NET framework.&lt;/p&gt;  &lt;p&gt;In addition, some of the major new features that are emerging in .NET also are LINQ related. One example is LINQ to Entities, which is part of the Entity Framework. The Entity Framework is one of the latest database technologies being promoted by Microsoft.&lt;/p&gt;  &lt;p&gt;Turning our attention to the general case of LINQ, LINQ queries can be divided into three basic parts. These are&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A queryable source of data &lt;/li&gt;    &lt;li&gt;A query definition &lt;/li&gt;    &lt;li&gt;Query execution &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The following sections describe each of these parts in greater detail. &lt;/p&gt;  &lt;h2&gt;&lt;a name="_Toc228098596"&gt;Queryable Sources of Data&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;In strictly .NET terms, a queryable source of data is any object that implements the generic IEnumerable&amp;lt;T&amp;gt; interface, which includes List&amp;lt;T&amp;gt; and Dictionary&amp;lt;TKey, TValue&amp;gt;. In Delphi Prism, this also includes any collection that is declared as a sequence, as well as arrays (both fixed and dynamic).&lt;/p&gt;  &lt;p&gt;Some of the LINQ technologies, such as LINQ to DataSet and LINQ to XML, are implemented through LINQ providers, which are support classes that enable LINQ operations. These providers usually include special methods that provide access to an IEnumerable&amp;lt;T&amp;gt; reference based on an object that otherwise does not support this interface. For example, LINQ to DataSet provides the AsEnumerable extension method to the DataTable class.&lt;/p&gt;  &lt;p&gt;The following variable declaration defines a simple queryable data source. In this case, the data source is a sequence.&lt;/p&gt;  &lt;p&gt;var seq: sequence of Integer := [1,2,3,4,5,6,7,8,9];&lt;/p&gt;  &lt;h2&gt;&lt;a name="_Toc228098597"&gt;Query Definitions using Query Syntax&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;A query definition consists of two parts, a query variable and a query expression. Furthermore, query expressions are defined using one of two techniques. The first is called query syntax, and the second is called method syntax. This section describes query syntax. Method syntax is described later in this article.&lt;/p&gt;  &lt;p&gt;Query expressions are defined using a combination of one or more LINQ statements, comparison operators, extension methods, and value references. At a minimum, a LINQ query includes a from clause, which defines an alias and a data source. Consider the following code segment:&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];&lt;/p&gt;  &lt;p&gt;var myquery := from c in numbers select c;&lt;/p&gt;  &lt;p&gt;The first line of code defines the data source, and the second line defines the query. The query in this case selects all items from the sequence numbers, as can be seen in the following figure (the code that populates the list box has not been shown yet).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://3.bp.blogspot.com/_oiz-KoL9VE4/SlTHF9UhF6I/AAAAAAAAABU/jbjCD7oaqoM/s1600-h/LINQ1.1.jpg"&gt;&lt;img style="display:block;margin:0px auto 10px;width:320px;height:243px;text-align:center" alt="" src="http://3.bp.blogspot.com/_oiz-KoL9VE4/SlTHF9UhF6I/AAAAAAAAABU/jbjCD7oaqoM/s320/LINQ1.1.jpg" border="0"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Figure 1. The LINQExamples project&lt;/p&gt;  &lt;p&gt;The c in the preceding query is an alias, and it is used to reference items in the numbers sequence. The select part of the query, which contrary to SQL standards, appears at the end of the statement, defines what is returned by the query. In this case, the query returns each of the items in the sequence.&lt;/p&gt;  &lt;p&gt;The preceding query really just creates another sequence that is no different from the one that it queried. Most LINQ queries, by comparison, either select subsets of the data, performs data transformations, or other similar operations. The following query includes a where clause that limits the myquery sequence to those numbers between 4 and 8, inclusively. As you can see, the alias is essential for performing this operation.&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];    &lt;br&gt;var myquery := from c in numbers where (c &amp;gt;= 4) and (c &amp;lt;= 8) select c;&lt;/p&gt;  &lt;p&gt;In both queries shown so far in this section, the select clause could have been omitted. Specifically, if what we are returning is exactly the same type of item as in the sequence, we can omit the select clause altogether. In other words, omitting the select clause is somewhat similar to a SELECT * clause in a SQL query. The following query, which does not have a select clause, produces the same result as the preceding one.&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];    &lt;br&gt;var myquery := from c in numbers where (c &amp;gt;= 4) and (c &amp;lt;= 8);&lt;/p&gt;  &lt;p&gt;The select clause in LINQ is required when you are querying objects with one or more members, and want to only return a subset of its members, or want to return transformed data. For example, the following query returns a sequence of objects whose values are equal to the square of the original values. The objects returned by the select clause, in this case, are anonymous types. (An anonymous type of an object whose type is never explicitly declared, one of many advanced language features supported by Delphi Prism.)&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];    &lt;br&gt;var myquery := from c in numbers select new class(Value := c * c);&lt;/p&gt;  &lt;p&gt;LINQ queries can be relatively complicated. In addition to the from, where, and select keywords shown here, Delphi Prism also supports the following LINQ operations: order by, group by, join, with, take, skip, reverse, and distinct. In addition, LINQ queries can make use of lambda expressions, both in the where and select parts (Lambda expressions are discussed briefly later in this article). Finally, similar to SQL, LINQ queries can include subqueries.&lt;/p&gt;  &lt;h2&gt;&lt;a name="_Toc228098598"&gt;Executing LINQ Queries&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;Defining a query and executing a query are two distinct steps (though as you will learn shortly, Delphi Prism provides a mechanism for combining these operations). Specifically, the query defined in the preceding section identifies what the query will do, but does not execute the query. In LINQ this is referred to as deferred execution.&lt;/p&gt;  &lt;p&gt;You cause the query to be executed by iterating over it using a for each loop. Each execution of the loop brings back another instance of whatever the query returns. For example, if you used a for each loop to iterate over the query shown in the preceding example, each iteration of the loop would return a different instance of the anonymous type. &lt;/p&gt;  &lt;p&gt;The following is the entire code sequence (short as it is), which shows how the Value member of the returned objects are assigned to the list box (which is name ResultList in this example).&lt;/p&gt;  &lt;p&gt;ResultsList.Items.Clear;    &lt;br&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];     &lt;br&gt;var myquery := from c in numbers select new class(Value := c * c);     &lt;br&gt;for each m in myquery do     &lt;br&gt;  ResultsList.Items.Add(m.Value.ToString);&lt;/p&gt;  &lt;p&gt;When written to the list box, this query result looks like the following.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_oiz-KoL9VE4/SlTHLGrTSEI/AAAAAAAAABc/uRg1xIawALE/s1600-h/LINQ1.2.jpg"&gt;&lt;img style="display:block;margin:0px auto 10px;width:320px;height:243px;text-align:center" alt="" src="http://2.bp.blogspot.com/_oiz-KoL9VE4/SlTHLGrTSEI/AAAAAAAAABc/uRg1xIawALE/s320/LINQ1.2.jpg" border="0"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Figure 2. Data from an anonymous type returns from a LINQ query&lt;/p&gt;  &lt;p&gt;Similar to the alias in the query definition, the for each loop defines a local variable that holds the value of the item that is returned in each iteration. In the preceding code, this variable is named m. In most cases, Delphi Prism uses type inference to determine the type of this variable (which is fortunate in this case, since we used an anonymous type).&lt;/p&gt;  &lt;p&gt;Not all LINQ queries use deferred execution. To cause the results of the query to retrieve immediately, you can use either the IEnumerable methods ToList&amp;lt;TSource&amp;gt; or ToArray&amp;lt;TSource&amp;gt;. An example of this is shown in the following code.&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];    &lt;br&gt;var MyResults: Array of Integer :=     &lt;br&gt;  (from c in numbers where (c &amp;gt;= 4) and (c &amp;lt;= 8)).ToArray();     &lt;br&gt;for each val in MyResults do     &lt;br&gt;ResultsList.Items.Add(val.ToString);&lt;/p&gt;  &lt;p&gt;Similarly, if you use any of the grouping operations, such Average, Count, First, and so forth, the query is executed immediately. This is demonstrated in the following code.&lt;/p&gt;  &lt;p&gt;var numbers: sequence of Integer := [1,2,3,4,5,6,7,8,9];    &lt;br&gt;var MyResults: Double := (from c in numbers).Average();     &lt;br&gt;MessageBox.Show(MyResults.ToString);&lt;/p&gt;  &lt;h2&gt;&lt;a name="_Toc228098599"&gt;LINQ Query Method Syntax&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;As mentioned earlier, LINQ query expressions can be defined using both query syntax and method syntax. Method syntax is implemented through extension methods on the System.Linq.Enumerable class, and corresponds roughly to the LINQ query syntax operators. &lt;/p&gt;  &lt;p&gt;The truth is that when you use query syntax in your query expressions, the compiler converts these into method syntax. Another way to put this is that any query that you can write using query syntax can also be defined using method syntax. Interestingly, the opposite is not true. Specifically, there are some queries that you must define using method syntax, as there is no equivalent in query syntax.&lt;/p&gt;  &lt;p&gt;Unlike in query syntax, there are no aliases in method syntax. Instead, the methods are called on your IEnumerable object directly, using dot notation. These operations are typically performed in a single expression. In other words, using dot notation, method syntax sometimes includes a number of method calls, implemented through a chain of calls.&lt;/p&gt;  &lt;p&gt;This is demonstrated in the following code segment, which produces a query identical to the first one listed in the preceding section “Query Definitions using Query Syntax.”&lt;/p&gt;  &lt;p&gt;var myquery := numbers.where(c -&amp;gt; c &amp;gt;= 4).    &lt;br&gt;  where(c -&amp;gt; c &amp;lt;= 8).orderby(c -&amp;gt; c).select(c -&amp;gt; c);&lt;/p&gt;  &lt;p&gt;The preceding statement is a single statement, even though it has been wrapped onto two lines due to the limits of the column space in this article. Fortunately, this wrapped form can still be compiled by Delphi since its compiler is designed to ignore white space. Also, the arguments of the where, orderby, and select clauses are lambda expressions. Lambda expressions are discussed in the following section.&lt;/p&gt;  &lt;p&gt;As with the query expressions, the select method call here is not necessary, since there is no transformation being performed on the returned items.&lt;/p&gt;  &lt;p&gt;The syntax is a little different when your sequence contains more complex data. This can be seen from the following code, which is the method syntax version of the code segment described in the following section “LINQ to Objects.”&lt;/p&gt;  &lt;p&gt;var Customers := GetCustomers;    &lt;br&gt;var query := Customers.Where(Customer -&amp;gt; Customer.Age &amp;gt; 10).     &lt;br&gt;  Where(Customer -&amp;gt; Customer.Age &amp;lt; 40).     &lt;br&gt;  Where(Customer -&amp;gt; Customer.Active);&lt;/p&gt;  &lt;h2&gt;&lt;a name="_Toc228098600"&gt;Lambda Expressions&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;Lambda expressions are anonymous functions that can accept zero or more parameters, and typically return a value. The parameters appear on the left-hand side of the lambda operator, and are enclosed in parentheses (unless there are zero or one parameters, in which case the parentheses are optional).&lt;/p&gt;  &lt;p&gt;The parameters, if present, are following by the lambda operator, which is the -&amp;gt; character sequence in Delphi Prism (C# uses =&amp;gt; as the lambda operator). When reading a lambda expression aloud, the lambda operator is spoken “goes to.” As a result, the first expression in the preceding query expression is read “customer goes to customer dot age greater than 10.”&lt;/p&gt;  &lt;p&gt;The expression on the right-hand side of the lambda operator includes either an expression or a statement. This is the value that is returned by the lambda expression (if the statement is an expression lambda). It is possible, however, to include an expression block that does not resolve to an expression. These lambdas are called statement lambdas. Statement lambdas should not be used in method calls when using method syntax. &lt;/p&gt;  &lt;p&gt;In most cases, lambda expressions take advantage of the compiler’s ability to infer the type of the input parameters. &lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;This article has provided you with a brief introduction to the composition of language integrated queries. In part 2 of this article, which will appear within a month of this article, numerous examples of LINQ queries are shown, including technologies such as LINQ to Objects, LINQ to DataSets, and LINQ to XML.&lt;/p&gt;  &lt;p&gt;Copyright © 2009 Cary Jensen All Rights Reserved&lt;/p&gt;  &lt;div&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/6222893893652665733-4559815027305325873?l=caryjensen.blogspot.com"&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/JamiesDelphiClippings/~4/0EtR0CQKfi0" height="1" width="1"/&gt;</content><author gr:unknown-author="true"><name>(author unknown)</name></author><source gr:stream-id="user/07946391749317373099/source/com.google/link"><id>tag:google.com,2005:reader/user/07946391749317373099/source/com.google/link</id><title type="html">Cary Jensen &amp;quot;Let&amp;#39;s Get Technical&amp;quot;</title><link rel="alternate" href="http://caryjensen.blogspot.com/" type="text/html" /></source><feedburner:origLink>http://caryjensen.blogspot.com/2009/06/introduction-to-language-integrated.html</feedburner:origLink></entry></feed>
