<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="http://www.atalasoft.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Atalasoft Community RSS</title>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2013/how-to-split-a-cubic-bezier-curve]]></guid>
     <title><![CDATA[How to Split a Cubic Bézier Curve]]></title>
     <description><![CDATA[<p>
	Today I&rsquo;m going to get all mathy on you.&nbsp; Don&rsquo;t worry about it &ndash; it&rsquo;s going to be pretty simple math and in the end we&rsquo;re going to learn how to split a cubic Bézier curve into two new curves.</p>
<p>
	First, let&rsquo;s start off with parametric equations.&nbsp; This is a type of equation that adds a new variable, <em>t</em>, which can be thought of as time.&nbsp; In our world, <em>t</em> is going to range from 0 (the start) to 1.0 (the end).&nbsp; So for example, if I have a line segment from point A to point B, then point A is at time 0, point B is at time 1 and the midpoint is at time 0.5.</p>
<p>
	Let&rsquo;s look at midpoint briefly &ndash; you probably learned midpoint as this:</p>
<p align="center">
	<em>x&rsquo; = </em>(<em>x</em><sub>1</sub><em>&nbsp;</em>+<em> x</em><sub>0</sub>)/2</p>
<p align="center">
	<em>y&rsquo; = </em>(<em>y</em><sub>1</sub><em>&nbsp;</em>+<em> y</em><sub>0</sub>)/2</p>
<p>
	or simply, the average of the x&rsquo;s and the y&rsquo;s.&nbsp; But let&rsquo;s have some fun with this.&nbsp; I&rsquo;m going to only work with <em>x</em> components, but I assure you that this works just fine with both.&nbsp; First, I&rsquo;m going to rewrite that divide by 2 as a multiply by 0.5:</p>
<p align="center">
	<em>x&rsquo; = </em>(<em>x</em><sub>1</sub><em> </em>+<em> x</em><sub>0</sub>) * 0.5</p>
<p align="left">
	Now, let&rsquo;s distribute this over the terms:</p>
<p align="center">
	<em>x&rsquo; = </em>0.5<em>x</em><sub>1</sub><em> </em>+<em> </em>0.5<em>x</em><sub>0</sub></p>
<p align="left">
	Now, I&rsquo;m going to rewrite the second term as an equivalent:</p>
<p align="center">
	<em>x&rsquo; = </em>0.5<em>x</em><sub>1</sub><em> </em>+<em> -</em>0.5<em>x</em><sub>0</sub> + <em>x</em><sub>0</sub></p>
<p align="left">
	We simplify and associate:</p>
<p align="center">
	<em>x&rsquo; = </em>(<em>x</em><sub>1</sub><em> &ndash; </em><em>x</em><sub>0</sub>)<em> * </em>0.5 + <em>x</em><sub>0</sub></p>
<p align="left">
	This is an equivalent, if slightly more general version of midpoint.&nbsp; So why did we do that?&nbsp; Because we can now replace that 0.5 with <em>t</em> as time and we have a complete parametric equation for a line:</p>
<p align="center">
	<em>x&rsquo; = </em>(<em>x</em><sub>1</sub><em> &ndash; </em><em>x</em><sub>0</sub>)<em> * t</em> + <em>x</em><sub>0</sub></p>
<p align="center">
	<em>y&rsquo; = </em>(<em>x</em><sub>1</sub><em> &ndash; </em><em>y</em><sub>0</sub>)<em> * t</em> + <em>y</em><sub>0</sub></p>
<p align="left">
	I&rsquo;ve also given you the formula for linear interpolation from one point to another &ndash; it&rsquo;s the same.&nbsp; And to help you along, I&rsquo;m going to give you a new verb, lerp, which means to linear interpolate from A to B.</p>
<p align="left">
	Now, onto cubic Bézier curves.&nbsp; Here is a simple cubic Bézier curve which is defined by 4 points &ndash; two end points and two control points<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=da27a266-3f87-4015-bef7-02eaa375134e"><img alt="bezier1" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6b96a1fd-9c48-4e23-bd23-8ad446967b46" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="bezier1" width="337" /></a></p>
<p align="left">
	P0 and P3 are end points and P1 and P2 are the control points.&nbsp; The parametric formula for this curve is this:</p>
<p align="center">
	<em>x</em> = <em>a<sub>x</sub>t</em><sup>3</sup> + <em>b<sub>x</sub>t</em><sup>2</sup> +<em> c<sub>x</sub>t</em> + <em>x</em><sub>0</sub></p>
<p align="center">
	<em>y</em> = <em>a<sub>y</sub>t</em><sup>3</sup> + <em>b<sub>y</sub>t</em><sup>2</sup> +<em> c<sub>y</sub>t</em> + <em>y</em><sub>0</sub></p>
<p align="left">
	&nbsp;</p>
<p align="left">
	It looks like a handful, but it&rsquo;s not really that bad &ndash; it&rsquo;s a third degree polynomial that is a function of <em>t</em> and <strong>not</strong> of x or y.&nbsp; One tricky part is understanding the relationship between the four control points and the coefficients of the <em>t</em> terms.&nbsp; Again, let&rsquo;s work with just the <em>x</em> side, since the <em>y </em>equation will work out the same.&nbsp; I&rsquo;m not going to derive these for you &ndash; trust me.</p>
<p align="center">
	<em>a<sub>x</sub></em> = <em>x</em>3 &ndash; ( 3 * <em>x</em>2) + (3 * <em>x</em>1) &ndash; <em>x</em>0</p>
<p align="center">
	<em>b<sub>x</sub></em> = (3 * <em>x</em>2) &ndash; (6 * <em>x</em>1) + (3 * <em>x</em>0)</p>
<p align="center">
	<em>c<sub>x</sub></em> = (3 * <em>x</em>1) &ndash; (3 * <em>x</em>0);</p>
<p align="left">
	&nbsp;</p>
<p align="left">
	The variables <em>x</em>0 through <em>x</em>3 correspond to the X coordinates for points P0 through P3 in the diagram above.&nbsp; So let&rsquo;s look at splitting this Bézier in half.&nbsp; We&rsquo;ll do this graphically by first drawing in some guides:</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a983b653-fce1-4902-9a06-559502446714"><img alt="bezier2" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9626012d-eee1-48f4-960f-c2e0c7a28223" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bezier2" width="337" /></a></p>
<p align="left">
	I&rsquo;ve added a line between P1 and P2 and added three new points, P4, P5, and P6.&nbsp; Each of these points are at the midpoint of the segment on which they lie.&nbsp; Now, let&#39;s connect the midpoints together:</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=c6e19b32-1ad9-4ccd-a26f-f278609946e7"><img alt="bezier3" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bd120409-718d-4d50-be84-c97cb44f2baa" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bezier3" width="337" /></a></p>
<p align="left">
	Here I&rsquo;ve added two new midpoints, P7 and P8.&nbsp; Repeat again to leave us with a new line and midpoint:</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=35bbc093-6df0-4cf0-8e04-50d109bb85f8"><img alt="bezier4" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9e4a76f4-36d2-41e7-8cb5-8501582eefd3" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bezier4" width="337" /></a></p>
<p align="left">
	And P9 is on the right on the curve.&nbsp; Furthermore, the first section of the split curve from P0 to P9 can be described with the four points, P0, P4, P7 and P9:</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=91fac116-cb3f-4daf-ba79-889d4fc6d91d"><img alt="bezier5" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=94509e76-5f2e-4a26-bed2-0e64eb715036" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bezier5" width="337" /></a></p>
<p align="left">
	and the second part of the split curve and be described with points P9, P8, P6 and P3:</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=2a964ab2-4a01-43a8-ab8e-5e90352afdf6"><img alt="bezier6" border="0" height="313" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1e684987-ab05-4ca5-a47f-f2b00827c6d5" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bezier6" width="337" /></a></p>
<p align="left">
	If you&rsquo;re still with me, you&rsquo;ll note that if you keep splitting the subcurves, you will eventually draw every point on the original curve.&nbsp; And you can do this all with calling midpoint successively.&nbsp; Generally speaking, in software we like this because midpoint is one add and one divide by two.&nbsp; If you&rsquo;re working in fixed point, this is wonderful because that becomes an add and a bitshift, both very fast instructions.&nbsp; In theory, I could do the subdivision of a curve in 14 instructions (plus about 7 instructions of overhead) per coordinate.&nbsp; That&rsquo;s really not a lot.&nbsp; There&rsquo;s a problem though &ndash; splitting a Bezier this way to, say, draw it with a series of straight lines is not so good as it&rsquo;s not obvious when you should subdivide further or be satisfied with what you have.&nbsp; In other words, a small change in <em>t</em> may make a substantial change in the distance traveled along the curve and the next change in <em>t</em> is likely NOT going to end up with the same change on the curve.&nbsp; So midpoint is not really the best way to do this.&nbsp; What if we wanted to use any arbitrary <em>t</em>?&nbsp; We could use the general formula above, but that may not be the best choice &ndash; we don&rsquo;t like the cubes and squares so much and while that will give as a point on the curve, it won&rsquo;t let us actually split the curve because we would be missing the new control points.</p>
<p align="left">
	So let&rsquo;s go back to our original midpoint formula and throw it away.&nbsp; Instead of using midpoint, we&rsquo;re going to use the parametric equivalent.&nbsp; So give the T you want, you get P4 by lerping from P0 to P1, you get P5 by lerping from P1 to P2, you get P6 by lerping from P2 to P3.&nbsp; Moving to the next step (red), you get P7 by lerping from P4 to P5, you get P8 by lerping from P5 to P6.&nbsp; Finally, to get P9 by lerping from P7 to P8.&nbsp; In implementation, each lerp is a multiply and two adds.&nbsp; 6 lerps is therefore 6 multiplies and 12 adds, or about 30 instructions.</p>
<p align="left">
	Now if we used the polynomial form each coordinate would be 5 multiplies and 3 adds per coordinate, but we wouldn&rsquo;t have the control points of the new curves and getting them turns out to be more work than just doing all the lerping in the other solution.</p>
<p align="left">
	There are two closely related problems that fall out from this work &ndash;<br />
	<br />
	1. How do I draw a cubic Bézier with the fewest/optimal straight line segments?<br />
	2. What is the length of a cubic Bézier curve?&nbsp;<br />
	<br />
	If you can solve the first problem, you can come up with an approximation for the second.&nbsp; We&rsquo;ll save this for another time, though.</p>
]]></description>
     <pubDate>Fri, 24 May 2013 11:47:08 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2013/how-to-split-a-cubic-bezier-curve]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2013/why-typography-matters]]></guid>
     <title><![CDATA[Tying Things Together: Why Typography Matters]]></title>
     <description><![CDATA[<p>
	Quick &ndash; take a look at this excerpt from a Dr. Seuss book:<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
<br />
<br />
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bec2b1c1-c961-4653-ac62-ce7710634b60"><img alt="ligatures" border="0" height="155" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5d1d5c33-4a15-4732-9c02-771db8047491" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="ligatures" width="604" /></a></p>
<p>
	&nbsp;</p>
<p>
	I took this picture with my phone shortly after reading with my son and found this page particularly jarring.&nbsp; Like many technologies, automated type came from a hand-driven process.&nbsp; Writing used to be hand done until <a href="http://en.wikipedia.org/wiki/Johannes_Gutenberg">Gutenberg</a> and then after, it&rsquo;s been a continual struggle to get technology to be able to create something that can be done by a talented calligrapher.&nbsp; In this case, the problem is ligatures.&nbsp; Ligatures are sets of glyphs that are tied together (ligated) by their shapes.&nbsp; They are necessary because they improve the appearance and readability of a document.&nbsp; <a href="http://www.nikibrown.com/designoblog/2009/02/23/lovely-lovely-ligatures/">Here is a pretty good blog entry</a> on ligatures.</p>
<p>
	Now look back at the Seuss.&nbsp; Here&rsquo;s what I saw immediately (and I am not a typographer):</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6bbc6557-ba76-493d-b698-a006a4125259"><img alt="ffi" border="0" height="187" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=b34a2381-c1e5-4d2d-8567-43e6025c2dba" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ffi" width="154" /></a><a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=4a7d398a-64a0-44c8-9b4e-0bebd6099f02"><img alt="fl" border="0" height="176" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=38a41b45-18c3-4f11-8e6e-fc8a3689edaf" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="fl" width="118" /></a><a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1be5713b-485d-48ed-a7dc-c401040206f5"><img alt="ff" border="0" height="191" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=4591f804-4ea5-4bfa-9577-9dd93a58c7a1" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ff" width="136" /></a></p>
<p>
	which are all pairs which should be replaced with an equivalent ligature.&nbsp; In particular, the fl is bad because of the f just barely touching the l and in the ffi, the dot from the i is almost but not quite hitting the second f.&nbsp; It feels off to me.</p>
<p>
	I first encountered ligatures while I was working on Adobe Acrobat version 1.0.&nbsp; I was assigned the task of &ldquo;fixing&rdquo; the built-in find tool, which as it stood could find a single word in the document and no more.&nbsp; I built it up to handle phrases and text that was perhaps on a curve (which made maps searchable).&nbsp; Working on this tool taught me about ligatures because, for example, that ffi in the document was represented by a single character which may or may not bear any relation to the actual glyph.&nbsp; So the text consuming code had to internally undo the text encoding and then undo the ligature expanding it to something that could be matched, but it had to keep the mapping so that we understood that three characters in the search key might not map to three glyphs on the page for highlighting.&nbsp; It was interesting and as a result my eye has been trained to spot ligatures, or more precisely to spot when ligatures are not there.</p>
<p>
	Here is what the above text looks like with ligatures in place &ndash; I approximated the font.&nbsp; It&rsquo;s not quite right, but it&rsquo;s close enough so you can see the difference</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=fb0a5d19-2a21-4a3e-b885-5275fe570008"><img alt="ligatures" border="0" height="155" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7f6e47d0-a4d8-4059-a8a2-7edf8122e545" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="ligatures" width="604" /></a></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f6935fe1-37bb-406a-9c04-db6a8a17cc26"><img alt="ligatureswith" border="0" height="155" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9a333974-2a67-456a-84b4-3dd2f3039c41" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="ligatureswith" width="604" /></a></p>
<p>
	&nbsp;</p>
<p>
	And to its credit, Photoshop did the ligatures for me as I typed in the text.&nbsp; I&rsquo;m glad that another engineer has had an eye for this detail. I can&rsquo;t wait for this to be better supported on the web.&nbsp; Chrome, Firefox and Safari appear to have support for it on Windows, but not Internet Explorer.</p>
]]></description>
     <pubDate>Fri, 10 May 2013 11:26:31 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2013/why-typography-matters]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/support/february-2013/how-to-give-your-company-a-really-bad-reputation]]></guid>
     <title><![CDATA[How to Give Your Company a Really Bad Reputation]]></title>
     <description><![CDATA[<p>
	<span style="font-size:16px;">Step 1-through-infinity: offer the worst support ever.&nbsp; <em><strong>Nothing</strong></em> can make up for it.</span></p>
<p>
	A little bit of background for those who haven&#39;t read Steve&#39;s latest article. Atalasoft has purchased quite a few of ----------&#39;s (Company That Shall Not Be Named) peripherals over the years, as well as some of us buying them for personal use. &nbsp;In our server room, we have a collection of dead peripherals&nbsp;-- all of them failing in the same manner (the peripheral&nbsp;would fail intermittently, increasing in frequency until it didn&#39;t turn on at all). &nbsp;Steve wrote to ----------, explained the issue in appropriate &quot;that&#39;s why he&#39;s an expert&quot; language, and asked for reasonable suggestions for repair, replacement, or recycling. &nbsp;The response back? &nbsp;There&#39;s a reason why Steve asked, &quot;<em>This is a joke, right?</em>&quot;</p>
<p>
	The response he received from ---------- was the epitome of bad support. &nbsp;Whoever was responsible for it:</p>
<p style="margin-left: 40px;">
	1. Didn&#39;t read the initial email.</p>
<p style="margin-left: 40px;">
	2. Didn&#39;t take the email seriously.</p>
<p style="margin-left: 40px;">
	3. Gave inappropriate (and insulting) advice.</p>
<p>
	Here&#39;s the summary. &nbsp;They gave these troubleshooting directions:</p>
<p style="margin-left: 40px;">
	1. Make sure the computer is on.</p>
<p style="margin-left: 40px;">
	2. Make sure the peripheral&nbsp;is connected.</p>
<p style="margin-left: 40px;">
	3. Try a different cable.</p>
<p style="margin-left: 40px;">
	4. Make sure the laptop can handle this kind of peripheral.</p>
<p style="margin-left: 40px;">
	5. Try a different computer.</p>
<p style="margin-left: 40px;">
	6. If the menu is available, try blah, blah, blah...</p>
<p style="margin-left: 40px;">
	7. Try turning it off and on again.</p>
<p>
	Then, they gave the instructions for sending it back. &nbsp;To add insult, here&#39;s a quote: <em>&quot;I care about your concern and I am glad that you took the time to contact us.&quot;</em></p>
<p>
	Really?</p>
<p>
	The failure here really lies in expectation. &nbsp;Apparently, whomever designed ----------&#39;s support team/department thinks they will save time and money by having a first level, out-of-the-manual response. &nbsp;Honestly, if your support structure is sufficient, you NEVER need someone to read out of a manual. &nbsp;The first line of defense is self-help, and they reference that in the email -- there is a place online where we can go to get troubleshooting tips. &nbsp;If a person takes the time to look up how to contact you and then sends you an in-depth description, chances are they are the kind of user who has tried a number of things already (or they&#39;re too lazy to RTFM, but that&#39;s another article). &nbsp;Also, telling someone to make sure peripherals are on and connected? &nbsp;Seriously? &nbsp;If that&#39;s not the first thing a person checks, they need to put it back in the box and use carrier pigeons.</p>
<p>
	<strong>At Atalasoft,</strong> we try to set an expectation of support that anyone can call us and we take their problem seriously. &nbsp;A recent <a href="http://www.techvalidate.com/tvid/423-0F3-B60" target="_blank">survey</a> by our marketing team let people rate our support in five categories: response time, product knowledge, professionalism, caring about the problem, and self-help options.&nbsp; In most categories, we ranked 89% above average. &nbsp;It&#39;s what makes us a differentiator in our space, and many times it&#39;s why people choose to buy our products.</p>
<p>
	The result of Steve&#39;s emails about the peripherals? &nbsp;He figured out that the problem with each of them could be fixed in about 40 minutes with a piece that costs 28 cents. &nbsp;He also decided that ---------- lost all of his future business, and because of his stature in our company (and others), they also lost business from everyone he influences.&nbsp; <em>That</em> is the price of bad support.<br />
	<br />
	(A followup: I&#39;m not mentioning the name of the company in this article. &nbsp;Why? &nbsp;Because, to reference Carly Simon, if you think this song is about you... it is.)</p>
]]></description>
     <pubDate>Wed, 20 Feb 2013 15:06:23 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/support/february-2013/how-to-give-your-company-a-really-bad-reputation]]></link>
     <dc:creator> Support</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/february-2013/failure-modes]]></guid>
     <title><![CDATA[Failure Modes]]></title>
     <description><![CDATA[<p>
	Software engineering is funny.&nbsp; It shares a lot with Computer Science (which honestly, should be called applied mathematics) and it shares some things with other engineering disciplines.&nbsp; With other engineering disciplines, it shares the need for clear processes for planning projects, managing work, ensuring quality, and handling defects.&nbsp; I say that it shares the <em>need</em> because not every shop actually does all of these things and there is certainly no one good standard for any of these.&nbsp; This is an industry problem.</p>
<p>
	One of the many nice things about being married to a real engineer is that I get to hear a lot about engineering and manufacturing process and one of the things I&rsquo;ve heard her (and other engineers) talk about is <a href="http://en.wikipedia.org/wiki/Failure_mode_and_effects_analysis">FMEA</a>: Failure Mode and Effects Analysis.&nbsp; This is process whereby a component can be analyzed for failure and severity or probability of failure can be reduced or eliminated.&nbsp; This is what I thought of when one of my LCD monitors failed.</p>
<p>
	We believe that engineers work better when there is more screen real estate available to them.&nbsp; We also believe that an investment in a good pair of monitors will pay off in terms of other resources saved.&nbsp; For example, our office supply sales representative asked us in all honesty if we were buying our paper from another source, since we go through very little paper (but a great deal of coffee).&nbsp; We purchased a fair number of these LCD monitors from a well-known consumer electronics manufacturer.&nbsp; In a few years, they started failing.&nbsp; In the past 6 months we have had 4 fail.&nbsp; Every single monitor failed in exactly the same way: the display went blank and the power light went off.&nbsp; After a brief pause, the monitor started back up again.&nbsp; The frequency of failures increase until the monitor fails to work at all.&nbsp; This to me screams of being a very analog problem, probably power related.&nbsp; To date, 68% of our monitors failed this way.</p>
<p>
	I contacted the manufacturer of these monitors to find out if there are replacement parts available, hoping that they would have an FMEA put together with this device that would pick out the likely culprit.&nbsp; I received worse than no help from the manufacturer, but <a href="http://atalasoft.com/blogs/support">Elaine</a> will talk in more detail from a support point of view about what they did wrong and how they could&rsquo;ve done it right.</p>
<p>
	Since I&rsquo;m alone in this I chose to ignore the manufacturer&#39;s lawyers.&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8c89f300-5f6a-4103-8921-20dce85ac737"><img alt="image" border="0" height="50" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=c4e21d01-fa35-4ee3-8c31-7ec79116f69d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="image" width="504" /></a></p>
<p>
	By the way &ndash; unlike this manufacturer, I&rsquo;m going to say that if you&rsquo;re deciding to do this, you should understand the risks. Power supplies in electronic devices can have components that will hold onto a charge long after they&rsquo;ve been shut off. If you&rsquo;re uncomfortable doing something like rewiring parts of your house, listen to your discomfort and don&rsquo;t do this since the charge in a typical power supply cap can give you a nice burn or stop your heart. You know, bad things if you&rsquo;re not appropriately careful.</p>
<p>
	I took the monitor apart and looked over the various boards to see if anything obvious was out of kilter and here&rsquo;s what I found:</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=66a28144-53ad-4b87-8e1e-1439de4f7ee6"><img alt="image" border="0" height="540" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=060f2f13-d77b-440c-b40b-a39a6cc370c0" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="image" width="504" /></a></p>
<p>
	There are three of these capacitors on the board used to drive the <a href="http://en.wikipedia.org/wiki/Cold_cathode">CCFL</a> that is used as a backlight to the LCD display.&nbsp; If you look at the top of the cap, you can see it bulging up.&nbsp; <a href="http://en.wikipedia.org/wiki/Capacitor_plague">This is a sign that this part is failing or has failed</a>.&nbsp; The manufacturer either used the cheapest caps they could find or used underrated parts or both (or heck, even something else).&nbsp; The point is that all three of the capacitors on this board look like this, and I would expect a large consumer electronics manufacturer to know about this, to admit to it, and to have a well-defined process for managing it, as well as to have fixed the problem in later revisions (and I can tell you that the manufacturing dates indicate on our devices that they likely did nothing of the sort).</p>
<p>
	Unfortunately, this part isn&rsquo;t well-marked so I can&rsquo;t tell you what the capacitance or the rating are, but taking a guess, this particular part probably cost them a few cents in quantity, whereas a higher quality part would have cost roughly 10 cents in quantity.&nbsp; So someone looked at the design and chose an off-brand manufacturer for the part in order to save 25 cents on the assembly.</p>
<p>
	The actual cost of this problem was probably far higher in terms of in-warrantee repairs.&nbsp; Sadly, the most costly loss to this manufacturer is in terms of customer loyalty.&nbsp; I had a CRT from the same manufacturer that I used for 10 years before replacing it with a smaller footprint, less power-hungry LCD.&nbsp; That CRT looked every bit as good on the last day as it did on the first day.&nbsp; The shoddy quality of these LCD devices and the especially poor customer service is such that<strong> I will never purchase another product from this manufacturer again</strong> and if I have a say in the matter, I will strongly discourage anyone I know or work for from purchasing their products.</p>
<p>
	By comparison, I have a workstation made by another well-known consumer electronics manufacturer on my desk which I use for my day-to-day work.&nbsp; The computer shut down without warning.&nbsp; We reported this to the manufacturer and even though it was out of warrantee, they sent us a replacement motherboard and power supply which arrived the very next day.&nbsp; When we replaced the board, we noted that the bad motherboard had several capacitors that were bulged up.&nbsp; The replacement motherboard had caps made by a different manufacturer.</p>
<p>
	And while a desktop workstation is a different beast than a monitor, the desktop manufacturer demonstrated that the proper way to handle this type of problem is with alacrity not with incompetence.</p>
]]></description>
     <pubDate>Tue, 19 Feb 2013 14:41:27 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/february-2013/failure-modes]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/being-lazy-is-a-virtue]]></guid>
     <title><![CDATA[Being Lazy is a Virtue]]></title>
     <description><![CDATA[<p>
	One of the things that I admire in solid programmers is laziness.&nbsp; Some programmers will go to extreme lengths to avoid doing certain classes of work and frankly, I can&rsquo;t blame them really.&nbsp; For example, if you need to have a set of look up tables in code from some specification, you could just pull of the spec and start typing in the tables.&nbsp; A clever programmer will look at the task and start asking the following questions:</p>
<ol>
	<li>
		How much typing will each entry in the table take (and by extension, how long will the whole task take)?</li>
	<li>
		How many mistakes will I make just typing?</li>
	<li>
		How long will it take to find all of them?</li>
	<li>
		How long will it take to fix all of them?</li>
	<li>
		How irate will my customers get because of 3 and 4?</li>
</ol>
<p>
	When 1 gets measured in any units greater than &lsquo;minutes&rsquo; and 3 gets measured in units of days to years, a very clever programmer will also ask, &ldquo;how can I automate this?&rdquo;</p>
<p>
	This week I was looking at creating a number of tables (22 in all), each of which had somewhere around 200 entries in them.&nbsp; That&rsquo;s around 4000-4800 entries to type in.&nbsp; Yuck.&nbsp; That&rsquo;s easily 3 days of typing and the number of mistakes would probably be about 10%, which would easily be another day to catch 95% of those errors and weeks for the rest.</p>
<p>
	Enter the robot.</p>
<p>
	First trick, look at your source data and see if you can easily parse it.&nbsp; For example, I needed to parse Adobe Font Metrics files and <a href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5004.AFM_Spec.pdf">the spec is blissfully simple</a>.&nbsp; It&rsquo;s mostly a collection of one key/value pair per line as well as a set of separately subsection with differently formatted key/value pairs, several per line.&nbsp; In this case, I decided to put reflection to work for me, since all of the keys overlapped the set of names allowed in .NET object properties.&nbsp; On top of that, the tokenization can be done with String.Split().&nbsp; I&rsquo;m already on board.&nbsp; Here&rsquo;s the guts of the parsing code:</p>
<pre class="code">
</pre>
<pre class="code">
<span style="color: #0000ff">while</span> (<span style="color: #0000ff">true</span>)
</pre>
<pre class="code">
{
</pre>
<pre class="code">
    <span style="color: #0000ff">string</span> line = reader.ReadLine();
</pre>
<pre class="code">
    <span style="color: #0000ff">if</span> (line == <span style="color: #0000ff">null</span>)
</pre>
<pre class="code">
        <span style="color: #0000ff">break</span>;
</pre>
<pre class="code">
    <span style="color: #0000ff">string</span>[] pieces = line.Split(<span style="color: #0000ff">new</span> <span style="color: #0000ff">char</span>[] { &#39; &#39;, &#39;\t&#39; }, StringSplitOptions.RemoveEmptyEntries);
</pre>
<pre class="code">
    <span style="color: #0000ff">if</span> (pieces.Length == 0)
</pre>
<pre class="code">
        <span style="color: #0000ff">continue</span>;
</pre>
<pre class="code">
    <span style="color: #0000ff">string</span> delimeter = pieces[0];
</pre>
<pre class="code">
    <span style="color: #0000ff">switch</span> (delimeter)
</pre>
<pre class="code">
    {
</pre>
<pre class="code">
        <span style="color: #0000ff">case</span> &quot;<span style="color: #8b0000">StartCharMetrics</span>&quot;:
</pre>
<pre class="code">
            ParseCharMetrics(metrics, reader, GetInteger(pieces[1]));
</pre>
<pre class="code">
            <span style="color: #0000ff">break</span>;
</pre>
<pre class="code">
        <span style="color: #0000ff">default</span>:
</pre>
<pre class="code">
            SetProperty(metrics, delimeter, pieces);
</pre>
<pre class="code">
            <span style="color: #0000ff">break</span>;
</pre>
<pre class="code">
    }
</pre>
<pre class="code">
    <span style="color: #0000ff">if</span> (line == <span style="color: #0000ff">null</span>)
</pre>
<pre class="code">
        <span style="color: #0000ff">break</span>;
</pre>
<pre class="code">
}
</pre>
<pre class="code">
</pre>
<p>
	SetProperty is very simple &ndash; it just looks for a property named by delimeter with a setter and when it finds it type coerces the string value to the property type and sets it.&nbsp; Most of the conversion is done with System.Convert, which is easy.</p>
<p>
	For the main AFM file, I project the data onto an object that looks like this:</p>
<pre class="code">
</pre>
<pre class="code">
<span style="color: #0000ff">class</span> GlobalFontMetrics
</pre>
<pre class="code">
{
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FontName { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FullName { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FamilyName { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Weight { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span>[] FontBBox { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Version { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Notice { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> EncodingScheme { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> MappingScheme { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> EscChar { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> CharacterSet { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Characters { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> IsBaseFont { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span>[] VVector { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> IsFixedV { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> CapHeight { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> Ascender { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> Descender { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> StdHW { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> StdVW { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> XHeight { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
}
</pre>
<p>
	Now, all of this code is scaffolded into my unit tests and the output of each test is one or more .cs file containing code that constructs the tables from the AFM data. These source files are then added into the main project &ndash; but not automatically.</p>
<p>
	Now, suppose that you have source data that isn&rsquo;t quite so easy to parse as AFM files.&nbsp; In my case I needed to build encoding tables for the various supported standard encodings in PDF, including StandardEncoding, MacRomanEncoding, and WinAnsiEncoding.&nbsp; These are listed out in the spec as tables.&nbsp; Fortunately, I could copy them within Acrobat and then paste them into Excel.&nbsp; From Excel, I ran a set of functions that transformed the data into abbreviated lists that I could use and then was able to turn that into C# with a handful of regular expressions.&nbsp; This is not as ideal as the tables are not as easily reproducible, but hopefully this won&rsquo;t have to be done again.</p>
<p>
	All in all, the code and Excel chicanery took me two days to implement, verify, and unit test, far less than just typing in the tables and I&rsquo;m far more confident that the data is correct.</p>
]]></description>
     <pubDate>Wed, 30 Jan 2013 13:18:03 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/being-lazy-is-a-virtue]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/atalasoft-general/january-2013/atalasoft-version-10-3-released]]></guid>
     <title><![CDATA[Atalasoft 10.3 Released - Major Version Includes Mobile Annotations]]></title>
     <description><![CDATA[<p style="font-size: 12px;">
	<span style="font-size: 14px;">Hello!</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">This time, we have lots of exciting updates across our entire suite of SDKs including new mobile support, index fields, and more. Who&#39;s ready to learn more? Let&#39;s dig in.</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">Quick Introduction to New Features in 10.3</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">Atalasoft&#39;s VP of Product Development gives us a quick run-down of what to expect in 10.3. (Running time: 1:29)</span></p>
<p style="font-size: 12px; text-align: center;">
	<br />
	<iframe width="640" height="360" src="http://www.youtube.com/embed/rA7pNWBBwPo" frameborder="0" allowfullscreen></iframe><br />
	<span style="font-size: 14px;"><strong><a href="https://www.youtube.com/watch?v=rA7pNWBBwPo" title="Watch the 10.3 Overview Video">Watch the overview video. </a></strong><a href="https://www.youtube.com/watch?v=rA7pNWBBwPo" title="Watch the 10.3 Overview Video">Subtitles and 1080p available.</a></span></p>
<p style="font-size: 12px; text-align: center;">
	&nbsp;</p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">Build Mobile Document Viewers w/Annotations<br />
	&nbsp;</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">This is two-fold: The DotImage Web Document Viewer controls are now supported on iOS Mobile Safari and Android&#39;s Chrome <strong>mobile browsers</strong>. This also includes <strong>annotation support</strong> with touch interfaces, zooming, pagination, and more. Your users can interact with multipage docs on the run.</span></p>
<p style="font-size: 12px; text-align: center;">
	<span style="font-size: 14px;"><a href="mailto:eric@atalasoft.com&amp;subject=Mobile%20WDV%20Annotations">Contact for a demo</a></span></p>
<p style="font-size: 12px; text-align: center;">
	&nbsp;</p>
<p style="font-size: 12px;">
	&nbsp;</p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">PDF Generation updates</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">In DotPdf, you can now import SVG drawings as well as make use of the new TableShape so you can add tabular data to any PDF. Generate invoices with full control over the template.</span></p>
<p style="font-size: 12px; text-align: center;">
	<span style="font-size: 14px;"><a href="http://www.atalasoft.com/products/dotpdf/">Learn about DotPdf</a></span></p>
<p style="font-size: 12px; text-align: center;">
	&nbsp;</p>
<p style="font-size: 12px;">
	&nbsp;</p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">Java Barcode Reader Add-on<br />
	&nbsp;</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">Our Java SDK (JoltImage) now supports the same <strong>1-D and 2-D barcode</strong> sets that our .NET equivalent has. Automatically detect the orientation of the recognized barcode, return a bounding polygon, and get the string value of a barcode. Use this add-on for your server or desktop Java apps.</span></p>
<p style="font-size: 12px; text-align: center;">
	<span style="font-size: 14px;"><a href="http://www.atalasoft.com/products/joltimage/barcode-reader" title="JoltImage Barcode Reader Addon">Learn about JoltImage Barcode Reader</a></span></p>
<p style="font-size: 12px; text-align: center;">
	&nbsp;</p>
<p style="font-size: 12px;">
	&nbsp;</p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">Scan from the web and manually index to SharePoint<br />
	&nbsp;</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">DotImage can now read in the index fields associated with a repository and content type from <strong>SharePoint</strong> or Kofax Capture. You can then edit them, and include their values on the import. We do most of the work for you. Ask to see a live demo today.</span></p>
<p style="font-size: 12px; text-align: center;">
	<span style="font-size: 14px;"><a href="http://www.atalasoft.com/products/wingscan">Learn about WingScan</a> |&nbsp;<a href="mailto:eric@atalasoft.com&amp;subject=WingScan%20web%20Scanning">Contact for a demo</a></span></p>
<p style="font-size: 12px; text-align: center;">
	&nbsp;</p>
<p style="font-size: 12px;">
	&nbsp;</p>
<p style="font-size: 12px;">
	<span style="font-size: 22px;">Bug fixes<br />
	&nbsp;</span></p>
<p style="font-size: 12px;">
	<span style="font-size: 14px;">We&#39;ve fixed a bunch of bugs including PDF handling, serializable commands, and with web annotations. Call our support team if you run into any trouble; we&#39;re constantly working on our products and working with our users.</span></p>
<p style="font-size: 12px; text-align: center;">
	<span style="font-size: 14px;">See the release notes at atalasoft.com</span></p>
<p style="font-size: 12px;">
	&nbsp;</p>
<p>
	<span style="font-size: 14px;">If you&#39;d like to upgrade or learn more, visit us at <a href="http://www.atalasoft.com" title="Atalasoft Imaging SDKs">www.atalasoft.com</a></span></p>
<p>
	&nbsp;</p>
]]></description>
     <pubDate>Mon, 14 Jan 2013 17:20:35 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/atalasoft-general/january-2013/atalasoft-version-10-3-released]]></link>
     <dc:creator> Atalasoft General</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/how-to-manage-temporary-files]]></guid>
     <title><![CDATA[How to Manage Temporary Files]]></title>
     <description><![CDATA[<p>
	If you&rsquo;ve written software to manipulate large chunks of data, you&rsquo;ve likely created temporary files to hold the data for you. And if you&rsquo;re like me, your machine currently has 2587 files in your personal Temp folder. Why? Chances are there are a ton of apps on your system that are Doing It Wrong. I&rsquo;m going to talk about how most apps do this, how it goes horribly wrong, and what you can do to mitigate this problem for your own code.</p>
<p>
	Most apps will get the path to the Temp folder and run a loop creating files based on time stamp or time stamp followed by iteration until they succeed in making a new file. This path (or stream) gets used in the application in some manner and at some point in the future it will get removed. And you can bet that it&rsquo;s the last step where applications screw up &ndash; they don&rsquo;t (or can&rsquo;t) clean up after themselves.</p>
<p>
	If you&rsquo;re using Path.GetTempFileName(), stop. Seriously. Just stop using it. It&rsquo;s not appropriate. It tries to create a file in the form tmpXXXX.tmp, where XXXX is a 4 digit hex number. This is not appropriate for a couple reasons. First, in my own folder, there are currently 2516 files that match that pattern. In other words, 2516/65536 or 3.8% of the files are already in use and I swear I cleaned out that folder a couple months ago. In short order, it will fill up. Further, every nth call will take longer, as the first n-1 tries to make the file will fail. On top of that, there is no infrastructure to take care of the temporary file when you&rsquo;re done with it. The developer is responsible for removing it and we know how well developers remember to do things.</p>
<p>
	This is a resource problem: a limited number of slots and responsibility to get and release the resource is in the hands of the developer. When you approach this as a resource problem, it becomes a whole lot harder to screw up.</p>
<p>
	So let&rsquo;s set a few goals for this task. This code should be:</p>
<ul>
	<li>
		Easy to use</li>
	<li>
		Hard to screw up</li>
	<li>
		Customizable</li>
	<li>
		Better than Path.GetTemporaryFile()</li>
</ul>
<p>
	So let&rsquo;s start with a TemporaryFile object. This is what is going to hold your information about the temporary file. There are a number of ways this could be structured to be more flexible (like a template base class wherein subclasses could be any Stream instead of a FileStream), but it&rsquo;s called Temporary<strong>File</strong> not Temporary<strong>Stream</strong>, so let&rsquo;s keep it simple. Here is TemporaryFile:</p>
<pre>
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> TemporaryFile : IDisposable
</pre>
<pre class="code">
    {
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> TemporaryFile(<span style="color: #0000ff">string</span> path)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (path == <span style="color: #0000ff">null</span>)
</pre>
<pre class="code">
                <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(&quot;<span style="color: #8b0000">path</span>&quot;);
</pre>
<pre class="code">
            Path = path;
</pre>
<pre class="code">
            TemporaryStream = <span style="color: #0000ff">new</span> FileStream(path, FileMode.Create);
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> Stream TemporaryStream { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Path { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">string</span> ToString()
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">return</span> Path;
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">bool</span> _disposed = <span style="color: #0000ff">false</span>;
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Dispose()
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            Dispose(<span style="color: #0000ff">true</span>);
</pre>
<pre class="code">
            GC.SuppressFinalize(<span style="color: #0000ff">this</span>);
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> Dispose(<span style="color: #0000ff">bool</span> disposing)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (!_disposed)
</pre>
<pre class="code">
            {
</pre>
<pre class="code">
                <span style="color: #0000ff">if</span> (disposing)
</pre>
<pre class="code">
                {
</pre>
<pre class="code">
                    TemporaryStream.Dispose();
</pre>
<pre class="code">
</pre>
<pre class="code">
                    File.Delete(Path);
</pre>
<pre class="code">
                }
</pre>
<pre class="code">
                _disposed = <span style="color: #0000ff">true</span>;
</pre>
<pre class="code">
            }
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        ~TemporaryFile()
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            Dispose(<span style="color: #0000ff">false</span>);
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
    }
</pre>
<pre class="code">
</pre>
<p>
	In this case, I chose to make the class itself immutable and Disposable. As it stands you could use this class as a wrapper around the result from Path.GetTemporaryFile(), but we&rsquo;ll do better than that. Remember that TemporaryFile is a <strong>resource</strong> and if that&rsquo;s the case, it should be IDisposable. We want to do something very specific when the file is closed.&nbsp; So following the pattern in <a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2006/09/21/10887.aspx">IDisposable Made E-Z</a>, I&rsquo;ve made this class do a few things: open the file on construction and on disposal dispose the TemporaryStream and delete the path. According to <a href="http://msdn.microsoft.com/en-us/library/system.io.stream.close.aspx">the spec for Stream.Close()</a>, it is not necessary to call Close() but to instead ensure that Stream.Dispose() gets called. If either Stream.Dispose() or File.Delete() throw an exception, you probably have worse problems on your hands. If you wanted you could add an implementation of Equals and GetHashCode. I chose not to since pointer equality should be good enough.</p>
<p>
	Where possible, TemporaryFile objects should be scoped within a using() block to ensure they get disposed in a timely manner, otherwise you have to pray that the GC will help you out at the end of app life.</p>
<p>
	We&rsquo;re not done yet &ndash; as mentioned before, Path.GetTempFileName() gets worse the more you use it. We can fix that too. Also the filenames it generates are not so good in that we can&rsquo;t fingerprint them as our own so that we can check at a glance that we&rsquo;re leaking temp files or better yet, write a unit test to take care of them. So how do you make a TemporaryFile? Use a factory:</p>
<pre>
</pre>
<pre class="code">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> TemporaryFileFactory
</pre>
<pre class="code">
    {
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> kDefaultPrefix = &quot;<span style="color: #8b0000">Tmp</span>&quot;;
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> kDefaultSuffix = &quot;&quot;;
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> kDefaultExtension = &quot;<span style="color: #8b0000">tmp</span>&quot;;
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">int</span> kDefaultRetries = 10;
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> TemporaryFile MakeTemporaryFile(<span style="color: #0000ff">string</span> extension) { <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TemporaryFileFactory(<span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>, extension, kDefaultRetries).MakeTemporaryFile(); }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> TemporaryFileFactory(<span style="color: #0000ff">string</span> tempFolder, <span style="color: #0000ff">string</span> prefix, <span style="color: #0000ff">string</span> suffix, <span style="color: #0000ff">string</span> extension, <span style="color: #0000ff">int</span> retries)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (retries &lt;= 0) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentOutOfRangeException(&quot;<span style="color: #8b0000">retries</span>&quot;);
</pre>
<pre class="code">
            Retries = retries;
</pre>
<pre class="code">
            TempFolder = String.IsNullOrEmpty(tempFolder) ? Path.GetTempPath() : tempFolder;
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (!Directory.Exists(TempFolder))
</pre>
<pre class="code">
                <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> IOException(String.Format(&quot;<span style="color: #8b0000">Temporary folder &#39;{0}&#39; does not exist</span>&quot;, tempFolder));
</pre>
<pre class="code">
            Prefix = String.IsNullOrEmpty(prefix) ? kDefaultPrefix : prefix;
</pre>
<pre class="code">
            Suffix = suffix ?? kDefaultSuffix;
</pre>
<pre class="code">
            Extension = SanitizeExtension(extension ?? kDefaultExtension);
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">string</span> SanitizeExtension(<span style="color: #0000ff">string</span> ext)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (ext.EndsWith(&quot;<span style="color: #8b0000">.</span>&quot;))
</pre>
<pre class="code">
                ext = ext.Substring(0, ext.Length - 1);
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (ext.StartsWith(&quot;<span style="color: #8b0000">.</span>&quot;))
</pre>
<pre class="code">
                ext = ext.Substring(1);
</pre>
<pre class="code">
            <span style="color: #0000ff">if</span> (ext.Length == 0)
</pre>
<pre class="code">
                ext = kDefaultExtension;
</pre>
<pre class="code">
            <span style="color: #0000ff">return</span> ext;
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> TempFolder { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Prefix { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Suffix { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Extension { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Retries { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">private</span> <span style="color: #0000ff">set</span>; }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">public</span> TemporaryFile MakeTemporaryFile()
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; Retries; i++)
</pre>
<pre class="code">
            {
</pre>
<pre class="code">
                <span style="color: #0000ff">string</span> path = GenerateTemporaryPath(i);
</pre>
<pre class="code">
                <span style="color: #0000ff">if</span> (!File.Exists(path))
</pre>
<pre class="code">
                    <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TemporaryFile(path);
</pre>
<pre class="code">
            }
</pre>
<pre class="code">
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> IOException(String.Format(&quot;<span style="color: #8b0000">Unable to create temporary file in {0} after {1} {2}.</span>&quot;, TempFolder, Retries, (Retries == 1 ? &quot;<span style="color: #8b0000">try</span>&quot; : &quot;<span style="color: #8b0000">tries</span>&quot;)));
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> kDefaultFormat = &quot;<span style="color: #8b0000">{0}{1}{2}.{3}</span>&quot;;
</pre>
<pre class="code">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">string</span> GenerateTemporaryPath(<span style="color: #0000ff">int</span> retry)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            Guid g = Guid.NewGuid();
</pre>
<pre class="code">
            <span style="color: #0000ff">string</span> newPath = Path.Combine(TempFolder, String.Format(kDefaultFormat, Prefix, g.ToString(&quot;<span style="color: #8b0000">N</span>&quot;), Suffix, Extension));
</pre>
<pre class="code">
            <span style="color: #0000ff">return</span> newPath;
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
    }
</pre>
<pre class="code">
</pre>
<p>
	In this case, we&rsquo;re making the factory easy to use if you don&rsquo;t care about the file name format and easy to customize if you do. The first thing you should know is that I&rsquo;m defining the format of a temporary file name this way &ndash; &lt;Prefix&gt;&lt;content&gt;&lt;Suffix&gt;.&lt;Extension&gt;. The defaults are such that you should get Tmp&lt;content&gt;.tmp for your temporary file. There is a main constructor that takes values for Prefix and Suffix and Extension and defaults them if they are null (or in some cases null or empty). The constructor also takes a path to the folder you want to use for temporary files, but you can also set this to null and it will use Path.GetTempPath() instead. The question is, what should go in the &lt;content&gt; part of the file? Why not use a <a href="http://en.wikipedia.org/wiki/Globally_unique_identifier">GUID</a>? Just from the definition, I&rsquo;m fairly certain that I only have to check once to see if the path will exist since the GUID should be unique by definition. Still, GenerateTemporaryPath() was made virtual so you could override if this doesn&rsquo;t suit your particular needs. GenerateTemporaryPath() includes a retry number, so you could reimplement Path.GetTempFileName if you wanted to (but why?). There&rsquo;s some basic error checking/patching to mitigate pilot error in SanitizeExtension() and finally a nice static factory method that <a href="http://atalasoft.com/blogs/stevehawley/november-2012/jargon">news up</a> a factory for you with defaults and generates a TemporaryFile for you. Here&rsquo;s my test code:</p>
<pre>
</pre>
<pre class="code">
        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)
</pre>
<pre class="code">
        {
</pre>
<pre class="code">
            List&lt;<span style="color: #0000ff">string</span>&gt; files = <span style="color: #0000ff">new</span> List&lt;<span style="color: #0000ff">string</span>&gt;();
</pre>
<pre class="code">
</pre>
<pre class="code">
            <span style="color: #0000ff">try</span>
</pre>
<pre class="code">
            {
</pre>
<pre class="code">
                <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 20; i++)
</pre>
<pre class="code">
                {
</pre>
<pre class="code">
                    <span style="color: #0000ff">using</span> (TemporaryFile tf = TemporaryFileFactory.MakeTemporaryFile(<span style="color: #0000ff">null</span>))
</pre>
<pre class="code">
                    {
</pre>
<pre class="code">
                        files.Add(tf.Path);
</pre>
<pre class="code">
                        Console.WriteLine(&quot;<span style="color: #8b0000">Created </span>&quot; + tf.Path);
</pre>
<pre class="code">
                        <span style="color: #0000ff">if</span> (i &gt; 18)
</pre>
<pre class="code">
                            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> Exception(&quot;<span style="color: #8b0000">no purpose</span>&quot;);
</pre>
<pre class="code">
                    }
</pre>
<pre class="code">
                }
</pre>
<pre class="code">
            }
</pre>
<pre class="code">
            <span style="color: #0000ff">catch</span> { }
</pre>
<pre class="code">
            <span style="color: #0000ff">finally</span>
</pre>
<pre class="code">
            {
</pre>
<pre class="code">
                <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> path <span style="color: #0000ff">in</span> files)
</pre>
<pre class="code">
                {
</pre>
<pre class="code">
                    <span style="color: #0000ff">if</span> (File.Exists(path))
</pre>
<pre class="code">
                        Console.WriteLine(&quot;<span style="color: #8b0000">error - file </span>&quot; + path + &quot;<span style="color: #8b0000"> still exist.</span>&quot;);
</pre>
<pre class="code">
                }
</pre>
<pre class="code">
            }
</pre>
<pre class="code">
        }
</pre>
<pre class="code">
</pre>
<p>
	which demonstrates how to make TemporaryFiles using the static factory method within a using and throws an exception for no other reason than to demonstrate the IDisposable does what it says on the box.</p>
<p>
	From an architecture point of view, this is good enough. It could be slightly cleaner and if I were to make any changes at all, I might put the static factory method(s) inside of TemporaryFile instead of TemporaryFileFactory, then I would call the methods Create(). If I wanted to hide the implementation details of TemporaryFile, I would probably make an interface ITemporaryStream and only put the TemporaryStream property in it. Then if you wanted to use a MemoryStream based factory you could. I think this is poor decision for a few reasons:</p>
<ul>
	<li>
		Temporary files are well established in the art</li>
	<li>
		MemoryStreams (or other streams) don&rsquo;t have the same need for a file deletion as a FileStream and fall outside of our problem domain</li>
	<li>
		It would necessitate either a factory for specific file streams</li>
	<li>
		Existing code isn&rsquo;t always .NET Stream compatible (for example, a C library that needs a path)</li>
</ul>
<p>
	So you see that by looking at the task as a resource problem rather than a temporary file problem, we can make a solution that is as easy to use and more resilient.</p>]]></description>
     <pubDate>Wed, 09 Jan 2013 14:09:30 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/how-to-manage-temporary-files]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/what-does-it-take-to-be-a-software-developer]]></guid>
     <title><![CDATA[What Does It Take To Be A Software Developer?]]></title>
     <description><![CDATA[<p>
	I saw <a href="http://ask.metafilter.com/232409/Math-major-wants-to-be-a-software-developer">this question</a> on <a href="http://www.metafilter.com/">Metafilter</a> about what CS courses are necessary to be a software developer and thought I would take the opportunity to expound a bit.</p>
<p>
	The first non-useful answer is: all of it.&nbsp; I went to <a href="http://new.oberlin.edu/">Oberlin</a>, a college that only grants arts degrees, and received a degree in computer science.&nbsp; In that time, I also took classes in religion, ethnomusicology, physics, media, anthropology, and so on.&nbsp; Anything that seemed interesting and I could schedule, I tried to take. I honestly believe in the value of breadth in many things and depth in a few things.&nbsp; The value is especially apparent in software where solutions frequently need to be tailored to the problem domain and the possible number of domains that can be addressed effectively with software grows daily.&nbsp; If you know about a wide number of things, you can better tailor solutions to those domains.&nbsp; Being a lifelong learner makes it easier to learn new problem domains.</p>
<p>
	The second answer, more useful perhaps, is the following.</p>
<p>
	<strong>An intro class in a high-level language </strong>&ndash; you&rsquo;ll probably find classes taught in Java, C#, Python, Ruby, or C++.&nbsp; My first CS class in college was in Pascal.&nbsp; If you already know a HLL, it&rsquo;s still worthwhile, especially if it&rsquo;s a different language.&nbsp; In fact, you might want to look at the entire course book to see if all the classes are taught in only one or two languages.&nbsp; That&rsquo;s a bad sign, especially for a budding software developer where you should <em>expect</em> to need to learn a new language every few years.&nbsp; I know more than 20 and it is a career skill to pick up a new one in short order.</p>
<p>
	<strong>A class in algorithms and analysis</strong> &ndash; this is probably the one that I touch on the most without ever really having to crack a book (I do keep the textbook in my office in case), just for the ability to analyze the best, worst and average cases of code I write.&nbsp; I have encountered code in the wild that search for the first/next instance of a string in a stream that was O(<em>n!</em>) &ndash; easy to spot if you know what to look for.</p>
<p>
	<strong>A class in design patterns</strong> &ndash; I don&rsquo;t know if this is in any college curriculum, but when I started my professional career, there weren&rsquo;t any formal design patterns.&nbsp; They were informal and maybe differently named from shop-to-shop.&nbsp; I did discover that many of us had invented the same things just to get a job done and the wise ones abstracted them just enough to be able to apply them in many circumstances while keeping them nimble (for example, I had a tight library that was built around the <a href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a> pattern which was the basis for an entire UI toolkit.</p>
<p>
	<strong>A class in system architecture</strong> &ndash; in my day, this was called assembly, but I believe that a good solid understanding of the hardware underneath your computer is key to making good high level decisions as well as making you a far better debugger.&nbsp; It is also necessary for writing a compiler.</p>
<p>
	<strong>The Scheme/Functional class</strong> &ndash; if you&rsquo;re lucky, your department will have a Scheme zealot.&nbsp; I&rsquo;ll be honest, I hated Scheme.&nbsp; I&rsquo;m a very concrete/practical programmer by nature and Scheme drove me crazy.&nbsp; Not because I didn&rsquo;t understand it &ndash; I did.&nbsp; It drove me nuts how fluffy the language was in terms for how it worked and how code I wrote would stall for chunks of time while the garbage collector went to work to get rid of all the things I allocated that I couldn&rsquo;t prevent.&nbsp; I swear I was the worst offender of using set! and its variants in my code just to avoid wasting time/memory.&nbsp; Still, in spite of the structural language deficiencies, it is a fabulous language for getting you to stop thinking about problems sequentially.</p>
<p>
	<strong>A class in compilers</strong> &ndash; this was my hardest class, I think.&nbsp; I flunked it.&nbsp; But it was the most valuable class for learning how to debug a high level language from the lowest level.&nbsp; You should get to the point where you can look at machine generated assembly language and mentally decompile it into the HLL that made it.&nbsp; For example, I had a third party library that worked most of the time, but crashed at other times.&nbsp; It turns out that they were using C enums in size-dependent data structure and their compiler chose one size for the enum and my compiler chose a different size.&nbsp; Without being able to understand what a compiler would have done with code to operate on structs that contained this enum, I would&rsquo;ve been dead in the water.&nbsp; I run into this kind of thing All. The. Time.</p>
<p>
	<strong>A class in operating systems</strong> &ndash; and by extension, this class should cover concurrency and resource management.&nbsp; You&rsquo;re writing code and you&rsquo;re running it on what now?&nbsp; You should understand how an operating system works, how to write device drivers, and especially concurrency.&nbsp; When every machine, including your phone, is shipping with a couple cores, you should understand how to best leverage concurrent programming.</p>
<p>
	Beyond that, everything else is gravy.&nbsp; Also consider a writing class of some kind. Clear communication is vital and it <em>is</em> one of the things that I use to pick a new hire.</p>
]]></description>
     <pubDate>Mon, 07 Jan 2013 14:52:47 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2013/what-does-it-take-to-be-a-software-developer]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/december-2012/merry-christmas-and-happy-holidays-from-atalasoft]]></guid>
     <title><![CDATA[Merry Christmas and Happy Holidays from Atalasoft]]></title>
     <description><![CDATA[<p>
	For the last several years, we&rsquo;ve hosted a Secret Docubot event at Atalasoft.&nbsp; This year, we combined the annual Docubot festivities with a bacon day.&nbsp; Now as I sit back at my desk, trying to concentrate in the face of a food coma, I thought I&rsquo;d present you with some pictures I took during the festivities:</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=c07da319-e6ab-461d-8608-f6fa056de4b2"><img alt="012" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7df42d88-dfd7-4a7f-a504-98b386c3af50" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="012" width="644" /></a></p>
<p align="center">
	Hi!&nbsp; I&rsquo;m bacon!</p>
<p>
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=c4f6319a-31e2-448d-865f-b7bc1884dba3"><img alt="002" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=fe3c926e-0ecc-41dd-bffd-8563e6d8e8eb" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="002" width="644" /></a></p>
<p align="center">
	We bought a grill to keep in the office.&nbsp; This one is much larger.&nbsp; It&rsquo;s loaded up with two pounds of thick cut pepper bacon from <a href="http://www.smokehouse.com">Burger&rsquo;s Smokehouse</a>.</p>
<p align="center">
	By the way, their Cajun Steak Cut bacon was awesome.&nbsp; See that jar there?&nbsp; Rick G. claims it&rsquo;s moonshine.&nbsp; I don&rsquo;t know how he got it.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6b5a258e-cda6-4a27-9c1b-03171c77f76a"><img alt="009" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8e547902-a06a-44d1-8c73-72f26ca06720" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="009" width="644" /></a></p>
<p align="center">
	Yes, that&rsquo;s a donut.&nbsp; Yes, we eat dangerously.&nbsp; Just not every day.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=09ab3b0a-4700-436c-9f9a-3af502bb5821"><img alt="011" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e0ce4c90-5663-477b-b972-c4bbe61a7d5d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="011" width="644" /></a></p>
<p align="center">
	Sadly, as delicious as it looks, it didn&rsquo;t taste that great &ndash; it tasted like a hot, extra greasy donut.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=2194b2d3-3d2f-44d9-9877-f03ff1e25f09"><img alt="017" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=cd530618-bc40-4b8c-9352-4da06b065175" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="017" width="644" /></a></p>
<p align="center">
	Elaine and her animatronic hat.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=71869dbd-c05a-43ca-ae71-a790e4b9274d"><img alt="025" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6da32ead-e6d3-4079-bf2c-644511cbe9de" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="025" width="644" /></a></p>
<p align="center">
	Rick C. opening Docubot gifts.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dceda819-2028-4086-a113-caffd9e194bf"><img alt="030" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=4a6513ac-9a22-4ea7-bf35-6dfb2bc6621c" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="030" width="644" /></a></p>
<p align="center">
	Engineering Kevin preparing to shuffle.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=43980a72-d7b0-48d0-8877-b5776585efdd"><img alt="015" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8f371817-5042-4d8d-838e-e9d15bfeca2f" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="015" width="644" /></a></p>
<p align="center">
	Marco conferenced in.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=733ef212-8148-406c-be50-b0b938c75087"><img alt="036" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=29394b15-c26c-4964-85c7-db93fedf1cb1" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="036" width="644" /></a></p>
<p align="center">
	Asia with morning coffee.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=4c5f43b0-9976-4f3f-8175-3012434a4289"><img alt="032" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=0b9b6992-4910-4375-8e7e-c812a95fd796" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="032" width="644" /></a></p>
<p align="center">
	Lou recreated Eric&rsquo;s tragic dodge ball accident</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8c318f27-1322-4fc8-b940-7e91d96d1053"><img alt="020" border="0" height="484" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ca9bcc21-a4e7-4288-8f27-a098b3f48481" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="020" width="644" /></a></p>
<p align="center">
	Eric, clearly excited to open his Docubot gift.</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f3ee94a8-30f6-4689-ae36-0784f2d83ecd"><img alt="007" border="0" height="218" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f77526de-6171-4c97-b40a-385fbb14587c" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="007" width="644" /></a></p>
<p align="center">
	Yes. Yes you are.</p>
]]></description>
     <pubDate>Fri, 21 Dec 2012 12:24:04 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/december-2012/merry-christmas-and-happy-holidays-from-atalasoft]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/atalasoft-general/december-2012/have-a-happy-new-year-not-end-of-years]]></guid>
     <title><![CDATA[Have a Happy New Year... Not End of Years!]]></title>
     <description><![CDATA[<br />
<h2>
	December 21 is coming...so what!</h2>
<p>
	December 21 of this year marks the end of the Mayan Calendar. It does not, however, mark the end of the world as your Facebook friends will soon tell you! In fact, there are still Maya around today and they believe December 21 actually marks the start of a new era. Think of it like a Mayan New Year&#39;s Eve celebration...except it only happens every 52,000 years. The calendar ends and then is &quot;restarted.&quot; What? A calendar that ends and then starts again? Sounds familiar to me - and on a day that&#39;s shared with my wedding anniversary, I would rather not have a going-away party; I&#39;d rather think of it as a Mayan time for renewal and reflection. That said,...</p>
<h2>
	Thank you.</h2>
<p>
	We wanted to put some internet conspiracy ideas to bed and put your worries to rest. For all the rest of us, it&#39;s the end of our calendar year - and it&#39;s been such a fantastic year we&#39;ve shared with you. Thank you for continuing to put your trust in Atalasoft, our products, and Support Team to help you through your imaging SDK needs. We really, truly appreciate it. We&#39;ve released some major product updates (<a href="http://atalasoft.com/products/dotimage-sdk-1.aspx">Atalasoft DotImage 10.2</a> for .NET and <a href="http://atalasoft.com/products/joltimage.aspx">Atalasoft JoltImage</a> for Java) and we couldn&#39;t have done it without you.</p>
<h2>
	Atalasoft likes to give back</h2>
<p>
	We&#39;re always trying to find ways to give back to the community and show our appreciation. From our early days of <a href="http://www.billbither.com/cs/blogs/billbither/archive/2007/02/19/eyebatch-to-charity-in-memory-of-dad.aspx">donating 100% of the profits</a> from our legacy batch image software to this month when Atalasoft sponsored the Pioneer Valley Habitat for Humanity Gingerbread House Build-off. Habitat for Humanity builds houses for those in need, so we didn&#39;t hesitate at the chance to make a donation and dive into some sweet, sweet creations.</p>
<br />
<img alt="Atalasoft at the PVHabitat Gingerbread House Build-off" src="http://atalasoft.com/blogs/atalasoft-general/december-2012/have-a-happy-new-year-not-end-of-years!/blog-gingerbread-panorama-atalasoft-pioneer-valley.jpg" style="width: 600px; height: 230px;" /><br />
<span style="font-size:10px;"><strong>A view of the nice turnout at the PV Habitat for Humanity Gingerbread event</strong></span>.<br />
<br />
<img alt="Atalasoft&amp;#39;s gingerbread house creation at PV Habitat&amp;#39;s Gingerbread House Build-off event" src="http://atalasoft.com/blogs/atalasoft-general/december-2012/have-a-happy-new-year-not-end-of-years!/blog-gingerbread-panorama-atalasoft-pioneer-valley-en.jpg" style="width: 600px; height: 450px;" /><br />
<span style="font-size:10px;"><strong>The Atalasoft Sugar Village. Hey, we only had an hour :) Left to right: Eric Deutchman, Spike McLarty, Julia Burch, Jake Mitchell</strong></span><br />
<p>
	<span style="font-size:14px;"><strong>Whichever calendar you use, have a great holiday and a happy new year!</strong></span></p>
]]></description>
     <pubDate>Wed, 12 Dec 2012 21:56:18 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/atalasoft-general/december-2012/have-a-happy-new-year-not-end-of-years]]></link>
     <dc:creator> Atalasoft General</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/november-2012/jargon]]></guid>
     <title><![CDATA[Jargon]]></title>
     <description><![CDATA[<p>
	Last blog, I wrote about using C# to get some of the benefits of F# <a href="http://atalasoft.com/blogs/stevehawley/november-2012/what-is-partial-function-application">partial function application</a>.&nbsp; In submitting the blog, I was asked by <a href="http://atalasoft.com/company/bios">Rick C.</a> about the phrase &ldquo;newing up&rdquo;.&nbsp; That got me thinking about the jargon we use day to day and how it comes to be.</p>
<p>
	When I was in high school, I did a small amount of electronics work with my dad.&nbsp; He introduced me to <a href="http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_616690_-1">perfboard</a>, which we used for making small circuits by using a wiring pen to make circuits &ndash; bread-boarding he called it.&nbsp; From that point on, I had internalized the jargon.&nbsp; I never really thought about it much &ndash; it was just a word.&nbsp; It&rsquo;s kind of like how most people don&rsquo;t think about the word &lsquo;handicapped&rsquo; which derives from a lottery game called &ldquo;<a href="http://www.snopes.com/language/offense/handicap.asp">hand in cap</a>&rdquo;.&nbsp; My after school job was working at Bell Laboratories for <a href="http://en.wikipedia.org/wiki/Max_Mathews">Max Mathews</a> as a violin builder.&nbsp; The necks of the violins were made from glued-up pieces of poplar.&nbsp; Max sent me to the Bell Labs stock room with a shopping list of things I&rsquo;d need.&nbsp; The list included &ldquo;bread boards,&rdquo; which I found in the stock room.&nbsp; They were exactly that: bread boards.&nbsp; Large wooden boards for rolling out bread dough and which were repurposed by electrical engineers for making prototypes.&nbsp; In my case, I cut them up and, after much carving and other work, turned them into the final product.</p>
<p align="center">
	<a href="http://www.flickr.com/photos/_plinth_/4651368848/" title="Max Mathews Violin by _plinth_, on Flickr"><img alt="Max Mathews Violin" height="500" src="http://farm5.staticflickr.com/4069/4651368848_a27cc22ba6.jpg" width="351" /></a></p>
<p align="center">
	<em><font size="2">Yup, that&rsquo;s me circa 1982.</font></em></p>
<p>
	And in software engineering we make up jargon all the time.&nbsp; We use metaphor, make up new words, and repurpose old words.&nbsp; We talk about visitors, enumerators, events, and so on deftly.&nbsp; Sometimes the origin isn&rsquo;t always clear.&nbsp; My friend <a href="http://www.red-bean.com/jimb">Jim Blandy</a> was given a task to port the text editor <a href="http://doc.cat-v.org/plan_9/4th_edition/papers/sam/">sam</a> and was trying to figure out some of the code.&nbsp; Completely out of context, he asked &ldquo;Hey Steve, what&rsquo;s a rasp?&rdquo;&nbsp; I answered simply, &ldquo;a file with holes in it.&rdquo;&nbsp; This was a forehead-slapping moment which Jim no doubt punctuated with a lot of laughter.&nbsp; He had been trying to work out the meaning of the <a href="http://texteditors.org/cgi-bin/wiki.pl?action=browse&amp;diff=1&amp;id=Jim&amp;revision=1">Rasp</a> struct, which was intended to be a representation of a partial file &ndash; a literal file with holes.</p>
<p>
	And so we come back to the phrase &ldquo;to new up&rdquo;.&nbsp; I consulted a friend of mine who is a dictionary researcher was unable to shed deeper light on the origin of the phrase beyond the earliest I&rsquo;d heard it which was in 2008, spoken by Anders Hejlsberg at the PDC 2008 conference as a substitute for the word &ldquo;instantiate&rdquo;.&nbsp; The first I saw the keyword &lsquo;new&rsquo; in a programming language was in Pascal, but compared to a typical object-oriented implementation of operator new, the Pascal&rsquo;s version is little more than syntactic sugar giving the language type-safe memory allocation.&nbsp; I had expected it to be an older keyword, considering that the <a href="http://ahdictionary.com/word/search.html?q=new&amp;submit.x=35&amp;submit.y=26">English word &lsquo;new&rsquo;</a> is very old, but didn&rsquo;t find earlier programming languages that use it.&nbsp; Heard it earlier than that?&nbsp; By all means, let me know.</p>
]]></description>
     <pubDate>Mon, 19 Nov 2012 16:23:39 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/november-2012/jargon]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/november-2012/what-is-partial-function-application]]></guid>
     <title><![CDATA[What is Partial Function Application?]]></title>
     <description><![CDATA[<p>
	I&rsquo;m going to talk about Partial Function Application in F# and show how you can simulate that (to a degree) in C#.</p>
<p>
	Let&rsquo;s start with a function to calculate quadratic of the form a<em>x</em><sup>2</sup> + b<em>x</em> + c:</p>
<pre class="code">
<span style="color: blue">let </span>quadratic a b c x =
    a * x * x + b * x + c</pre>
<p>
	This is pretty straight-forward &ndash; it just rips through the math and you can see that it works:</p>
<pre class="code">
&gt; quadratic 4.0 3.0 3.0 0.0;;

val it : float = 3.0

&gt; quadratic 4.0 3.0 3.0 1.0;;

val it : float = 10.0

&gt; quadratic 4.0 3.0 3.0 2.0;;

val it : float = 25.0</pre>
<p>
	The cool thing is that you don&rsquo;t have to pass all of the arguments in to quadratic.&nbsp; If you leave off arguments from the end to the front, what you get back is a function that can be applied to the arguments that you left off.&nbsp; What happens is that the arguments you <em>do</em> supply get bound to the parameter names, but the rest still need to be done.&nbsp; I can rework my example to save some typing:</p>
<pre class="code">
<span style="color: blue">let </span>q1 = quadratic 4.0 3.0 3.0
</pre>
<pre class="code">
&gt; q1 0.0;;
val it : float = 3.0

&gt; q1 1.0;;

val it : float = 10.0

&gt; q1 2.0;;

val it : float = 25.0</pre>
<p>
	Moreover, I can define other functions in terms of quadratic.&nbsp; For example, one form of linear function is a quadratic with a = 0:</p>
<pre class="code">
<span style="color: blue">let </span>linear = quadratic 0.0
</pre>
<p>
	Nifty.&nbsp; Now how do we do this in C#?&nbsp; To do this, you need to think about what&rsquo;s happening.&nbsp; When you invoke a function without its full complement of arguments, the compiler goes through an act called &ldquo;binding&rdquo; wherein the supplied argument values are permanently tied to the parameter names.&nbsp; In Lisp or Scheme (and F# is a cousin of these languages), this is often done by creating an &ldquo;environment&rdquo; which is a collection of bounds symbols and their values.&nbsp; We can do this by representing a function as a delegate (which contains an optional reference to a class) and using the class itself as the environment.</p>
<p>
	Here&rsquo;s the quadratic code &ldquo;ported&rdquo; to C#:</p>
<pre class="code">
<span style="color: blue">public class </span><span style="color: #2b91af">Quadratic
</span>{
&nbsp;&nbsp;&nbsp; <span style="color: blue">private double </span>_a, _b, _c;
&nbsp;&nbsp;&nbsp; <span style="color: blue">private </span>Quadratic(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b, <span style="color: blue">double </span>c)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _a = a;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _b = b;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _c = c;
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; <span style="color: blue">private </span>Quadratic(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b) : <span style="color: blue">this</span>(a, b, 0.0) { }
&nbsp;&nbsp;&nbsp; <span style="color: blue">private </span>Quadratic(<span style="color: blue">double </span>a) : <span style="color: blue">this</span>(a, 0.0, 0.0) { }
&nbsp;&nbsp;&nbsp; <span style="color: blue">public static double </span>Value(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b, <span style="color: blue">double </span>c, <span style="color: blue">double </span>x)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">return </span>a * x * x + b * x + c;
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; <span style="color: blue">private double </span>_f1(<span style="color: blue">double </span>x) { <span style="color: blue">return </span>Value(_a, _b, _c, x); }
&nbsp;&nbsp;&nbsp; <span style="color: blue">public static </span><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">double</span>, <span style="color: blue">double</span>&gt; F(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b, <span style="color: blue">double </span>c)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">Quadratic </span>q = <span style="color: blue">new </span><span style="color: #2b91af">Quadratic</span>(a, b, c);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">return </span>q._f1;
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; <span style="color: blue">private double </span>_f2(<span style="color: blue">double </span>c, <span style="color: blue">double </span>x) { <span style="color: blue">return </span>Value(_a, _b, c, x); }
&nbsp;&nbsp;&nbsp; <span style="color: blue">public static </span><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">double</span>, <span style="color: blue">double</span>, <span style="color: blue">double</span>&gt; F(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">Quadratic </span>q = <span style="color: blue">new </span><span style="color: #2b91af">Quadratic</span>(a, b);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">return </span>q._f2;
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; <span style="color: blue">private double </span>_f3(<span style="color: blue">double </span>b, <span style="color: blue">double </span>c, <span style="color: blue">double </span>x) { <span style="color: blue">return </span>Value(_a, b, c, x); }
&nbsp;&nbsp;&nbsp; <span style="color: blue">public static </span><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">double</span>, <span style="color: blue">double</span>, <span style="color: blue">double</span>, <span style="color: blue">double</span>&gt; F(<span style="color: blue">double </span>a)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">Quadratic </span>q = <span style="color: blue">new </span><span style="color: #2b91af">Quadratic</span>(a);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">return </span>q._f3;
&nbsp;&nbsp;&nbsp; }

}

</pre>
<p>
	What I&rsquo;ve done is hidden the environment for the function in a private constructor for the class Quadratic.&nbsp; I implemented the actual quadratic function with the static method Value.&nbsp; In the first flavor of F, I take 3 arguments and by newing up a Quadratic, I have bound the values into the environment.&nbsp; _f1 only takes x as its argument and uses _a, _b, and _c from the environment to calculate the quadratic.&nbsp; In every subsequent flavor of F, I drop an argument.</p>
<p>
	I&rsquo;m not saying that this is what F# is actually doing under the hood.&nbsp; There are other ways to get the same behavior, but they&rsquo;re all fairly similar.&nbsp; For example, the F# compiler could just be writing a new function on the fly with the bound values being constants in the IL.&nbsp; What happens is still the same; it&rsquo;s just that the individual IL instructions become the environment instead of a class object.&nbsp; Similarly, the code above could have used lambda expressions instead of the _f functions and then the lambda expression would have captured the arguments instead of the class:</p>
<pre class="code">
<span style="color: blue">public static </span><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">double</span>, <span style="color: blue">double</span>&gt; F(<span style="color: blue">double </span>a, <span style="color: blue">double </span>b, <span style="color: blue">double </span>c)

{
&nbsp;&nbsp;&nbsp; <span style="color: blue">return </span>x =&gt; Value(a, b, c, x);

}</pre>
<p>
	Looking at the C# code, you should be asking yourself why on earth you would want to do this in C#.&nbsp; You might want to keep in mind that class encapsulation is a way of representing <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">closures</a> rather than the day-to-day business logic of your application.&nbsp; Another case is when you have the task of porting F# code to another platform.&nbsp; In our managed version of dotImage, I made heavy use of partial function application in order to make it easier for me to write generic functions to operate on different pixel formats.&nbsp; It made my code a lot easier to read, maintain, and debug.&nbsp; When I ported this to Java in JoltImage, I could have written the code without using this notion.&nbsp; I was sorely tempted since at present Java doesn&rsquo;t have delegates or lambda expressions in the way that C# does.&nbsp; Because of this, I made an private abstract base class that had the method I wanted to expose and then had a subclass for each pixel format that had a constructor that parameterized the environment.</p>
]]></description>
     <pubDate>Mon, 19 Nov 2012 11:30:52 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/november-2012/what-is-partial-function-application]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/october-2012/don’t-do-eclipse-headless-builds-ever]]></guid>
     <title><![CDATA[Don’t Do Eclipse Headless Builds Ever]]></title>
     <description><![CDATA[<p>
	We standardized on using Eclipse for Java development for a few reasons, not the least of which was the having <a href="http://www.microsoft.com/en-us/download/details.aspx?id=4240">Team Explorer Anywhere</a> integrated.&nbsp; This was a key feature for us since we use TFS for our regular source control and would prefer to not have another infrastructure system, if possible.</p>
<p>
	Since our shop uses continuous integrated and have all our releases built by automation, we needed to build the Eclipse projects on our own system.&nbsp; If you search for &ldquo;eclipse headless build&rdquo; you will find a number of hits on how to do this.&nbsp; They work.&nbsp; Sometimes.&nbsp; Sort of.&nbsp; We found a couple things &ndash; we can&rsquo;t check in the .metadata folder since it stores absolute paths and one particular engineer&rsquo;s .metadata folder won&rsquo;t necessarily work on the build machine or any other engineer&rsquo;s machine.&nbsp; So we kept a private copy on the build server with the provision that if you added a new sub project, it would be necessary to update the .metadata folder on the build server (and on engineering machines).&nbsp; We found that even with that, builds were flakey.&nbsp; They worked most of the time, but not all the time.&nbsp; By adding a call to refresh the projects before the headless build, we found that we could get a more reliable build.&nbsp; Then we had a new project added that didn&rsquo;t really change the build order on the engineering machines, but it was causing <em><strong>errors on the build server that didn&rsquo;t halt the build</strong></em>.&nbsp; We only found out about them by reading the logs and finding out that later in the build obfuscation was failing.&nbsp; Interestingly enough, the java compiler was spouting errors, but was writing .class files that were technically correct but would never load or run (the compiler injected throws in all the constructors).</p>
<p>
	Long story short: <strong>Don&rsquo;t Do Headless Builds with Eclipse</strong>.&nbsp; They may work in simple projects, but will ultimately fail in the worst possible way: generating bad code and not failing the build.</p>
<p>
	So what do we do?&nbsp; All our builds are run from CruiseControl which then fires up NAnt tasks.&nbsp; When we added Java, we kept the same infrastructure but now fire off Ant tasks to do more Java specific things.&nbsp; First, I broke down a project build into 5 tasks (there&rsquo;s actually a 6th, but I haven&rsquo;t integrated it in this build step fully yet):</p>
<ol>
	<li>
		validate</li>
	<li>
		wipe previous output (not technically necessary, but I like to make sure the environment is clean)</li>
	<li>
		compile</li>
	<li>
		make jar</li>
	<li>
		obfuscate</li>
</ol>
<p>
	With this, I added one file to the global workspace and one file to each project.&nbsp; The global file is a csv that contains a project directory name on each line (with the notion that there may be other information later on each line), then I loop over it with a NAnt foreach (this implies that the file is in build order):</p>
<blockquote>
	<p>
		<font face="Courier New">&lt;foreach item=&quot;Line&quot; in=&quot;ProjectList.csv&quot; property=&quot;buildDirName&quot;&gt;</font></p>
</blockquote>
<p>
	Then I set up some properties including the .classpath&nbsp; file, the src folder, the bin folder and so on.</p>
<p>
	<strong>Validation </strong>&ndash; I want to make sure that each project folder really is intended to be a project.&nbsp; There should be a .classpath and a file I call ProjectManifest.xml.&nbsp; It don&rsquo;t actually contain anything yet, but in the future, there may be project specific properties set in this file so that there need not be as much logic and special cases in the actual build script.</p>
<p>
	<strong>Wipe Previous Output </strong>&ndash; this is easy, just a delete task on the bin folder.</p>
<p>
	<strong>Compile</strong> &ndash; this is somewhat complicated.&nbsp; I wrote an embedded C# script in NAnt that parses the .classpath file and turns it into a string suitable for a command line option to the java compiler.&nbsp; Here&rsquo;s the code, which works well enough:</p>
<blockquote>
	<p>
		<font face="Courier New">&lt;script language=&quot;C#&quot; prefix=&quot;pathmunge&quot;&gt;<br />
		&nbsp; &lt;references&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;include name=&quot;System.Xml.dll&quot; /&gt;<br />
		&nbsp; &lt;/references&gt;<br />
		&nbsp; &lt;imports&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;import namespace=&quot;System.IO&quot; /&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;import namespace=&quot;System.Collections.Generic&quot; /&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;import namespace=&quot;System.Xml&quot; /&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;import namespace=&quot;System.Xml.Serialization&quot; /&gt;<br />
		&nbsp; &lt;/imports&gt;<br />
		&nbsp; &lt;code&gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;![CDATA[<br />
		&nbsp;&nbsp;&nbsp; [Function(&quot;to-class-path&quot;)]<br />
		&nbsp;&nbsp;&nbsp; public static string ToClassPath(string projectDir, string dotClassPath)<br />
		&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;ClassPathEntry&gt; paths = GetPaths(dotClassPath);<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (paths == null)<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception(&quot;unable to find class path entries.&quot;);<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ToClassPath(paths, projectDir);<br />
		&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;<br />
		&nbsp;&nbsp;&nbsp; private static List&lt;ClassPathEntry&gt; GetPaths(string dotClassPath)<br />
		&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using(TextReader reader = new StreamReader(dotClassPath)) {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlSerializer serializer = new XmlSerializer(typeof(ClassPath));<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClassPath cp = (ClassPath)serializer.Deserialize(reader);<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cp == null) return null;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return cp.Paths;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;<br />
		&nbsp;&nbsp;&nbsp; private static string ToClassPath(List&lt;ClassPathEntry&gt; list, string projectDir)<br />
		&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuilder sb = new StringBuilder();<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(ClassPathEntry entry in list)<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string pathPart = null;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (entry.Kind)<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &quot;lib&quot;:<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pathPart = projectDir + entry.Path;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &quot;src&quot;:<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (entry.Path == &quot;src&quot;) continue;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pathPart = projectDir + entry.Path + @&quot;\bin&quot;;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pathPart != null)<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (sb.Length &gt; 0 &amp;&amp; sb[sb.Length - 1] != &#39;;&#39;) sb.Append(&#39;;&#39;);<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.Append(pathPart);<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return sb.ToString();<br />
		&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp;<br />
		&nbsp;&nbsp;&nbsp; [Serializable()]<br />
		&nbsp;&nbsp;&nbsp; public class ClassPathEntry {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string _kind;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Xml.Serialization.XmlAttribute(&quot;kind&quot;)]<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string Kind { get { return _kind; } set { _kind=value; } }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string _path;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Xml.Serialization.XmlAttribute(&quot;path&quot;)]<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string Path { get { return _path; } set { _path = value; } }<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private bool _combineaccessrules;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Xml.Serialization.XmlAttribute(&quot;combineaccessrules&quot;)]<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public bool CombineAccessRules { get { return _combineaccessrules; } set { _combineaccessrules = value; } }<br />
		&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp; [Serializable()]<br />
		&nbsp;&nbsp;&nbsp; [System.Xml.Serialization.XmlRootAttribute(&quot;classpath&quot;, Namespace = &quot;&quot;, IsNullable = false)]<br />
		&nbsp;&nbsp;&nbsp; public class ClassPath<br />
		&nbsp;&nbsp;&nbsp; {<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private List&lt;ClassPathEntry&gt; _paths = new List&lt;ClassPathEntry&gt;();<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [XmlElement(&quot;classpathentry&quot;)]<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public List&lt;ClassPathEntry&gt; Paths { get { return _paths; } set { _paths = value; } }<br />
		&nbsp;&nbsp;&nbsp; }<br />
		&nbsp;&nbsp;&nbsp; ]]&gt;<br />
		&nbsp; &lt;/code&gt;<br />
		&lt;/script&gt;</font></p>
</blockquote>
<p>
	You can see that I leverage the Xml serializer to get the information that I need.&nbsp; My first job after writing the compile-java task was to verify that a compiler error would fail the build appropriately.&nbsp; It does.&nbsp; Here is the compile-java task:</p>
<blockquote>
	<p>
		<font face="Courier New">&lt;!-- compile-java - compiles a single java project<br />
		&nbsp; this needs to have Dir.CurrentJavaSrc set<br />
		--&gt;<br />
		&lt;target name=&quot;compile-java&quot; &gt;<br />
		&nbsp; &lt;echo message =&quot;Compiling ${CurrentJavaProject}&quot; /&gt;<br />
		&nbsp; &lt;if test=&quot;${not file::exists(File.DotClassPath)}&quot; &gt;<br />
		&nbsp;&nbsp;&nbsp; &lt;fail message=&quot;compile-java: bad project structure - looking for ${File.DotClassPath}&quot;/&gt;<br />
		&nbsp; &lt;/if&gt;<br />
		&nbsp; &lt;property name=&quot;JREMainJars&quot; value=&quot;${environment::get-variable(&#39;JAVA_HOME&#39;)}\jre\lib\*&quot; /&gt;<br />
		&nbsp; &lt;property name=&quot;JREExtJars&quot; value=&quot;${environment::get-variable(&#39;JAVA_HOME&#39;)}\jre\lib\ext\*&quot; /&gt;<br />
		&nbsp; &lt;property name=&quot;DerivedClassPath&quot; value=&quot;${pathmunge::to-class-path(Dir.Build, File.DotClassPath)};${JREMainJars};${JREExtJars}&quot; /&gt;<br />
		&nbsp; &lt;echo message=&quot;initial class path - ${DerivedClassPath}&quot; /&gt;<br />
		&nbsp; &lt;property name=&quot;ant.commands&quot; value=&quot;-Dcompile-classpath=${quote}${DerivedClassPath}${quote} -Dcompile-srcpath=${quote}${Dir.CurrentJavaSrc}${quote} -Dcompile-binpath=${quote}${Dir.CurrentJavaBin}${quote}&quot; /&gt;<br />
		&nbsp; &lt;property name=&quot;ant.task&quot; value=&quot;compile-project&quot; /&gt;<br />
		&nbsp; &lt;call target =&quot;ant&quot; /&gt;<br />
		&lt;/target&gt;</font></p>
</blockquote>
<p>
	And the actual Ant task is straight forward:</p>
<blockquote>
	<p>
		<font face="Courier New">&lt;target name=&quot;compile-project&quot;&gt;<br />
		&nbsp; &lt;echo message=&quot;compiling with srcpath ${compile-srcpath} binpath ${compile-binpath} classpath ${compile-classpath}&quot; /&gt;<br />
		&nbsp; &lt;javac srcdir=&quot;${compile-srcpath}&quot; destdir=&quot;${compile-binpath}&quot; classpath=&quot;${compile-classpath}&quot; /&gt;<br />
		&lt;/target&gt;</font></p>
</blockquote>
<p>
	The only other missing piece is how we invoke ant:</p>
<blockquote>
	<p>
		<font face="Courier New">&nbsp; &lt;target name=&quot;ant&quot;&gt;<br />
		&nbsp; &lt;exec program=&quot;ant.bat&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; basedir=&quot;${Dir.Ant}\bin&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; workingdir=&quot;${Dir.Build}&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; output=&quot;${Progress.Log.File}&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; append=&quot;true&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timeout=&quot;7200000&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; verbose=&quot;true&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; failonerror=&quot;true&quot;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; commandline=&quot;-buildfile ${quote}${Dir.Build}\JavaImageAnt.xml${quote} ${ant.commands} ${ant.task}&quot; /&gt;<br />
		&nbsp; &lt;property name=&quot;ant.commands&quot; value=&quot;&quot; /&gt;<br />
		&lt;/target&gt;</font></p>
</blockquote>
<p>
	Oh and ${quote} is used to get an embedded double-quote into a string&nbsp; <font face="Courier New">&lt;property name=&quot;quote&quot; value=&#39;&quot;&#39; /&gt;</font>.</p>
<p>
	<strong>Jar</strong> &ndash; jar is similar to compile.&nbsp; We need the bin directory to pass in and then invoke an Ant task to build the jar file.&nbsp; This is complicated only by the one project that has to have a few external jar&rsquo;s combined into it, so one project gets handled with a special case Ant task.&nbsp; Every project gets a jar even though unit test projects don&rsquo;t strictly need them.</p>
<p>
	<strong>Obfuscate</strong> &ndash; the obfuscation task is nearly identical.&nbsp; At present, all our jars get obfuscated with the same settings using <a href="http://www.zelix.com/klassmaster/">Zelix Klassmaster</a>.&nbsp; We skip the obfuscate step on unit tests as we don&rsquo;t need them and the dependencies would be unusual.</p>
<p>
	There are a number of ways that this type of build automation could be done &ndash; for example, keeping a completely separate ant file that handles the build entirely.&nbsp; In an ideal world, the build would be done by the same system as an engineering workstation, but since that isn&rsquo;t currently possible, we strike a balance to get the build as automatic as possible.&nbsp; In theory, we should be able to analyze all the .classpath files and intuit the build order and this might be a good step for the future.</p>
]]></description>
     <pubDate>Mon, 29 Oct 2012 10:46:36 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/october-2012/don’t-do-eclipse-headless-builds-ever]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/october-2012/atala-luau-lunch]]></guid>
     <title><![CDATA[Atala-Luau Lunch]]></title>
     <description><![CDATA[<p>
	What is one to do when the boss is on vacation in Hawaii?&nbsp; Possible ideas:</p>
<ol>
	<li>
		Nothing.&nbsp; Because you&rsquo;re super lame.</li>
	<li>
		Show up to work 2 minutes late and leave 2 minutes early, out of spite.&nbsp; WHOA!&nbsp; LIVIN&rsquo; ON THE EDGE!</li>
	<li>
		Go to Hawaii, too.</li>
</ol>
<p>
	These were all thoughts that crossed my mind last week while our General Manager and 2 members of our sales team sipped tropical drinks, climbed sleeping volcanoes, napped on powder-soft beaches, and flew in helicopters over the serene blues of the Hawaiian waters.&nbsp; I work hard.&nbsp; I deserve a trip to the islands.&nbsp; Right?&nbsp; RIGHT?!</p>
<p>
	But alas, I was not in Hawaii.&nbsp; And my options weren&rsquo;t looking good.&nbsp; I would not get lazy with my work, because that is unethical (and frankly, not how I roll).&nbsp; I could not afford a trip to Hawaii, and I would most likely be fired if my boss unzipped his suitcase to find me folded up inside.&nbsp; And I wasn&rsquo;t going to do nothing, because I am certainly NOT a lame-o.</p>
<p>
	So&hellip;what to do?</p>
<p>
	<em>Why, bring Hawaii to Atalasoft!</em>&nbsp; (Duh.)</p>
<p>
	Thursday evening on a whim, I decided to go pick up some leis:</p>
<p>
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=74b20ee7-cae7-47e1-8a0a-0be086cd0ed6"><img alt="photo 4" border="0" height="348" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=782ec255-00f9-4dae-8f20-62903ca0f998" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="photo 4" width="261" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=b5a25854-6ec4-48d5-837b-978c15f673ce"><img alt="photo 5" border="0" height="347" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=779000fd-563b-4e2e-ab2f-b2e66982e1a4" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="photo 5" width="260" /></a></p>
<p align="center">
	<em><font size="1">Look how happy Spike and Dave are with their bright pink leis!</font></em></p>
<p>
	&nbsp;</p>
<p>
	Some tropical tchotchkes:</p>
<p>
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ef191f0d-ec72-4df4-92f6-f6d1e333ea78"><img alt="photo 1" border="0" height="306" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=900632de-c077-433a-bbd0-c40f8cd130fd" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="photo 1" width="408" /></a></p>
<p align="center">
	<em><font size="1">Well, at least the ceiling spinners aren&rsquo;t blurry.</font></em></p>
<p align="center">
	&nbsp;</p>
<p>
	Some plastic Margarita cups for Piña Coladas at Beer:30:</p>
<p>
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5a86e1d1-e46b-4a7e-b50c-82dc9c552d0e"><img alt="photo 2" border="0" height="305" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=96d76994-464c-4d5f-87ef-0f7930304f2c" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="photo 2" width="407" /></a></p>
<p align="center">
	<em><font size="1">Who would turn down a chance to break out Mr. Tipsy the Margarita Machine?</font></em></p>
<p align="left">
	&nbsp;</p>
<p align="left">
	And then on Friday, I ordered some Hawaiian pizza, threw together a tropical fruit salad, and slapped on some Beach Boys for a lunchtime getaway:</p>
<p align="left">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=467b836a-0562-4e12-8662-f5826b12a722"><img alt="photo 3" border="0" height="303" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a79eb2ec-f5c6-44f3-b0a9-d9fa469fa374" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="photo 3" width="405" /></a></p>
<p align="center">
	<font size="1"><em>Hawaiian pizza is obviously a native cuisine.</em></font></p>
<p>
	So maybe it wasn&rsquo;t a siesta on a perfect 75-degrees-and-sunny afternoon, or a swim session with dolphins and stingrays, or a feast of grilled spam and pineapples, or a beautiful Hawaiian lady dancing around in a grass skirt.&nbsp; It was just me showing my coworkers that I love them.</p>
<p>
	And if an act of genuine love doesn&rsquo;t take you away to a magical place, I don&rsquo;t know what will.</p>
]]></description>
     <pubDate>Wed, 24 Oct 2012 16:52:06 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/october-2012/atala-luau-lunch]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/october-2012/the-cupcake-truck-cometh]]></guid>
     <title><![CDATA[The Cupcake Truck Cometh]]></title>
     <description><![CDATA[<p>
	If you couldn&rsquo;t tell, Atalasoft is serious about appreciating its employees.</p>
<p>
	Things have been pretty hectic around here lately.&nbsp; Between traveling to multiple trade shows, wrapping up the quarter, and releasing our <a href="http://atalasoft.com/products/joltimage" target="_blank">brand new Java SDK, JoltImage</a>, it has taken every bit of energy and cooperation for us to keep moving forward.</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f370eabe-9a3b-405d-a60e-5353607eda52"><img alt="JoltImage" border="0" height="168" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a8c3393e-506b-4c94-a78a-87b691c91dba" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="JoltImage" width="331" /></a></p>
<p>
	&nbsp;</p>
<p>
	Luckily, we are are a bunch of Rock Star Ninjas.&nbsp; We punched every obstacle right in the face and rocked it.</p>
<p>
	As a reward for our hard work and innate awesomeness, Christina hired <a href="http://frostedswirl.com/index.html" target="_blank">Frosted Swirl Cupcakes</a> to bring us delicious treats in their sweet decked-out cupcake truck!</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7e55f0a7-0c54-4231-9030-ac747433e30d"><img alt="truck 2" border="0" height="304" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8f182765-b708-4dc7-80f5-9b3659b77f44" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="truck 2" width="404" /></a></p>
<p>
	&nbsp;</p>
<p>
	With over 20 different flavors to choose from, we took a poll and ordered our top 4 picks: Classic Chocolate, The Java, Carrot Cake, and Peanut Butter Cup Perfection.&nbsp; They even have gluten-free options!</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d5a58086-f795-4514-b39e-fe3a30a726e0"><img alt="closeup2" border="0" height="302" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8f59fbfb-e70a-4e4d-bd11-d02991175dea" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="closeup2" width="402" /></a></p>
<p>
	&nbsp;</p>
<p>
	Even though the weather was rather rainy and gloomy, we were all smiles.&nbsp; It&rsquo;s hard not to be when your employer cares about you so much.&nbsp; And I bet our afternoon productivity was even boosted by the sugar rush!</p>
<p align="center">
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e4f3c4c7-32dd-4adf-95db-7aa0ee514c3c"><img alt="the crew" border="0" height="233" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=b777d100-de94-4469-92a3-1663e74bc9bd" style="background-image: none; float: left; border-width: 0px; border-style: none; border-color: -moz-use-text-color; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="the crew" width="310" /></a></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dbe11be6-5c07-4d33-a03b-5bf71e169c61"><img alt="Cam cutie" border="0" height="233" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=0b1797e6-575a-4b51-bb1b-5b541b4c7641" style="background-image: none; float: right; border-width: 0px; border-style: none; border-color: -moz-use-text-color; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="Cam cutie" width="310" /></a></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=230f861b-1ba3-4464-b9fd-7ec186e57bfc"><img alt="Adam" border="0" height="345" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6a26dff4-783b-4de9-83ea-49ad2a981126" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 40px" title="Adam" width="260" /></a></p>
<p align="left">
	&nbsp;</p>
<p align="left">
	Check out the rest of the pictures in our <a href="https://www.facebook.com/media/set/?set=a.10151127099674011.452100.6034814010&amp;type=1&amp;l=62f7e3ee89" target="_blank">Facebook album</a>, and learn more about Frosted Swirl cupcake on their <a href="https://www.facebook.com/FrostedSwirlTruck" target="_blank">Facebook page</a> and <a href="http://frostedswirl.com/index.html" target="_blank">company website</a>.</p>
]]></description>
     <pubDate>Mon, 15 Oct 2012 14:39:27 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/october-2012/the-cupcake-truck-cometh]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/october-2012/about-those-enums,-java…]]></guid>
     <title><![CDATA[About those Enums, Java…]]></title>
     <description><![CDATA[<p>
	As you&rsquo;ve seen, we&rsquo;ve released a new product &ndash; <a href="http://atalasoft.com/products/joltimage">JoltImage</a>.&nbsp; This is our foray into the Java world of image processing, something that we&rsquo;ve been contemplating for some time.&nbsp; I will be writing about that experience so that engineers faced with similar problems (porting .NET code to Java) might have a reference.</p>
<p>
	When I started working in Java in 1996, it was a brand new language and working in it was freeing to a certain extent.&nbsp; I found that compared with C or C++, I was able to write far more code with far fewer bugs that I had in the past.&nbsp; Having checked arrays, immutable strings, and garbage collection removed three personal sources of bugs.</p>
<p>
	One thing that it lacked was enumerations.&nbsp; This is something that is, IMHO, vital.&nbsp; The work around was declaring public final values to use or to make singletons.&nbsp; The problem with public finals are the lack of type safety and singletons are more heavyweight than you&rsquo;d like.</p>
<p>
	Before I take a hammer to Java, let&rsquo;s step back and examine the use cases for enumerations:</p>
<p>
	Cardinal values</p>
<p>
	Ordinal values</p>
<p>
	Set elements</p>
<p>
	Cardinal values are effectively atoms &ndash; symbolic names that have no particular meaningful value.&nbsp; Ordinals are symbols that have specific values that have meaning and may or may not have operations on those values.&nbsp; Set elements are either cardinal or ordinal values that need to be contained in a set and have specific set operations (intersection, union, difference, complement, member, etc.).</p>
<p>
	In Java, enums are easiest to use for Cardinal values and appear to be optimized for that.&nbsp; I can do the following declaration:</p>
<p>
	<font face="Courier New" size="2"><font color="#9b00d3">public enum</font> IOPortID {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; A, B, C, D;</font></p>
<p>
	<font face="Courier New" size="2">}</font></p>
<p>
	&nbsp;</p>
<p>
	<span class="sc0">In this case, I can refer to an IO port very easily by name.&nbsp; Terrific.&nbsp; Now suppose that each of the ports has slightly more meaning. </span></p>
<p>
	<span class="sc0">Let&rsquo;s say that each of those ports is associated with a hardware address.&nbsp; You&rsquo;d LIKE to be able to just associate the address with the symbol.&nbsp; That should be easy, but you can&rsquo;t do that.&nbsp; At least not really.&nbsp; Instead, you have two choices, code that looks like this:</span></p>
<p>
	<font face="Courier New" size="2"><font color="#9b00d3">public enum</font> IOPortID {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; A, B, C, D;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; <font color="#9b00d3">final int</font> toHardwareAddress() {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">switch</font> (this) {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">case</font> A: <font color="#9b00d3">return</font> 0xaba;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">case</font> B: <font color="#9b00d3">return</font> 0xabb;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">case</font> C: <font color="#9b00d3">return</font> 0xabc;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">case</font> D: <font color="#9b00d3">return</font> 0xabd;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">default</font>: <font color="#9b00d3">throw new</font> RuntimeException(&ldquo;Illegal IOPortID!&rdquo;);</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; }</font></p>
<p>
	<font face="Courier New" size="2">}</font></p>
<p>
	&nbsp;</p>
<div style="line-height: 1; display: inline; white-space: pre; background: #ffffff; float: none">
	<span class="sc0">or code that looks like this:</span></div>
<p>
	&nbsp;</p>
<p>
	<font face="Courier New" size="2"><font color="#9b00d3">public enum</font> IOPortID {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; A(0xaba), B(0xabb), C(0xabc), D(0xabd);</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; <font color="#9b00d3">private</font> <font color="#9b00d3">int</font> _value;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; <font color="#9b00d3">private</font> IOPortID(<font color="#9b00d3">int</font> value) { _value = value; }</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; <font face="Courier New" size="2"><font color="#9b00d3">public </font></font><font color="#9b00d3">static</font> IOPortID fromValue(<font color="#9b00d3">int</font> value)</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; {</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">if</font> (value == A._value) <font color="#9b00d3">return</font> A;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">if</font> (value == B._value) <font color="#9b00d3">return</font> B;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">if</font> (value == C._value) <font color="#9b00d3">return</font> C;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">if</font> (value == D._value) <font color="#9b00d3">return</font> D;</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#9b00d3">throw new</font> IllegalArgumentException(&ldquo;unknown hardware address &ldquo; + value);</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; }</font></p>
<p>
	<font face="Courier New" size="2">}</font></p>
<p>
	Either implementation is bad.&nbsp; The first one might be slightly better in that I&rsquo;ve decoupled the port ID value from the port ID symbol and made that particular method accessible only within the namespace.&nbsp; In both cases, I&rsquo;ve had to put in a stack of boilerplate code which is a bad <a href="http://en.wikipedia.org/wiki/Code_smell">code smell</a>.&nbsp; I will say that because Java does not dictate how many members you put into an enum, you could very well put in any number of scalar dimensions or references to other classes.&nbsp; For example, you could make an enum that encapsulates longitude and latitude and represents major cities.</p>
<p>
	And herein is the problem with Java enumerated values: they are not enumerated values.&nbsp; They are singleton classes.&nbsp; When I declare an enum as in the very first example, I end up with 4 classes constructed, A, B, C, and D.&nbsp; Don&rsquo;t believe me?&nbsp; Add a setValue() method to each of the above and you can mutate your enum.&nbsp; Yikes.&nbsp; I can think of a few reasons why you might want to do this, but they&rsquo;re all hacks on top of a bad base model.</p>
<p>
	One of the other handy use cases in enums is to represent bit flags for settings.&nbsp; This is frequently used in software &ndash; for example, the permissions in a PDF file is represented by a 32-bit integer holding a set of bit flags.&nbsp; The prescribed method is to use <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/EnumSet.html">EnumSet</a>.&nbsp; EnumSet has two main problems with it which are intimately entwined: it is neither blittable nor is it immutable.&nbsp; Let me explain &ndash; a blittable type is any type that is bit-for-bit copied by an assignment.&nbsp; Scalars (int, char, float, etc.) are blittable.&nbsp; Class instances are not blittable, they are copied.&nbsp; Since Enums and EnumSets are classes, they are not blittable.&nbsp; This means that if they are mutable (and Enums can be and EnumSets are), then we have to be very careful about how they are used.&nbsp; For example, if I design an abstract class that needs to return an EnumSet of all operations that it supports, I need to either prescribe that the implementation always return a new EnumSet (bad idea &ndash; I can&rsquo;t trust all my implementors) or wrap each call to the abstract method in another method that does a EnumSet.copyOf().&nbsp; This is cumbersome and error prone and is necessary because EnumSet is fundamentally broken.&nbsp; remove() and removeAll mutate the set &ndash; this is bad.&nbsp; Instead, their should be the methods intersect(other), union(other), difference(other), complement(), which do the actual set operations and return a new EnumSet with the appropriate types and there should be no mutators.&nbsp; This way instead of writing this code:</p>
<p>
	<font face="Courier New" size="2"><font face="Courier New" size="2"><font color="#9b00d3">public </font></font><font color="#9b00d3">final boolean</font> has1DOtherThanCode39(EnumSet&lt;Symbologies&gt; sym)</font></p>
<p>
	<font face="Courier New" size="2">{</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; EnumSet&lt;Symbologies&gt; set = EnumSet.copyOf(sym); <font color="#008000">// have to copy!</font></font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; set.removeAll(Symbologies.all2D());</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; set.remove(Symbologies.CODE_39);</font></p>
<p>
	<font face="Courier New" size="2">&nbsp;&nbsp; <font color="#9b00d3">return</font> !set.isEmpty();</font></p>
<p>
	<font face="Courier New" size="2">}</font></p>
<p>
	I could write this:</p>
<p>
	<font face="Courier New" size="2"><font color="#9b00d3">return</font> !sym.difference(Symbologies.all2D().union(Symbologies.CODE_39)).isEmpty();</font></p>
<p>
	or the equivalent in .NET</p>
<p>
	<font face="Courier New" size="2"><font color="#9b00d3">return</font> (sym &amp; ~(Symbologies.All2D | Symbologies.Code39)) != 0;</font></p>
<p>
	The requirement of the copyOf() is to prevent us from side-effecting the input, since it is passed by reference.&nbsp; This is an easy thing to forget which is a bug waiting to happen.&nbsp; If we left out the copyOf() call, we would be side-effecting the caller&rsquo;s copy which in the case of this particular operation will not always be noticeable.&nbsp; Not cool.&nbsp; In addition, if EnumSet were immutable, then we would be allocating 3 EnumSet objects that would get thrown away immediately (probably their reason for making them mutable in the first place).</p>
<p>
	So we can see that the Java Enum is a class and not actually an enum and when any case beyond simple cardinals is needed (which in my experience is about 3/4 of the time), the programmer is required to use boilerplate code which is error prone.&nbsp; Finally, the use of EnumSets is cumbersome as well as requiring the client to understand the consequences of having a mutable class, although to its credit, EnumSet will scale well beyond 64 members.&nbsp; By contrast, the .NET enum is a scalar (and blittable), and is trivial to use in all the common cases and only starts to be a leaky abstraction when the use case is inappropriate for an enum and more appropriate for an actual class.</p>
]]></description>
     <pubDate>Tue, 09 Oct 2012 13:23:25 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/october-2012/about-those-enums,-java…]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/september-2012/rapid-fire-updates]]></guid>
     <title><![CDATA[Rapid fire updates]]></title>
     <description><![CDATA[<p>
	Hey.&nbsp; So it&rsquo;s been a while.&nbsp; Which means&hellip;</p>
<p>
	&nbsp;</p>
<p align="center">
	<font color="#ff0000" face="Showcard Gothic" size="4">RAPID FIRE UPDATES IN ORDER OF EVENT OCCURRENCE!</font></p>
<p align="center">
	<font color="#333333" size="2"><em>Yes.&nbsp; That absolutely called for an obnoxious font style, size, and color.</em></font></p>
<p align="center">
	<font color="#333333" size="2"><em>Just as this side comment calls for decreased font size and italics.</em></font></p>
<p>
	&nbsp;</p>
<p align="center">
	<strong><font size="4">Steve Day</font></strong></p>
<p align="left">
	On September 7th, Atalasoft had the honor of participating in the celebration of <a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2009/01/14/thinking-about-dates.aspx" target="_blank">Steve Day</a>.&nbsp; This is not yet a national or international holiday, but it should be.</p>
<p align="left">
	This holiday pays tribute to Steve Hawley, our Chief Architect and the creator of the most brilliant calendar system EVER.&nbsp; Seriously, what is this &ldquo;30 days hath September, April, June, and November&rdquo; nonsense?!&nbsp; Steve&rsquo;s calendar provides a methodical and practical organization of dates, without the silly rhyme.</p>
<p align="left">
	Basically: there is a set of 13 months consisting of 28 days each.&nbsp; Every month starts on Sunday and ends on Saturday, so dates will always fall on the same day of the week and there will never be a Friday the 13th (phew!).</p>
<p align="left">
	If you do the math (28x13=364) there is one day left in the year.&nbsp; That day is Steve Day.</p>
<p align="left">
	Steve Day has no &ldquo;date&rdquo; value; it is not a Monday, or any other day of the week, and it has no numerical digit assigned to it.&nbsp; This day shall be spent not working but instead honoring the calendar creator as the community sees fit (parades, shrines, feasts, etc.).</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=10c2020b-302a-460a-8ac6-5732689f37c4"><img alt="Steve dry ice" border="0" height="242" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5ff95134-b43c-44c0-9b81-5a1a12b34a5a" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Steve dry ice" width="361" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5e8f8afd-cb66-4b66-88e5-c29cffc74583"><img alt="itsit" border="0" height="241" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5aa0c002-f3ec-4419-ac96-dc168f487cb7" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="itsit" width="241" /></a></p>
<p align="center">
	<em><font size="1">Atalasoft celebrated by doing science with dry ice and with a feast of <a href="http://www.itsiticecream.com/" target="_blank">mint It&rsquo;s-It sandwiches</a>!</font></em></p>
<p align="left">
	This system also accounts for what we call a &ldquo;leap year&rdquo;.&nbsp; The &ldquo;leap day&rdquo; becomes another Steve Day, and during this year the Steve Days are referred to as Steve Day<sub>0</sub> and Steve Day<sub>1</sub>.&nbsp; Both days shall be spent in a similar celebratory manner.</p>
<p align="left">
	There are also some rules about naming children born on Steve Day, as well as other calendar specifics which I do not possess the eloquence to explain properly.&nbsp; If you didn&rsquo;t click on the link to Steve&rsquo;s blog post above, do it <a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2009/01/14/thinking-about-dates.aspx" target="_blank">now</a>.</p>
<p align="left">
	Until this calendar becomes law (which I&rsquo;m sure it will, as soon as Steve&rsquo;s son Stuart rules the world), Steve Day shall be celebrated on or around Steve&rsquo;s birthday &ndash; September 2nd.</p>
<p align="left">
	&nbsp;</p>
<p align="center">
	<strong><font size="4">Office Beautification: Project Bathroom</font></strong></p>
<p align="left">
	As I mentioned previously in my <a href="http://atalasoft.com/blogs/office/august-2012/office-beautification" target="_blank">Office Beautification blog post</a>, our bathroom was in some serious need of attention.&nbsp; So, inspired by a post-it mural left on the wall by an anonymous employee, I decided to give it some Space Invaders lovin&rsquo;.</p>
<p align="left">
	&nbsp;</p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e6d16f1a-ffaf-493e-ba83-e7d194a6ca48"><img alt="bathroom panoramic" border="0" height="176" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=eef51d79-4e5f-4a00-a60d-7be38cc07b91" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="bathroom panoramic" width="703" /></a></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=98c2adb9-36c2-44e4-bd17-9e41d6e33c2b"><img alt="bathroom little guys" border="0" height="169" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=948efb33-5589-4e86-954e-f78e6ae94c5a" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="bathroom little guys" width="224" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7e319849-b497-4cf6-ae1b-3823cd9248ff"><img alt="bathroom mural" border="0" height="169" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ef0c6a0a-39e9-43d4-8b00-6205b5aa19d9" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="bathroom mural" width="224" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1e36b67a-648c-4457-a8cb-4ebf832cc9da"><img alt="bathroom little guys 3" border="0" height="170" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=b34c4678-12e5-499d-ad6c-f17ca206b0cd" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="bathroom little guys 3" width="225" /></a></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=af326094-ca86-4d12-82f2-dad61983366a"><img alt="bathroom mini mural rotate" border="0" height="286" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=880fe271-bf54-4b77-8a05-462d0feb6dbc" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="bathroom mini mural rotate" width="215" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=2f398da9-e276-4c71-88e8-31150650d9c8"><img alt="bathroom little guys 2" border="0" height="285" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8ff44c42-9c9c-4ca6-82b9-7d33fa105d41" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="bathroom little guys 2" width="215" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p align="left">
	&nbsp;</p>
<p align="left">
	There you have it, folks.&nbsp; I feel like a proud parent.</p>
<p>
	&nbsp;</p>
<p align="center">
	<strong><font size="3">Marco came to visit!</font></strong></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=af9016cc-fff2-40b7-ab3a-4069d6805ec5"><img alt="Marco" border="0" height="299" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dd8c8123-a886-4490-ab06-67788ddf1701" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Marco" width="246" /></a></p>
<p align="center">
	<font size="1"><em>This is Marco, our EMEA sales account executive.&nbsp; We love Marco!&nbsp; Yay!</em></font></p>
<p align="left">
	&nbsp;</p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<strong><font size="3">A Gangnam Style Staff Meeting</font></strong></p>
<p align="left">
	On the morning of September 21, 2012, Atalasoft held its regularly-scheduled staff meeting, per usual.&nbsp; But what occurred at this staff meeting was not so usual.</p>
<p align="left">
	A couple weeks ago, I had a life-changing experience.&nbsp; This experience has since ignited a flame of passion within me, a passion to make the world a better place by sharing this wonderful gift with everyone I know.&nbsp; I decided to start with my coworkers.</p>
<p align="left">
	At approximately 10 AM, the employees of Atalasoft (including Marco!) got to their feet around the conference room table, placed their right hand over their hearts, and blindly swore to take this magical journey with me.&nbsp; And then I played them a clip of what we were about to do together.</p>
<p align="left">
	&nbsp;</p>
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:74ec5780-aa82-46ad-bb6c-15baf6f257af" style="padding-bottom: 0px; padding-left: 0px; width: 640px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px">
	<div style="margin: auto;">
		<iframe align="left" allowfullscreen="" frameborder="0" height="360" scrolling="no" src="http://www.youtube.com/embed/9bZkp7q19f0" width="640"></iframe></div>
	<div style="width:640px;clear:both;font-size:.8em">
		&ldquo;Gangnam Style&rdquo; by South Korean rapper, Psy</div>
</div>
<p>
	&nbsp;</p>
<p>
	Oh yes.&nbsp; I taught this dance.&nbsp; And EVERYBODY HAD TO DO IT because they swore to me that they would!&nbsp; BWAH HAH HAH HAH!</p>
<p>
	The Atalasoft team constantly surprises and amazes me.&nbsp; Who else would learn this ridiculous dance so early in the morning, and even laugh while being forced to look like a complete goof?</p>
<p>
	PS: If you hadn&rsquo;t seen this video before reading this blog post, you must be living under a rock.&nbsp; It&rsquo;s even been on the news!!!</p>
<p>
	&nbsp;</p>
<p align="center">
	<font color="#ff0000" face="Showcard Gothic" size="4">Fin.</font></p>
]]></description>
     <pubDate>Wed, 03 Oct 2012 12:07:54 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/september-2012/rapid-fire-updates]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/august-2012/atalakids!]]></guid>
     <title><![CDATA[Atalakids!]]></title>
     <description><![CDATA[<p>
	I don&rsquo;t need to do any scientific research on this one: Family-Work balance is VITAL.</p>
<p>
	Missing your favorite Spin class to meet a major project deadline might bum you out a little, but you won&rsquo;t experience any major health detriments (assuming your &ldquo;deadline&rdquo; is not just a frequent excuse for missing out on your sweat sessions).&nbsp; Occasionally you might have to trade Happy Hour for some presentation prep, but you can always catch it next week (or tomorrow).&nbsp; But what happens when your daycare provider suddenly gets food poisoning and your significant other is out of town?&nbsp;</p>
<p>
	I might not have any children myself, but I can still appreciate a workplace that fully supports those who do.&nbsp; And according to this article from the <a href="http://blogs.hbr.org/cs/2012/03/a_key_to_us_competitiveness_wo.html" target="_blank">Harvard Business Review</a>, it&rsquo;s kind of a rare thing in the US.</p>
<p>
	Family-workplace balance is an area where Atalasoft truly shines.&nbsp; But rather than having me, a single and childless 20-something tell you why, I&rsquo;m going to let a few of my coworkers speak for themselves&hellip;</p>
<blockquote>
	<p>
		<em>&ldquo;From being a constantly-puking pregnant person to working from home with a feverish baby, Atalasoft has given me the flexibility to maintain a realistic work-life balance and truly enjoy my life as a working mom.&rdquo; &ndash; Christina Gay, HR Director</em></p>
</blockquote>
<p align="center">
	<strong><font face="Lucida Calligraphy" size="4">Clara V. Gay</font></strong></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1ef9201f-4682-4548-a8a9-10d46cd6edb2"><img alt="Clara" border="0" height="444" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=13582c42-bea5-467b-a376-a09ee0804ef6" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Clara" width="444" /></a></p>
<ul>
	<li>
		<strong>Likes:</strong> Pretending to burp, eggplant, drinking bathwater</li>
	<li>
		<strong>Dislikes:</strong> When the cat runs away from her Godzilla-like advances (ME CLARA! ME LOVE KITTEH!), having her face wiped, when you say &ldquo;we&rsquo;re going for a ride in the car&rdquo; and then you don&rsquo;t (WTF MOM!)</li>
</ul>
<p>
	&nbsp;</p>
<blockquote>
	<p>
		<em>&ldquo;The trust that Atalasoft has placed in me means that I can schedule my work time flexibly, allowing me to take care of my daughter when needed.&nbsp; Because I get to spend more time with her, I end up performing with a higher quality to show my appreciation.&rdquo; &ndash; Elaine Gorham, Training &amp; Support Manager</em></p>
</blockquote>
<p align="center">
	<strong><font face="Lucida Calligraphy" size="4">Camille G.</font></strong></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=0484d4c7-8945-40cc-8716-451516216e4e"><img alt="Cam" border="0" height="533" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=2ce6a3e5-6a80-45cc-8ad6-4ff601eba4b2" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Cam" width="402" /></a></p>
<ul>
	<li>
		<strong>Favorite songs: </strong>&ldquo;Werewolves of London&rdquo; by Warren Zevon, &ldquo;So What&rdquo; by P!nk, and the childhood classic &ldquo;Baa Baa Black Sheep&rdquo;</li>
	<li>
		<strong>Fun Fact: </strong>Camille took her first steps on her first birthday &ndash; IN THE ATALASOFT OFFICE!</li>
</ul>
<p>
	&nbsp;</p>
<blockquote>
	<p align="left">
		<em>&ldquo;My kids have loved the social events that Atalasoft has had for families, and [Atalasoft] has been tolerant of the times I&rsquo;ve had them in the office.&rdquo; &ndash; Steve Hawley, Chief Architect</em></p>
</blockquote>
<p align="center">
	<strong><font face="Lucida Calligraphy" size="4">Alice &amp; Stuart</font></strong></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e631db09-2181-45d4-a398-0ae3c937593f"><img alt="Alice" border="0" height="170" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7ea09390-c483-4a60-ae75-6242e5166ff7" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Alice" width="225" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d384f225-bc35-49be-9d13-a411c44f598b"><img alt="Stuart" border="0" height="170" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a9065650-773b-4797-bbec-a2c979929977" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Stuart" width="225" /></a></p>
<p align="left">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7ba70d74-2140-49ff-a7e1-b4876c149354"><img alt="Stuart and Alice" border="0" height="350" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bf3c376e-1237-446b-bc95-556e0e95ca86" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Stuart and Alice" width="466" /></a></p>
<ul>
	<li>
		<strong>Fun Facts: </strong>Alice has danced in 3 ballets!&nbsp; And Steve is worried that Stuart may someday rule the universe&hellip;</li>
	<li>
		<strong>Link of appreciation: </strong>Check out how Steve&rsquo;s family was <a href="http://atalasoft.com/cs/blogs/support/archive/2011/10/27/old-time-hockey-eh.aspx" target="_blank">supported by a fellow Atalasoft-er</a></li>
</ul>
<p>
	&nbsp;</p>
<p>
	Getting to meet the families of my coworkers and hear outstanding testimonials such as these make me feel SO lucky to work here.&nbsp; I truly believe that Atalasoft&rsquo;s mission to keep its employees close with their families helps all of us in the office feel a little bit closer, too.</p>
]]></description>
     <pubDate>Tue, 28 Aug 2012 15:54:03 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/august-2012/atalakids!]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/august-2012/office-beautification]]></guid>
     <title><![CDATA[Office Beautification]]></title>
     <description><![CDATA[<p>
	Wanting a nice-looking workspace is kind of a no-brainer, but did you know that the physical work environment can actually have scientifically measurable effects on stress?</p>
<p>
	Atalasoft is currently undergoing an &ldquo;Office Beautification&rdquo; process (not that it wasn&rsquo;t beautiful before &ndash; we just want to make it even MORE beautiful!).&nbsp; Of course, me being the psych nerd that I am, I decided to do some research on the types of consequences we might see with our improved workspace.</p>
<p>
	I stumbled across <a href="http://leidenuniv.academia.edu/BartVerkuil/Papers/301834/Effects_of_the_Physical_Work_Environment_on_Physiological_Measures_of_Stress" target="_blank">this article</a> published by Wolters Kluwer and sponsored by the European Society of Cardiology.&nbsp; The study, performed by Thayer et al. in 2009, focused on a group of 60 employees working in the same government building.&nbsp; The building was in the middle of being renovated, which allowed for the splitting of the study group into 2 subgroups according to environment.&nbsp; The first subgroup was located in the older part of the building (the &ldquo;traditional&rdquo; work environment, characterized by separate offices and old-looking cubicles), and the second subgroup in the newly renovated part (composed of new cubicles with improved views and lighting).</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f23d82f5-8c14-4924-89ce-72f09cfc709b"><img alt="Work environment 003" border="0" height="218" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d0371729-42e1-422c-a96b-3bbd39efc86d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Work environment 003" width="289" /></a></p>
<p align="center">
	<em><font size="2">This is the already-beautified part.&nbsp; No improvement needed here!</font></em></p>
<p>
	Researchers looked at two physiological measures of stress response: 1. Circadian variations in vagally mediated heart rate variability (HRV; basically, differences in heartbeat intervals during the day versus at night) and 2. Morning levels of salivary cortisol.&nbsp; Observations were made with the understanding that healthy individuals have prominent variation in HRV (with more variation occurring during the day and a significant decrease in variation at night) and relatively low and stable cortisol levels, especially upon waking.</p>
<p>
	What the scientists found was that the &ldquo;traditional&rdquo; office environment yielded less circadian variation in HRV (meaning that the workers&rsquo; nighttime HRV closely resembled their daytime HRV) and a larger rise of cortisol upon waking as compared to the more modern office environment.&nbsp; So basically, the &ldquo;traditional&rdquo; environment stressed out its workers!</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bc3b576c-d403-465b-96a6-451b1999110b"><img alt="Work environment 014" border="0" height="275" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=925972e5-76c7-4923-af20-3e5277206af2" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Work environment 014" width="207" /></a></p>
<p align="center">
	<em><font size="2">Not gonna lie&hellip; Domo and his OJ stress me out a little bit.</font></em></p>
<p>
	This isn&rsquo;t exactly a revolutionary conclusion; you could probably draw a similar one based on your own personal experience.&nbsp; But it <em>is</em> pretty exciting to finally get some scientific evidence of work environment influence, as few studies have been performed up until this point.</p>
<p>
	I mean, it really just helps to build the case for a nicer office.&nbsp; Past studies have shown that stress at work can lead to increased absenteeism and worker turnover, as well as decreased job satisfaction and productivity.&nbsp; Even worse: stress has been linked to cardiovascular disease.&nbsp; No company wants sick (or dead) workers!</p>
<p>
	While software engineering, sales, and support can be pretty stressful jobs, I&rsquo;d say Atalasoft does its best to buffer the physiological impact with its superior work environment.&nbsp; We&rsquo;ve got a spacious and well-lit suite with brightly painted walls and a fantastic view of Mount Tom.&nbsp; Our offices and cubicles are arranged in a way that allows for socialization and collaboration, but also quiet individual work when necessary.&nbsp; We have a fully-stocked supply of snacks and coffee (with over 20 flavors in the cabinet), and a number of gaming systems available to blow off steam.&nbsp; And dude.&nbsp; We even have a Super Mario mural on our wall.</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=752b141e-be65-4973-a231-b3f66216c17d"><img alt="Work environment 005" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=2619e835-0557-48e1-9263-c616e3042dfa" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Work environment 005" width="244" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ea5868ab-3356-43fe-bcfa-6b750e65e600"><img alt="Work environment 007" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=873f7ad8-1d3f-40a5-8d62-a3caf11bfb5c" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Work environment 007" width="244" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7900a37b-ba6e-40c9-ab0f-6d717ec3e102"><img alt="Work environment 009" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=b5e0b5d2-c4c0-4e27-a8b0-36d7ba1652dc" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Work environment 009" width="244" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=5f7957fe-5dfc-4776-ad29-bd18b268d8d7"><img alt="Work environment 012" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f67c784a-19b6-43a5-ba99-316265762b2f" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Work environment 012" width="244" /></a></p>
<p>
	If you&rsquo;re looking to improve your own work space, there are a few lessons you can learn from Atalasoft:</p>
<p>
	&nbsp;</p>
<ul>
	<li>
		The brighter (paint colors AND lighting), the better</li>
</ul>
<p>
	&nbsp;</p>
<ul>
	<li>
		Every space counts &ndash; including storage closets and bathrooms</li>
</ul>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=37185a5c-39f7-4a47-bf39-084475db93eb"><img alt="Work environment 001" border="0" height="212" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=86114a94-32d4-4da0-8885-9b98abe22524" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Work environment 001" width="282" /></a></p>
<p align="center">
	<em><font size="2">Our bathroom is getting ready for a paint job</font></em></p>
<ul>
	<li>
		Make the office interesting!&nbsp; Decorate your personal work space with action figures from your favorite movies (i.e. an 18&rdquo; Eward Scissorhands collective figurine with sound and motion capability), random toys (like an Airzooka or a singing Triumph, the Insult Comic Dog), or items from a personal collection (it&rsquo;s okay to be a Mickey Mouse fanatic at work!).&nbsp; In common spaces, display old print marketing campaigns in frames, show off the company chocolate fountain, or set up a 5-gallon fish tank.&nbsp; Your goal should be to create a space that encourages individuality, creativity, and passion.</li>
</ul>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dd38366f-f650-451e-a7df-edd3d6d91b12"><img alt="Work environment 015" border="0" height="209" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d77691fd-69c7-49ad-b5b8-ddb27e2ec761" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Work environment 015" width="277" /></a></p>
<p align="center">
	<em><font size="2">I would suggest you don&rsquo;t get on Joann&rsquo;s bad side &ndash; she&rsquo;s got some heavy artillery!</font></em></p>
<p>
	And it can&rsquo;t hurt to make sure the office temperature is above 70 degrees at all times!&nbsp; (Or maybe that&rsquo;s just my personal preference&hellip;)</p>
]]></description>
     <pubDate>Thu, 23 Aug 2012 11:41:42 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/august-2012/office-beautification]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/wings-scanned]]></guid>
     <title><![CDATA[Wings Scanned]]></title>
     <description><![CDATA[<p>
	With almost half of our team away at the Kofax Connections conference in Vegas, it&rsquo;s been a pretty quiet week here at Atalasoft.&nbsp; I was honestly struggling to find something to write about today.&nbsp; I even considered doing a feature on the new office pet, Zebulon!</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=0b527d52-3cdd-4d52-96a0-22e1ee02b4cf"><img alt="Zeb" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9c2868a4-05e8-4006-abdd-2c288f48bb76" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Zeb" width="324" /></a></p>
<p align="center">
	<em><font size="1">He deserves a picture on here, at least.&nbsp; I mean, look at him!&nbsp; He&rsquo;s practically a professional model!</font></em></p>
<p align="left">
	But then something really important happened around lunchtime.&nbsp; Two days ago, we launched a top-secret project involving our latest product, <a href="http://atalasoft.com/products/wingscan/" target="_blank">Wingscan</a>.&nbsp; After many hours of diligent teamwork and impeccable organization, we finished our highly-anticipated masterpiece.</p>
<p align="left">
	Ladies and gentlemen, I give you&hellip;</p>
<p align="center">
	<font color="#ff0000" size="6">Project: WINGSCANNED!!!</font></p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=538e5186-d380-4222-b84d-9411d0bd6de6"><img alt="wingscanned" border="0" height="315" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=78c1fc4f-ab5e-4864-bb73-3d64a47dfef1" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="wingscanned" width="365" /></a></p>
<p align="center">
	<em><font size="1">Yes, this is an actual scan of Honey BBQ wings.</font></em></p>
<p>
	&nbsp;</p>
<p>
	Stay tuned for a post about our next masterpiece-in-the-making, Project: Office Beautification!</p>
]]></description>
     <pubDate>Fri, 27 Jul 2012 14:42:32 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/wings-scanned]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/putting-on-our-thinking-caps]]></guid>
     <title><![CDATA[Putting on our Thinking Caps]]></title>
     <description><![CDATA[<p>
	Having attended a school that prides itself on Individual, Global, and Exceptional Critical Thinkers (holla atcha, <a href="http://www.smith.edu/" target="_blank">Smith College!</a>), I was pretty sure I knew it all when it came to thinking about thinking.&nbsp; But once again, Atalasoft has managed to add another lesson to my mental book of knowledge.</p>
<p>
	Earlier in the week I was asked to help organize a special meeting for our Engineering/Development department.&nbsp; The discussion was to be about development obstacles that were met in Fiscal Year 2012, and it was to be conducted using the <a href="http://www.edwdebono.com/Book/1005" target="_blank">Six Thinking Hats</a> method.</p>
<p>
	Um&hellip;what?</p>
<p>
	The scholar in me ravenous for information, I immediately began researching the technique.&nbsp; What I found was like nothing I had encountered before.</p>
<p>
	<a href="http://www.edwdebono.com/Book/1005" target="_blank"><em>Six Thinking Hats</em></a><em>&nbsp;</em>was developed by <a href="http://www.edwdebono.com/" target="_blank">Edward de Bono</a> in 1985 as a tool for helping groups to think more collaboratively and effectively about a problem.&nbsp; The group is encouraged to put on six different &ldquo;thinking hats&rdquo;, each having its own color, in order to address the problem from multiple angles.&nbsp; The idea is to get people out of their usual thinking patterns (no more Positive Pollys and Negative Nancys!) and to create a more defined segregation of thinking directions.</p>
<p>
	So what are these &ldquo;hats&rdquo; I speak of?</p>
<p align="center">
	<font color="#0000ff" size="4"><strong>THE BLUE HAT</strong></font></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=54897925-edc6-4298-b0f9-607a99613b01"><img alt="blue hat 2" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=63e9956e-c06c-4d37-90ab-06167feb63fc" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="blue hat 2" width="244" /></a></p>
<p>
	<font color="#0000ff">The blue hat is the <strong>facilitator</strong>.&nbsp; Its role is to set the <strong>agenda</strong> for the discussion, as well as to <strong>focus</strong> and <strong>refocus</strong> the group.&nbsp; It tells the group when to <strong>switch hats</strong>, and informs as to any <strong>next steps</strong> or important <strong>decisions</strong>.</font></p>
<p>
	&nbsp;</p>
<p align="center">
	<font color="#a5a5a5" size="4"><strong>THE WHITE HAT</strong></font></p>
<p align="center">
	<strong><font color="#a5a5a5" size="4"><a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=42d0d370-2967-4c34-8cad-12adcb2126b5"><img alt="white hat" border="0" height="189" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=0ddd1e78-f135-4632-a1f2-6078668b17d4" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="white hat" width="244" /></a></font></strong></p>
<p align="left">
	<font color="#666666">The white hat is all about the <strong>facts</strong>.&nbsp; It wants to know what information is <strong>readily available</strong> about the problem at hand, and any proof to back it up.&nbsp; It also looks for what information is <strong>missing</strong>, and what the group would <strong>like</strong> to know and <strong>needs</strong> to know.</font></p>
<p align="left">
	&nbsp;</p>
<p align="center">
	<strong><font color="#008000" size="4">THE GREEN HAT</font></strong></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f0bab8e5-a239-446e-894c-027fb54ccd3f"><img alt="green hat" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=266eabd6-6c36-4fed-a5e7-a9d5ebd75b4d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="green hat" width="228" /></a></p>
<p align="left">
	<font color="#008000">The green hat is <strong>creative</strong> and <strong>innovative</strong>.&nbsp; It <strong>proposes solutions</strong> and means of <strong>overcoming</strong> difficult situations.&nbsp; It is also always looking for <strong>alternative</strong> methods of getting things done.</font></p>
<p align="left">
	&nbsp;</p>
<p align="center">
	<strong><font color="#dfce04" size="4">THE YELLOW HAT</font></strong></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=77d9e7b9-f07b-4704-904c-9f943d75becf"><img alt="yellow hat 2" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=47521be6-c906-49b3-b615-68878be4a994" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="yellow hat 2" width="205" /></a></p>
<p align="left">
	<font color="#ccb400">The yellow hat is primarily <strong>optimistic</strong> and <strong>positive</strong>.&nbsp; It asks &ldquo;What are the<strong> benefits</strong> of solving this problem?&rdquo;&nbsp; It seeks to identify the <strong>attractive</strong> qualities of the ideas being discussed, and hopes to encompass the group&rsquo;s <strong>values</strong>.</font></p>
<p>
	&nbsp;</p>
<p align="center">
	<font color="#000000" size="4"><strong>THE BLACK HAT</strong></font></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d00ee5f1-9625-4832-be16-7a13f4f74255"><img alt="black hat" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1dcf6bbb-8bc8-4b19-a384-9b9d6d7b6e37" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="black hat" width="244" /></a></p>
<p>
	The black hat is the <strong>conservative</strong> one of the bunch.&nbsp; It wants to point out the potential <strong>problems</strong> with the proposed solutions, and elaborate on areas of <strong>caution</strong> and <strong>risk</strong>.&nbsp; It is mostly <strong>logical</strong>, but at times just plain <strong>negative</strong>.</p>
<p>
	&nbsp;</p>
<p align="center">
	<font color="#ff0000" size="4"><strong>THE RED HAT</strong></font></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=13cacd62-a01e-4ac9-98fd-2cd6e940e9e8"><img alt="red hat" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ee26f50d-7e69-4b14-9aac-858edd96e4b3" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="red hat" width="200" /></a></p>
<p>
	<font color="#ff0000">The red hat needs <strong>no justification</strong>.&nbsp; It is purely <strong>emotional</strong>.&nbsp; It explores the group&rsquo;s current <strong>feelings</strong> and <strong>gut reactions</strong>, and relies only on <strong>intuition</strong>.</font></p>
<p>
	&nbsp;</p>
<p>
	I&rsquo;m not gonna lie.&nbsp; When I started reading about this method, my first thought was: &ldquo;What the heck is this loony new-age crap?!&rdquo;&nbsp; But the more I read, the more it all started to make sense.&nbsp; And I began to believe <em>Hey &ndash; this de Bono guy might actually be onto something!</em></p>
<p>
	As the official whiteboard note-taker of today&rsquo;s meeting, I can say this with conviction: BOY is my arm tired!&nbsp; Engineering brainstormed like nobody&rsquo;s business, and for TWO STRAIGHT HOURS!&nbsp; Not only did the team identify a number of creative solutions to the FY12 problems, but they also developed a pretty comprehensive and realistic game plan for the upcoming year.</p>
<p>
	My favorite part of the meeting today, though: EVERYONE participated.&nbsp; Even the n00bz.&nbsp; Not a single person was silenced by another who was dominating the conversation.&nbsp; This was seriously the most productive, effective, and inclusive discussion I have ever witnessed.</p>
<p>
	And we got donuts!</p>
]]></description>
     <pubDate>Mon, 23 Jul 2012 15:04:17 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/putting-on-our-thinking-caps]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/the-place-we-call-home]]></guid>
     <title><![CDATA[The place we call home]]></title>
     <description><![CDATA[<p>
	&ldquo;It&rsquo;s not the looks that count.&nbsp; It&rsquo;s what&rsquo;s on the <em>inside</em> that really matters.&rdquo;</p>
<p>
	Usually this phrase is applied to young bachelors and bachelorettes in pursuit of a relationship.&nbsp; But as the daughter of a realtor, I&rsquo;ve heard it used a number of times in reference to homes and commercial buildings.&nbsp; Amongst my favorite real estate euphemisms:&nbsp; &ldquo;This home is simply <em>charming</em>!&rdquo; and &ldquo;This building has so much <em>potential</em>.&rdquo;&nbsp; Basically, these phrases are used in place of &ldquo;This place could be really cool&hellip;but it&rsquo;s not.&rdquo;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dbc6c24a-2693-4605-9e4f-bd917bc20ac1"><img alt="Eastworks 045" border="0" height="243" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=adb003af-3de8-4eb8-ada5-584ad81bdf1d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; clear: both; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Eastworks 045" width="323" /></a></p>
<p align="center">
	<em><font size="1">Welcome to our humble abode: Eastworks</font></em></p>
<p>
	One thing that immediately impressed me when walking into my first interview was Atalsoft&rsquo;s physical work environment.&nbsp; I&rsquo;m not just talking about the office itself, but rather our habitat in the <a href="http://eastworks.com/site/" target="_blank">Eastworks</a> building.&nbsp; I mean, our office is pretty awesome and stuff (and I&rsquo;ll most likely take you on a virtual tour at some point &ndash; after I complete my current Office Beautification project).&nbsp; But we&rsquo;re also part of an eclectic collection of small businesses housed inside this unique and historic space.&nbsp; <a href="http://eastworks.com/site/" target="_blank">Eastworks</a> has it all: funky-cool local businesses on the inside, retro-modern awesome looks on the outside.</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=128a949a-bce4-4257-8474-b8c387bd2df4"><img alt="Eastworks 041" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=3a33f9fe-71a1-4aca-93d7-ad912ebc6f7a" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks 041" width="184" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a6acfc12-dba6-4135-bed9-45595677244d"><img alt="Eastworks 044" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ebd415e9-6bb8-44c8-b37b-3f7279b0c0e8" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks 044" width="184" /></a></p>
<p align="center">
	<em><font size="1">Some of our first floor residents (Easthampton has a thing for <a href="http://easthamptonbearfest.com/" target="_blank">bears&hellip;</a>)</font></em></p>
<p>
	3 months in and still fascinated by my workspace, I decided to do some research.</p>
<p>
	&nbsp;</p>
<p align="center">
	<em><font size="4">*****Cue Sepia-toned flashback sequence*****</font></em></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a629f42e-33af-4e48-a713-14cb0ec7bb8a"><img alt="West Boylston Textile Company" border="0" height="240" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9b4cb1dc-c7e1-41ef-9286-f17e3756543d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="West Boylston Textile Company" width="331" /></a></p>
<p align="center">
	<font size="1">The West Boylston Textile Company</font></p>
<p>
	The <a href="http://eastworks.com/site/" target="_blank">Eastworks</a> building was established on the banks of Lower Mill Pond in 1899 as the West Boylston Textile Company.&nbsp; Its founding was merely a small piece of the much larger Industrial Revolution, which began sweeping the nation in the 1820s and hit Easthampton in 1847 in the form of the Williston-Knight Button Company.&nbsp; The two factories, in addition to another cloth mill called The Hampton Company, played an important role in the urbanization of the once strictly agricultural town.&nbsp; Their success beefed up the population, largely due to the influx of Polish and Canadian immigrant workers, and sparked the development of several schools and churches.&nbsp; Simultaneously, the mill environment encouraged the growth of smaller business and community-based services (like the library, town hall, and a national bank).</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1ed46165-9d77-4ad2-b6de-1528cd6cdde7"><img alt="Stanhome cornerstone" border="0" height="271" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=238de02f-c971-452f-a6ea-67b45dec51ec" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Stanhome cornerstone" width="219" /></a></p>
<p align="center">
	<font size="1">Frank Stanley Beveridge and his cornerstone</font></p>
<p>
	In 1931, Frank Stanley Beveridge and wife Catherine O&rsquo;Brien took over the factory complex with their business, <a href="http://www.shponline.com/english/shop.asp" target="_blank">Stanley Home Products</a>.&nbsp; The first floor of the building housed their production lines; laboratory testing took place on the third floor, and freight delivery was in the basement (the use of the second floor is still a mystery to me!).&nbsp; The company produced high-quality cleaning products, such as cleaning solutions, brushes, and mops, and went on to become pioneers in home party demonstrations (you know, like Tupperware parties).&nbsp; <a href="http://www.shponline.com/english/shop.asp" target="_blank">Stanley Home Products</a> is still around today, but obviously not here in the <a href="http://eastworks.com/site/" target="_blank">Eastworks</a> building &ndash; their headquarters are now in Agawam.</p>
<p align="center">
	<em>A little bit of Then and Now&hellip;</em></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=cdea0028-7448-42b1-ad99-e6b4ecf85080"><img alt="Eastworks production line" border="0" height="183" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=4ebe9a8b-cd31-409f-81c4-7385c96ec49b" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks production line" width="244" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=94cf0968-ca37-404a-937c-74509108cf36"><img alt="Eastworks 039" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=77e1cdfe-2ee6-4e33-9b5e-6e660d103b5d" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks 039" width="244" /></a></p>
<p align="center">
	<em><font size="1">The first floor (a little more colorful now&hellip;hah!)</font></em></p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bd0d8739-94ed-4090-a365-b1373667f8d0"><img alt="Eastworks lab" border="0" height="181" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=020f4b33-cf70-472a-a381-4f1602027507" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks lab" width="244" /></a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e94d118e-9dd9-492e-b53a-bc080232efcf"><img alt="Eastworks 051" border="0" height="184" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1afe877a-12af-429b-a021-b3cfd5c66e3b" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Eastworks 051" width="244" /></a></p>
<p align="center">
	<em><font size="1">The third floor (check out our shiny new floor!)</font></em></p>
<p>
	The old <a href="http://www.shponline.com/english/shop.asp" target="_blank">StanHome</a> building was purchased in 1997 by private developer Will Bundy, who had the intention of converting the factory into a mixed-use community building.&nbsp; And that&rsquo;s exactly what he produced!</p>
<p align="center">
	<font size="4"><em>*****End of historical montage*****</em></font></p>
<p align="center">
	&nbsp;</p>
<p align="left">
	<a href="http://eastworks.com/site/" target="_blank">Eastworks</a> is now home to over 85 individual businesses in industries ranging from food and entertainment, to the arts, healthcare, non-profit, and more. You can go to the 1st floor to get yo hair did at <a href="http://www.theliftsalon.com/" target="_blank">The Lift</a>, then grab a burger from <a href="http://www.riffsjoint.net/" target="_blank">Riff&rsquo;s Joint</a> or a quesadilla from <a href="http://apollo-grill.com/" target="_blank">Apollo Grill</a>, work off those calories at <a href="http://www.renewpilates.com/" target="_blank">Renew Pilates Studio</a> on the 2nd floor, buy some sweet SDKs from <a href="http://atalasoft.com/" target="_blank">us</a> on the 3rd floor, and then go take an afternoon nap in your cozy-chic <a href="http://eastworks.com/site/2012/01/11/livework-loft-apartments/" target="_blank">loft apartment</a> on the 4th floor. (Check out the full business directory <a href="http://eastworks.com/site/our-community/tenant-directory/" target="_blank">here</a>.)</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d0ff02c9-acc8-4cb7-a919-01e48e37f8a1"><img alt="the invisible fountain" border="0" height="192" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=94ca9f9b-e757-4310-96f9-db5a15c80069" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="the invisible fountain" width="286" /></a></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d6a67856-656e-4ab4-89b6-a78d814b2dba"><img alt="pioneer valley ballet" border="0" height="115" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d6bea57d-658f-40d5-82cf-cd9bac0f28a2" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="pioneer valley ballet" width="286" /></a></p>
<p align="center">
	<em><font size="1">Two of Eastworks&rsquo; artsier tenants, <a href="http://www.invisiblefountain.com/" target="_blank">The Invisible Fountain</a> and <a href="http://www.pioneervalleyballet.org/" target="_blank">Pioneer Valley Ballet</a></font></em></p>
<p>
	This building literally has everything you could possibly need.&nbsp; When the Zombie Apocalypse inevitably occurs, just go down to the basement to borrow some metal from the blacksmith or various sculptors, use it to board up all the windows, and you&rsquo;ll be set for weeks!</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9f368477-f5d5-40d3-ab25-9545691dd869"><img alt="zombie home" border="0" height="288" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=31d8f32d-554b-498d-8f63-7b7e327b8a5e" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="zombie home" width="212" /></a></p>
<p align="center">
	<em><font size="1">Kinda like this!</font></em></p>
<p>
	But seriously.&nbsp; This is the coolest building ever.&nbsp; I love that I can point it out while driving by with family and friends and go &ldquo;Yeah.&nbsp; I work there.&rdquo;&nbsp; BOOYAH!</p>
]]></description>
     <pubDate>Thu, 12 Jul 2012 16:26:12 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/july-2012/the-place-we-call-home]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/july-2012/the-importance-of-writing-good-specifications]]></guid>
     <title><![CDATA[The Importance of Writing Good Specifications]]></title>
     <description><![CDATA[<p>
	The message in this blog article is very simple: write good specifications.&nbsp; The word &lsquo;good&rsquo; is problematic as it is terribly broad, so let&rsquo;s narrow it down a little bit.&nbsp; A good specification is simple, clear and unambiguous and when it is impossible to avoid ambiguity, it should describe how to resolve any ambiguity.&nbsp; The <a href="http://www.w3.org/TR/SVG/Overview.html">SVG specification</a> contains a good lesson in how to not do this, which I will talk about in detail.&nbsp; First, let&rsquo;s talk about the various ways that can be used to specify geometrical figures.</p>
<p>
	For most geometric figures, there are multiple ways that they can be specified.&nbsp; For example, a line (infinite) or a line segment can be specified by two points (<em>x<sub>1</sub>, y<sub>1</sub></em>) and (<em>x<sub>2</sub>, y<sub>2</sub></em>).&nbsp; In most applications, this is convenient and compact, but let&rsquo;s consider another way of representing a line:</p>
<p>
	Slope/intercept (from the formula <em>y</em> = <em>mx</em> + <em>b</em>, where <em>m</em> is the slope, <font face="Symbol">D</font><em>x</em>/<font face="Symbol">D</font><em>y</em>, and <em>b</em> i s the y intercept)</p>
<p>
	You should know this well from basic algebra.&nbsp; So we can take that and say that we will represent our line as (<em>m</em>, <em>b</em>).&nbsp; This is nice &ndash; it&rsquo;s more compact than the four points.&nbsp; The problem with it is that <em>m</em> is undefined when the line is vertical.&nbsp; Oops.&nbsp; If we specified slope intercept, we&rsquo;d need a way to deal with that.&nbsp; Maybe a flag that says that when the flag is true, the formula is to be interpreted as <font face="Symbol">D</font><em>y</em>/<font face="Symbol">D</font><em>x</em> and <em>m</em> is the x intercept.&nbsp; OK, that fixes that problem, but it makes the spec more complicated.</p>
<p>
	This can be used to define a line &ndash; what about a segment?&nbsp; How about a starting point and a length?&nbsp; Now our spec is (<em>m</em>, <em>b</em>, <em>f</em>, <em>x<sub>1</sub>, y<sub>1</sub></em>, <em>l</em>).&nbsp; This is also ambiguous, because we don&rsquo;t know which side of the point to extend the length (maybe it&rsquo;s centered).&nbsp; You see what&rsquo;s happening?&nbsp; Something that started relatively simply is just getting worse and worse.</p>
<p>
	Now consider the SVG specification for elliptical arcs &ndash; the parameters that define it are (<em>rx</em>, <em>ry</em>, <font face="Symbol">j,</font> <em>large-arc-flag</em>, <em>sweep-flag</em>, <em>x</em>, <em>y</em>) where <em>rx</em> and <em>ry</em> are the radii of the ellipse, <font face="Symbol">j</font> is the a rotation angle relative to the x-axis, <em>large-arc-flag</em> defines whether to use the large piece of the arc or the small piece, <em>sweep-flag</em> defines the which of two elliptical paths to select that could fit the data, and (x, y) are the end point of the arc.&nbsp; The start point is implicitly defined by previous path.&nbsp; To help you out, here is an illustration from the spec:</p>
<p>
	<img alt="Illustration of flags in arc commands" src="http://www.w3.org/TR/SVG/images/paths/arcs02.png" style="display: block; float: none; margin-left: auto; margin-right: auto" /></p>
<p>
	&nbsp;</p>
<p>
	technically this is a correct way to describe an elliptical arc, but it is wrong in so many ways.&nbsp; First, it is ambiguous.&nbsp; I can provide an ending point and radii for which there are no solutions and if you code up the math to solve for the ellipse, you will only find out about the problem when you need to take the square root of a negative number.&nbsp; No worries, the spec describes what you should do in these cases, in what also turns out to be an ambiguous and overly complicated fashion.&nbsp; Seriously.&nbsp; <a href="http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes">Check it out</a>.&nbsp; It requires an unnecessary wall of math which turns into a wall of code.&nbsp; In addition, if the start and end points are 180 degrees out of phase, there is no large arc &ndash; they&rsquo;re both the same size.&nbsp; Which do you pick?&nbsp; Finally, the x-axis angle, <font face="Symbol">j</font>, is totally redundant since any shape can be contained within a transform.</p>
<p>
	To be generous, there is one and only one reason I can think of for this that it&rsquo;s fairly simple to decide the two points that start and end the arc if you&rsquo;re hand-coding SVG, but the other ambiguities outweigh this benefit in my opinion.</p>
<p>
	Instead, they should use the specification (<em>cx</em>, <em>cy</em>, <em>rx</em>, <em>rx</em>, <font face="Symbol">q</font><sub>1</sub>, <font face="Symbol">q</font><sub>2</sub>, <em>cw</em>), where cx and cy are the coordinates of the center of the ellipse, <em>rx</em> and <em>ry</em> are the radii, <font face="Symbol">q</font><sub>1</sub> and <font face="Symbol">q</font><sub>2</sub> are the start and end angles of the ellipse in degrees, and <em>cw</em> determines if the arc should be drawn clockwise or counterclockwise from <font face="Symbol">q</font><sub>1</sub> to <font face="Symbol">q</font><sub>2</sub>.&nbsp; This spec is simpler to implement and impossible to get incorrect values.&nbsp; You could simplify it further and remove <em>rx</em> and <em>ry</em> and instead use a parent scale transform to set the radii, if you wanted.</p>
<p>
	To a certain extent, I prefer the PDF approach to representing arcs and circles: you don&rsquo;t.&nbsp; In PDF there are only Bezier curves and the specification is very simple.&nbsp; While drawing a Bezier curve is also simple, it can be tricky to do it efficiently.&nbsp; Also, circles can&rsquo;t be represented by Beziers without error.&nbsp; Fortunately, <a href="http://www.tinaja.com/glib/ellipse4.pdf">Don Lancaster has a great article</a> on how to approximate circles and minimize the error.&nbsp; If you use Atalasoft&rsquo;s <a href="http://atalasoft.com/products/dotpdf">DotPdf</a> toolkit, you&rsquo;ll get high-level shapes that implement this for you (as well as SVG-&gt;PDF conversion).&nbsp; On another day, I&rsquo;ll share how I turn an elliptical arc into Beziers.&nbsp; In the meantime, write good specifications!</p>
]]></description>
     <pubDate>Tue, 10 Jul 2012 10:51:03 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/july-2012/the-importance-of-writing-good-specifications]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/june-2012/cubicle-from-the-future]]></guid>
     <title><![CDATA[Cubicle from the Future]]></title>
     <description><![CDATA[<p>
	One thing that Atalasoft knows how to do really well is HAVE FUN.&nbsp; Don&rsquo;t get me wrong - we work our tookuses off too!&nbsp; It&rsquo;s kind of a work-hard-play-hard mentality.</p>
<p>
	June 28th (last Thursday) was my birthday, so, naturally, I wanted to play a little.&nbsp; The previous week Christina had sent me an inspirational photo she found on <a href="https://www.facebook.com/photo.php?fbid=10150891858573244&amp;set=a.165650018243.120646.86020888243&amp;type=1&amp;theater" target="_blank">Fuzz Production&rsquo;s facebook page</a>, along with a link to a similar one on a website called <a href="http://www.officecubiclepranks.com/Office-Pranks/aluminum-foil-office-prank.html" target="_blank">Office Cubicle Pranks</a>.&nbsp; The topic came up at lunch on Wednesday the 27th, and I decided that as my one request for my birthday, I wanted to pull this prank on someone.&nbsp; And that someone was my cube neighbor, Kevin Hanks.</p>
<p>
	Now Kevin Hanks is a bit of a jokester himself.&nbsp; Just a week or two ago, he admitted to hiding our old doorbell in Eric Deutchman&rsquo;s (Marketing Manager) office for about a month and pressing the ringer button from his desk a discreet 10-20 times per day.&nbsp; Antics such as this have prompted the nickname Kevin PRANKS (which I actually made up, like, yesterday&hellip; but it&rsquo;s totally gonna catch on!).</p>
<p>
	So Wednesday afternoon, right after Kevin left for the day, we decided to give him a dose of his own medicine.&nbsp; Christina and I (with a little help from Eric) covered Kevin&rsquo;s desk in 150 square feet of tinfoil.</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=c08876e8-b406-42e3-ad0b-04825ceed2c4"><img alt="Kevin Pranks 002" border="0" height="233" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1b878bb8-0b7f-4e54-9ab4-bc65ed1cd11c" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Kevin Pranks 002" width="309" /></a></p>
<p>
	&nbsp;</p>
<p>
	Of course we went for big things, like his monitors and desk chair, but the beauty was all in the details: a paper clip, a box of tissues (I definitely wrapped an actual tissue and stuck it in the box), even a bag of Ruffles chips sitting next to his phone.&nbsp; It was so shiny&hellip;so pretty&hellip;so&hellip;perfect&hellip;</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=cb271798-442f-42cd-9060-03019374c53a"><img alt="Kevin Pranks 005" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=8ed8d616-c788-4d85-9549-cb63ff4d52d1" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Kevin Pranks 005" width="164" /></a>&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=e1ace1b1-3951-4ccf-8a88-9be5f78e61c5"><img alt="Kevin Pranks 008" border="0" height="242" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=37aee5c4-f343-4a19-83ba-b76835561d44" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Kevin Pranks 008" width="312" /></a>&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=6e50a3ab-761e-4330-915e-0f684fea5988"><img alt="Kevin Pranks 004" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=45279475-c819-4df2-afa6-77241eecdb58" style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Kevin Pranks 004" width="164" /></a></p>
<p>
	&nbsp;</p>
<p>
	I got in the office a little early on Thursday so that I could see Kevin&rsquo;s reaction.&nbsp; I didn&rsquo;t even go into the kitchen to get breakfast, for fear that I would miss the big moment.&nbsp; And it was absolutely worth the tummy grumbles because I caught the whole thing on film!</p>
<p>
	&nbsp;</p>
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c8c04d24-d3cd-4df4-83cb-6160623d634b" style="padding-bottom: 0px; padding-left: 0px; width: 448px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px">
	&nbsp;</div>
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/UrYJ_DKwi3k" width="560"></iframe>
<div style="width:448px;clear:both;font-size:.8em">
	It&rsquo;s like Christmas morning!</div>
<p>
	&nbsp;</p>
<p>
	In the end, Kevin handled it well.&nbsp; In fact, he even <em>liked</em> it.&nbsp; Look how happy he is in his new Cubicle from the Future:</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=d9b2039f-8a35-458d-abe8-46aa2881d571"><img alt="Kevin Pranks 019" border="0" height="269" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7db894dc-5bcc-420e-9d69-2cfbd3062c96" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Kevin Pranks 019" width="357" /></a></p>
<p>
	&nbsp;</p>
<p>
	I&rsquo;m sure he&rsquo;ll get me back some day.&nbsp; I&rsquo;ll be ready for it.&nbsp; I&rsquo;ve got my big girl pants on.&nbsp; Until then, this is Amy Crawford, Professional Prankster &ndash; signing out.</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f3a741cf-a4ab-4745-9e10-57947dfc4202"><img alt="Kevin Pranks 011" border="0" height="282" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=88027ebd-b088-4112-8bac-105b96a49c77" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Kevin Pranks 011" width="375" /></a></p>
<p>
	&nbsp;</p>
<p>
	Check out the rest of the photos <a href="https://www.facebook.com/media/set/?set=a.10150935454369011.423730.6034814010&amp;type=1" target="_blank">here on our facebook page</a>!</p>
]]></description>
     <pubDate>Fri, 06 Jul 2012 10:55:54 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/june-2012/cubicle-from-the-future]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/office/june-2012/i-come-bearing-bacon!]]></guid>
     <title><![CDATA[I come bearing BACON!]]></title>
     <description><![CDATA[<p>
	<em>What&rsquo;s up party people! Christina here. Since I&rsquo;ve done a bang-up job keeping the blog updated (sarcasm tag), Amy graciously offered to take the reins.&nbsp; You are in extremely capable hands, and I&rsquo;ll just be like the googly muppet-eye of Sauron back here.</em></p>
<p>
	<br />
	Why, hello there!</p>
<p>
	<br />
	My name is Amy, and I&rsquo;m your new Atalasoft Office blogger.&nbsp; I was hired in March, two months before I even graduated from Smith College, as an office administrator (well, <em>the</em> office administrator, as I am the one and only).&nbsp; I have spent the last few months making the absolute easiest transition from the world of academia to the world of the 40-hour-work-week.&nbsp; And why?&nbsp; BECAUSE I WORK IN THE COOLEST OFFICE EVER.</p>
<p>
	<br />
	<em>Gee-whiz, Amy</em>, you&rsquo;re probably thinking,<em> that&rsquo;s a pretty bold statement to</em> <em>make!</em>&nbsp; This is true.&nbsp; But I&rsquo;m hoping that my blog will give you some idea of why I feel comfortable making that assertion.&nbsp; I&rsquo;ll be posting pictures, videos, and little text tidbits of all the latest office going-ons so that you can learn more about Atalasoft and the intelligent, hilarious, passionate, and quirky individuals who make up this company.</p>
<p>
	<br />
	And I don&rsquo;t mess around.&nbsp; I&rsquo;m starting out with a doozie.</p>
<p>
	&nbsp;</p>
<p align="center">
	<strong><font size="4">BACON WEEK, JUNE 2012</font></strong></p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1429cc88-71cd-4024-9509-0812a30b9b81"><img alt="Bacon Week June 2012 019" border="0" height="214" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=fc0ac338-2ff1-4afa-9867-ef8f30745bee" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Bacon Week June 2012 019" width="284" /></a></p>
<p>
	<br />
	As you may or may not know, Atalasoft has a <em>thing</em> for bacon.&nbsp; And by <em>thing</em> I mean a <em>burning passion of a thousand fiery suns</em>.&nbsp; Traditionally, we celebrate this love on Bacon Day.&nbsp; We order some gourmet cuts of bacon and fry them up on the griddle, along with a few side dishes (English muffins fried in bacon grease, scrambled eggs fried in bacon grease, coffee cake/potatoes/sticky buns fried in bacon grease if possible, etc.), and have a big breakfast for everyone in the office.&nbsp; And then we get back to work with bacon-y goodness in our bellies and a greasy grin on our faces.</p>
<p>
	&nbsp;</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=100c4556-770d-47d6-a1e9-8b8a843f69e5"><img alt="bacon peanut butter cupcakes" border="0" height="194" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a3748a87-3bc5-493e-bec9-e137bba2fd45" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="bacon peanut butter cupcakes" width="257" /></a></p>
<p align="center">
	&nbsp;</p>
<p align="center">
	<em><font size="2">Yeah, I made those.&nbsp; Peanut butter bacon cupcakes.&nbsp; Mmm.</font></em></p>
<p>
	Part of my job is event planning, and with this being my first encounter with any sort of bacon celebration, I wanted to plan something extra special.&nbsp; So Christina (Director of Human Resources/Director, Ministry of Culture) and I came up with the idea for BACON WEEK.&nbsp; Each day, we had volunteers bring in a bacon-y treat for all to share in anticipation of our Big Bacon Breakfast Fiesta on Friday.&nbsp; I also ordered some novelty bacon items to raffle off as prizes, and we gave away the new company t-shirt (also featuring bacon) to everybody at the end of the week.</p>
<p align="center">
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=14aef7fe-b943-4977-8791-727900594d61"><img alt="Ken and mfb" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7f67ce24-c50b-42f2-990c-e7819cbe5858" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Ken and mfb" width="184" /></a>&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=9191c8ca-02f0-4d45-968b-9b4f3981da71"><img alt="Bacon Week June 2012 031" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=1985a5bb-ac28-4104-9886-ae0c4503e5b1" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Bacon Week June 2012 031" width="184" /></a>&nbsp;&nbsp; <a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=dd9b1f03-1785-4e14-a4fa-11f655fa1159"><img alt="Bacon Week June 2012 027" border="0" height="244" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bf1d72ed-8409-4cc1-abc2-533b5a337870" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Bacon Week June 2012 027" width="184" /></a></p>
<p>
	<br />
	The event was a great success!&nbsp; Christina and I were a little nervous about the timing due to the looming year-end deadlines, but I think the bacon ended up nurturing productivity by keeping spirits high during this time of stress.</p>
<p>
	Personally, Bacon Week left me feeling inspired.&nbsp; I don&rsquo;t mean by the bacon itself (although, being in the presence of the Best Meat Product Known to Mankind can be pretty inspiring&hellip;).&nbsp; Rather, I was inspired by the atmosphere it created &ndash; an atmosphere of creativity, excitement, teamwork, and good humor; an atmosphere you can&rsquo;t wait to be a part of once again the next day, and the next, and the next.&nbsp; And I am so grateful that I am in a position to help create that sort of environment, because making other people happy is what really tickles my fancy/fuels my fire/floats my boat/rocks my socks/makes me want to speak in clichés.</p>
<p>
	<br />
	I can honestly say that I ate more bacon last week than I had for the entire last two years of my life.&nbsp; And I can&rsquo;t wait to do it again.</p>
<p>
	<br />
	Check out our Bacon Week album <a href="https://www.facebook.com/media/set/?set=a.10150935454369011.423730.6034814010&amp;type=1" target="_blank">here on our facebook page</a>.</p>
<p>
	<br />
	And I shall leave you with this:<br />
	&nbsp;</p>
<iframe width="560" height="315" src="http://www.youtube.com/embed/61YSpOZdXSU" frameborder="0" allowfullscreen></iframe>
<div style="width:448px;clear:both;font-size:.8em">
	Sizzle&hellip;.sizzle&hellip;sizzle&hellip;</div>
<p>
	&nbsp;</p>
<p>
	&hellip;Jealous yet?</p>
]]></description>
     <pubDate>Thu, 28 Jun 2012 10:14:20 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/office/june-2012/i-come-bearing-bacon!]]></link>
     <dc:creator> Office</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/june-2012/wow,-it’s-been-quiet]]></guid>
     <title><![CDATA[Wow, It’s Been Quiet]]></title>
     <description><![CDATA[<p>
	Have you heard the crickets?&nbsp; I&rsquo;m not surprised.&nbsp; The one thing you can count on when the blogs run thin is that we&rsquo;re <em>very</em> busy and that there are exciting things on the horizon.&nbsp; I can&rsquo;t talk about those things yet, but I can tell you about another thing that&rsquo;s been taking a lot of my time.</p>
<p>
	One thing you should consider when you are a software engineer is your health.&nbsp; Seriously.&nbsp; Software engineering is a sedentary job.&nbsp; This is unfortunate, but it is what it is.&nbsp; It is then your responsibility to take care of yourself.&nbsp; When you are in good physical condition, you are more relaxed, you sleep better, you think better, etc.&nbsp; But there are times when we are in crunch mode and can&rsquo;t exercise, right?&nbsp; Nonsense.&nbsp; First, crunch time shouldn&rsquo;t exist &ndash; I believe it is the result of poor planning.&nbsp; Second, if you&rsquo;re under the gun, you should absolutely sleep and exercise.&nbsp; You&rsquo;ll introduce fewer bugs.</p>
<p>
	Atalasoft has a lot of runners.&nbsp; We have three people who have run marathons, a couple people who are doing roller derby, and so on.&nbsp; Being active is part of the Atalasoft engineering culture, for sure.&nbsp; Last year, I did the <a href="http://www.coolrunning.com/engine/2/2_3/181.shtml">couch to 5K program</a> and found it worked quite well.&nbsp; I did the routine with two other coworkers, which was nice.&nbsp; This year, I did a crazy thing.&nbsp; I&rsquo;ll fill you in, but first let me give you some background.&nbsp; This is my daughter, Alice:</p>
<p>
	<img src="http://farm8.staticflickr.com/7245/7373687570_79933d9eb3_z.jpg" style="display: block; float: none; margin-left: auto; margin-right: auto" /></p>
<p>
	She is a funny, energetic 9 year-old girl.&nbsp; She also has Down syndrome.&nbsp; It&rsquo;s been a challenge to be a parent to a child with special needs, to say the least.&nbsp; Fortunately, there are organizations all around the world for helping people with Down syndrome and their families as well as their educators.&nbsp; In Massachusetts, we are involved with the <a href="http://www.mdsc.org/">Massachusetts Down Syndrome Congress</a>, which has been invaluable in helping us and other families in the state.&nbsp; I can&rsquo;t imagine trying to navigate through life without their information and guidance.</p>
<p>
	This past spring, they announced that they had secured a handful of slots in the <a href="http://www.falmouthroadrace.com/">Falmouth Road Race</a>.&nbsp; The race is a highly competitive 7 mile race held in August in Falmouth, Massachusetts.&nbsp; The catch?&nbsp; Runners under their name need to raise money for the MDSC.&nbsp; To me this is a slam dunk.&nbsp; So since early March, I have been training to get my distance up to 7 miles.&nbsp; For me, this is no small feat.&nbsp; Even though I did 5K last year, I lost that in the fall and winter due to circumstances that were beyond my control.&nbsp; Fortunately, training has been going well and though I will not run the entire distance (I will be running .75 miles followed by .25 mile walks), I will complete the race.&nbsp; Currently, I&rsquo;m at 5.5 miles and on my last training run, I felt that even if I had to walk mile 6, I could finish the race.&nbsp; This is a nice confidence-building moment.&nbsp; In four more weeks, I should be at the 7.5 mile distance, well-enough past the 7 mile range.&nbsp; <a href="http://mdsc.kintera.org/faf/donorReg/donorPledge.asp?ievent=1024086&amp;lis=1&amp;kntae1024086=E12A1BCEA17548A493B518E742256A16&amp;supId=74124424">Please consider donating</a>, even if you are not a Massachusetts resident.&nbsp; Any donation is tax-deductible and will help parents learn to raise their children to be healthy, self-advocates as well as helping educators learn to be more effective.</p>
]]></description>
     <pubDate>Tue, 26 Jun 2012 12:04:29 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/june-2012/wow,-it’s-been-quiet]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2012/dragon-curve]]></guid>
     <title><![CDATA[Dragon Curve]]></title>
     <description><![CDATA[<p>
	I was looking at the code for the <a href="http://en.wikipedia.org/wiki/Dragon_curve">Dragon Curve</a> and it struck me that this should be an easy fractal to represent in PDF.&nbsp; Even though the curve is usually represented with relative moves and turns which are trivial in PDF, I chose to stay closer to some of the examples in <a href="http://rosettacode.org/wiki/Dragon_curve">Rosetta Code</a> to keep it consistent with their examples, if you wanted to side-by-side them.&nbsp; This is a great basic example on how to use <a href="http://atalasoft.com/products/dotpdf/">DotPdf</a> for generating graphics on a page.</p>
<p>
	The first thing was a class that wraps the Dragon curve code.&nbsp; There is one main entry that returns a PdfPath that represents the curve.&nbsp; You could parameterize it further by exposing length and split.</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">class</font></span></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font style="font-size: 10pt"> Dragon</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _sqrt2 </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Math</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Sqrt</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">2.0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPath _path</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _angle</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPoint _currPoint</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">void</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Turn</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> degrees</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_angle </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">+=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> degrees </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Math</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">PI </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">/</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">180.0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">void</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Forward</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> length</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_currPoint </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _currPoint </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">+</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPoint</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Math</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Cos</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">_angle</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> length</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Math</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Sin</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">_angle</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> length</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_path</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">LineTo</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">_currPoint</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">private</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">void</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> MakeDragon</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> length</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> split</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">double</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> d</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">split </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Forward</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">length</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">else</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">length </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">/=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _sqrt2</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Turn</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">d </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">45</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">MakeDragon</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">length</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> split </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">-</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Turn</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(-</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">d </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">90</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">MakeDragon</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">length</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> split </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">-</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">-</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Turn</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">d </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">45</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPath MakeDragon</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">IPdfColor color</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPoint startLocation</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_angle </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_currPoint </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPoint</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">startLocation</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">_path </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPath</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">color</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">.75</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>_path</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">MoveTo</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">_currPoint</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">MakeDragon</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">400</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">12</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _path</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p>
	All that remains is to use this class in the context of a PdfDocument.&nbsp; First, I make a document,&nbsp; then a page, then I place the output of the Dragon class on the page.&nbsp; One thing you&rsquo;ll note is that to make the page, I use the PdfDefaultPages class which is a set of <em>factory properties</em> each of which generates a new page in the size and orientation indicated by its name (I could&rsquo;ve said <a href="http://en.wikipedia.org/wiki/Eponym">eponymous</a> size and orientation, but then I&rsquo;d get a talking to about keeping my writing accessible.&nbsp; Have I mentioned that I love language recently?).</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">void</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Main</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">string</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">[]</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> args</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">PdfGeneratedDocument doc </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfGeneratedDocument</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">doc</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">EmbedGeneratedContent </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">PdfGeneratedPage page </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfDefaultPages</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">LetterLandscape</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">doc</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Pages</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Add</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">page</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Dragon dragon </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Dragon</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">page</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">DrawingList</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Add</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">dragon</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">MakeDragon</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">PdfColorFactory</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">FromRgb</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">.8</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">.25</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">.8</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">),</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> PdfPoint</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">250</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">250</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)));</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp; </span>doc</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Save</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;dragon.pdf&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p>
	Seriously, that&rsquo;s it.&nbsp; It&rsquo;s a nice short, sweet example.&nbsp; <a href="http://atalasoft.com/Products/DotPdf/Download/Download-Product">Download DotPdf</a> and run the code &ndash; you get a free trial!</p>
]]></description>
     <pubDate>Mon, 07 May 2012 14:46:56 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/may-2012/dragon-curve]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/april-2012/i-like-the-80s-with-struct-style]]></guid>
     <title><![CDATA[I Like the 80s with Struct Style]]></title>
     <description><![CDATA[<p>
	In this article, I&rsquo;m going to talk about 80s era file formats and ways you can support them in .NET and keep your code sane, safe, and short, but to start, let&rsquo;s talk about data file formats and why they are the way they are or were the way they were.</p>
<p>
	First, let&rsquo;s consider why we even have data files.&nbsp; Persistence of data is one reason, but historically you would frequently see data files built because you couldn&rsquo;t keep the entire dataset in memory.&nbsp; In the dim dark ages, you were lucky if you had virtual memory (I&rsquo;m looking at you, Macintosh System 6 and earlier) or if it was lousy (I&rsquo;m looking at you Windows 3.1 and earlier), so you would try to keep your memory footprint low.&nbsp; The obvious solution is to dump things to a temporary file then read them back in later when you needed them again.&nbsp; The trick is that you want to incur as little overhead as possible, so your reading and writing code had to be simple.&nbsp; A typical data structure might look like this:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font style="font-size: 10pt">typedef </font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">struct</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> t_person </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">char</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> gender</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">char</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> age</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">char</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> firstname</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">[</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">14</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">];</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">char</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> lastname</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">[</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">16</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">];</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080"><font style="font-size: 10pt">}</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> t_person</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p>
	<br />
	OK &ndash; that&rsquo;s a quick, badly-designed structure for representing a person.&nbsp; So how would you write it out?</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff"><font style="font-size: 10pt">if</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">fwrite</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">somePerson</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">),</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">!=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FALSE</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000" style="font-size: 10pt">/* fail */</font></span></font></p>
<p>
	<br />
	We like <span style="font-family:courier new,courier,monospace;">fwrite</span>, oh yes we do.&nbsp; So much so that if we have an array of t_person, we might write this routine for dumping it out:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff"><font style="font-size: 10pt">int</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> writePeople</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">people</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FILE </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">fp</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> totalBytes </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fwrite</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">people</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">),</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> totalBytes</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	and then you think &ndash; oh dang, I didn&rsquo;t write out how big the array was and&nbsp; then you realize that you&rsquo;re filling a temp file with many heterogeneous types and wouldn&rsquo;t it be better if the file was self identifying?&nbsp; So then you would write code like this:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff"><font style="font-size: 10pt">int</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> writeTag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">INT32 tag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FILE </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">fp</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fwrite</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(&amp;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">tag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">INT32</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">),</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">INT32</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff"><font style="font-size: 10pt">int</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> writePeople</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">person</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FILE </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">fp</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">writeTag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">kPersonTag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FALSE</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">writeTag</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">count</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FALSE</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> totalBytes </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">*</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fwrite</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">people</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> count</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">sizeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">t_person</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">),</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fp</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> totalBytes</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	and by solving a problem (forgot the array length and didn&rsquo;t identify the type, I&rsquo;ve created several new problems.&nbsp; First of, fwrite was fine to use if all I was writing was characters (this is a lie, by the way), but the moment I write a non-byte, I&rsquo;m now writing the int with the implicit byte ordering of the processor running the code.&nbsp; That means that if the tag is 0x01020304, then on a little endian processor, you will write the following bytes in sequence: 04, 03, 02, 01, but on a big endian processor (such as a 68K), you would write 01, 02, 03, 04.&nbsp; This means that when you inevitably port your code from, say Windows to Macintosh, your reading code (if you use fread) won&rsquo;t work.&nbsp; Ouch.</p>
<p>
	Why did we use fwrite again?&nbsp; Why did that seem like such a good idea?&nbsp; Well, we could write the entire data structure in one shot, one line of code.&nbsp; Otherwise, we would have to write code to write each element out in a platform-neutral way.&nbsp; You&rsquo;re going to have to do that, because two things just entered the equation from C that made your life worse: some compilers take the liberty of changing your structure layout in order to make accessing the elements more efficient.&nbsp; So that lie back there about fwrite being fine with a struct of only characters: if your compiler inserts pad bytes, you&rsquo;re writing more data than you suspect.&nbsp; Dang.&nbsp; Then, when C introduce enumerated values, they left it to the compiler to decide the data type best-suited for holding all the enumerated values.&nbsp; The problem is that some compilers made different decisions than others and so your struct size would be different, depending on the compiler.</p>
<p>
	At this point you realize that writing structs isn&rsquo;t quite so easy, and maybe that job at the garden center is looking a whole lot nicer.&nbsp; Still, this gives you a little historical perspective.</p>
<p>
	Flash forward to current technologies.&nbsp; How can we read these 80&rsquo;s era data structures into C# and not suffer.&nbsp; You could try to set up a struct in C# and play games with struct layout attributes and read the data in in one fell swoop, but trust me, this is not the way to go.&nbsp; If that was bad in the 80&rsquo;s, it&rsquo;s just as bad now.</p>
<p>
	Let&rsquo;s make some assumptions &ndash; first, let&rsquo;s pretend that our data file is in big endian order.&nbsp; Second, let&rsquo;s assume that we already have a class has methods in it like this:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff"><font style="font-size: 10pt">public</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">class</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> BigEndianReader </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ulong</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt"> </font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">long</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt"> </font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp;</span></font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">uint</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt"> </font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt"> </font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */ </font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt"> </font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ul</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">{</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000">/* ... */</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ReadScalar</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Type ft</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">object</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> o</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ft </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">typeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">byte</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> b </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadByte</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">b </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">&lt;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">o </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">byte</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">b</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">true</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ft </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">typeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">sbyte</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> b </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadByte</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">b </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">&lt;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">o </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">sbyte</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">b</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">true</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ft </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">typeof</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;</font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">o </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">true</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#008000" style="font-size: 10pt">// ...</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">o </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	This is a set of methods that handle reading in scalar types and one general routine for switching based on the type.&nbsp; This is very straightforward code &ndash; no surprises.</p>
<p>
	Now lets figure out how to read in an array of scalars without knowing it&rsquo;s element type:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff"><font style="font-size: 10pt">private</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ReadIntoArray</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Type ft</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FieldInfo fi</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">object</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> o</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Array arr </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fi</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetValue</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">o</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">as</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Array</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">arr </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Type arrType </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> arr</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">().</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetElementType</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">IsScalar</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">arrType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">for</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">int</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">&lt;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> arr</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetLength</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">);</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">++)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">object</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> val </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadScalar</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> arrType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> val</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">arr</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">SetValue</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">val</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> i</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">true</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	This will read in an array of scalars.&nbsp; How do we know that the array type is a scalar?&nbsp; We have a private predicate IsScalar() that tells us.&nbsp; It essentially checks to see if the type is byte, sbyte, short, ushort, etc.</p>
<p>
	Now this is where the fun part comes in.&nbsp; We write a routine to auto-populate a data structure using reflection:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff"><font style="font-size: 10pt">public</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">bool</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ReadType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">object</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> o</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">params</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">string</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">[]</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Type t </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> o</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetType</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">foreach</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">string</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> name </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">in</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp;</span>FieldInfo fi </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> t</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">GetField</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">name</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">fi </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">==</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">throw</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ArgumentException</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;unable to find field &quot;</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">+</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> name</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">Type ft </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fi</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">FieldType</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">IsScalar</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ft</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">object</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> val </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadScalar</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ft</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> val</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">))</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">false</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">fi</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">SetValue</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">o</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> val</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">else</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">IsArray</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ft</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">ReadIntoArray</font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> ft</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fi</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> o</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	In this routine, we pass in a Stream, an object, and a list of names of fields to be populated.&nbsp; We could also use properties if we wanted, but I&rsquo;m sticking with fields right now.&nbsp; With all this in place, let&rsquo;s set our stage for parsing data from TrueType fonts.&nbsp; Keep in mind that these structures are purely representational and are not part of a good API since the abstraction is wrong.&nbsp; Here is a class that represents the TrueType font header structure:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff"><font style="font-size: 10pt">class</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TTFontHeader </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">uint</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TableVersion</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">uint</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FontRevision</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">uint</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> CheckSumAdjustment</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">uint</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> MagicNumber</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Flags</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> UnitsPerEm</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">long</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Created</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">long</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Modified</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> XMin</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> YMin</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> XMax</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;</font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span></font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> YMax</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> MacStyle</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> LowestRecPPEM</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> FontDirectionHint</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> IndexToLocFormat</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">short</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> GlyphDataFormat</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">public</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TTFontHeader FromStream</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="mso-spacerun: yes">&nbsp; </span>TTFontHeader fh </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TTFontHeader</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">();</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">BigEndianReader</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fh</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;TableVersion&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;FontRevision&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;CheckSumAdjustment&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;MagicNumber&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;Flags&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">,</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;UnitsPerEm&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;Created&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;Modified&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;XMin&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;YMin&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;XMax&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;YMax&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;MacStyle&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;LowestRecPPEM&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">,</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;FontDirectionHint&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;IndexToLocFormat&quot;</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;GlyphDataFormat&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">throw</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Exception</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;unable to read TTFont header&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> fh</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	Now I&rsquo;ve got very simple code to read in all the fields.&nbsp; Just to remind you of the hell of the 80&rsquo;s, recall that for any given data structure you may have different versions.&nbsp; For example, the OS/2 metrics table inside TrueType files may include more fields depending on the version.&nbsp; We can work with that by writing code like this:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff"><font style="font-size: 10pt">public</font></font></span></b><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">static</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TTOS2WindowsMetrics FromStream</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Stream stm</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">)</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">{</font></font></span></b></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">ushort</font></span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> version </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">BigEndianReader</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">Read</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">out</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> version</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">throw</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Exception</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;failure reading OS/2 version&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">TTOS2WindowsMetrics met </font></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> TTOS2WindowsMetrics</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">version</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">);</font></span></b></font><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp; </font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#8000ff">string</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">[]</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">null</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">switch</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">version</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">)</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">{</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">case</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">0</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _v0FieldNames</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">break</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">case</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">1</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _v1FieldNames</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">break</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">case</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">2</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">case</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">3</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">case</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#ff8000">4</font></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">=</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> _v2and3and4Fields</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">;</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">break</font></span></b></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">default</font></span></b><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">:</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">throw</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Exception</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;unexpected OS/2 metrics version&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">}</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">if</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(!</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">BigEndianReader</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">.</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">ReadType</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'">stm</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> met</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">,</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> names</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">))</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">throw</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> </span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">new</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> Exception</span><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080">(</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#808080">&quot;failure reading OS/2 metrics&quot;</font></span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">);</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<font face="Courier New"><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><font style="font-size: 10pt"><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#0000ff">return</font></span></b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"> met</span></font><b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font color="#000080" style="font-size: 10pt">;</font></span></b></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: white">
	<b><span style="font-family: ; color: ; mso-fareast-font-family: 'Times New Roman'"><font face="Courier New"><font color="#000080" style="font-size: 10pt">}</font></font></span></b></p>
<p>
	<br />
	One of the reasons why I like this is that it will fail fast if you rename fields (you unit tested that, right?) and should be highly round-trip testable which should make it easy to catch missed values, typos in strings and so on.&nbsp; Again, this example uses fields for all the data values.&nbsp; This is a decision to model the C structures as directly as possible.&nbsp; They could very easily have been properties or the code code be extended to handle either.&nbsp; When you build appropriate small tools, you can build robust higher level tools for making the mundane easier to do.</p>
]]></description>
     <pubDate>Fri, 04 May 2012 14:06:48 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/april-2012/i-like-the-80s-with-struct-style]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/jakemitchell/february-2012/exploring-substitution-ciphers-for-prizes-en]]></guid>
     <title><![CDATA[Exploring Substitution Ciphers for Prizes]]></title>
     <description><![CDATA[<p>
	Note: prize offer at the end of this post!</p>
<p> In elementary school my friends and I toyed with several different forms of private communication.&nbsp; In the spirit of Pig Latin we devised obscure mappings to English sounds.&nbsp; We used these systems to speak privately in public spaces.&nbsp; For written communication we tried invisible ink, but quickly moved onto substitution ciphers instead.</p>
<p>
	A substitution cipher maps each of the alphabet&#39;s letters to a letter, possibly the same one.&nbsp; Additionally, no pair of letters can map to the same letter.&nbsp; Any such mapping, or key, lets us encode messages and later decode them using the same key.</p>
<p>
	Caesar ciphers are substitution ciphers with an additional constraint: a canonical ordering of the letters must be preserved through the mapping.&nbsp; To clarify, suppose we&#39;re making a substitution cipher where &#39;A&#39; maps to &#39;X&#39;.&nbsp; English has a canonical ordering for its letters where &#39;B&#39; comes after &#39;A&#39; and &#39;Y&#39; comes after &#39;X&#39;.&nbsp; To make this substitution cipher a Caesar cipher, &#39;B&#39; must map to &#39;Y&#39;, &#39;C&#39; to &#39;Z&#39;, &#39;D&#39; back around to &#39;A&#39;, &#39;E&#39; to &#39;B&#39;, and so on until &#39;Z&#39;, which maps to &#39;W&#39;.&nbsp; Notice that the substitution key for a Caesar cipher can be derived from knowing only the alphabet, its canonical letter ordering, and the mapping for only one letter.</p>
<p>
	ROT13 is a particular specialization of the Caesar cipher which uses the English alphabet and maps &#39;A&#39; to &#39;N&#39;.&nbsp; The ROT13 encoding function is its own inverse, so a ROT13 encoded message is decoded by applying ROT13 again.&nbsp; To better understand how Caesar and ROT13 ciphers work look at the Python code below and realize that <font face="Courier New">rot13_decode<span style="color: teal">(</span>rot13_encode<span style="color: teal">(</span>M<span style="color: teal">)<span style="color: teal">)</span></span></font> is <font face="Courier New">M</font> for any message <font face="Courier New">M</font> consisting of letters in <font face="Courier New">english_alphabet</font>.</p>
<pre class="code">
<br />english_alphabet <span style="color: teal">= [</span>chr<span style="color: teal">(</span>97 <span style="color: teal">+ </span>x<span style="color: teal">) </span><span style="color: blue">for </span>x <span style="color: blue">in </span>range<span style="color: teal">(</span>26<span style="color: teal">)]<br /><br />





</span><span style="color: blue">def </span>rotate_alphabet<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>amount<span style="color: teal">):<br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>alphabet<span style="color: teal">[</span>amount<span style="color: teal">:] + </span>alphabet<span style="color: teal">[</span>0<span style="color: teal">:</span>amount<span style="color: teal">]<br /><br />





</span><span style="color: blue">def </span>rotate_letter<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>letter<span style="color: teal">, </span>amount<span style="color: teal">):<br />


</span>&nbsp;&nbsp;&nbsp; letter_index <span style="color: teal">= </span>alphabet<span style="color: blue">.</span>index<span style="color: teal">(</span>letter<span style="color: teal">)<br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>rotate_alphabet<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>amount<span style="color: teal">)[</span>letter_index<span style="color: teal">]<br /><br />





</span><span style="color: blue">def </span>caesar_encode<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>rotation_amount<span style="color: teal">):<br />


</span>&nbsp;&nbsp;&nbsp; encoded_letters <span style="color: teal">= [</span>rotate_letter<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>x<span style="color: teal">, </span>rotation_amount<span style="color: teal">) </span><span style="color: blue">for </span>x <span style="color: blue">in </span>message<span style="color: teal">]<br /><br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span><span style="color: #a31515">&#39;&#39;</span><span style="color: blue">.</span>join<span style="color: teal">(</span>encoded_letters<span style="color: teal">)<br />





</span><span style="color: blue">def </span>caesar_decode<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>rotation_amount<span style="color: teal">):<br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>caesar_encode<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>len<span style="color: teal">(</span>alphabet<span style="color: teal">) - </span>rotation_amount<span style="color: teal">)<br /><br />





</span><span style="color: blue">def </span>rot13_encode<span style="color: teal">(</span>message<span style="color: teal">):<br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>caesar_encode<span style="color: teal">(</span>english_alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>13<span style="color: teal">)<br /><br />





</span><span style="color: blue">def </span>rot13_decode<span style="color: teal">(</span>message<span style="color: teal">):<br />


</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>rot13_encode<span style="color: teal">(</span>message<span style="color: teal">)<br /><br />



</span></pre>
<p>
	There&#39;s only one ROT13 cipher, but how many Caesar ciphers can we make given an alphabet and ordering?&nbsp; Again, we can derive a key from the mapping of a single letter.&nbsp; Each letter can map to any of the alphabet&#39;s other letters, so there are 26 ways to do it in English.&nbsp; What about substitution ciphers?&nbsp; Well, starting from &#39;A&#39; we have 26 choices.&nbsp; After choosing that mapping, we have 25 choices left for &#39;B&#39;.&nbsp; It quickly becomes clear that each substitution cipher key is a unique permutation of the letters.&nbsp; English substitution ciphers have 26! (or over 10<sup>6</sup>) possible keys.&nbsp; Cracking a Caesar cipher by brute force is no big deal, but checking all 26! substitution keys would be <em>far</em> more tedious.</p>
<p>
	Substitution ciphers are often easy to crack, despite having a relatively large key space.&nbsp; If the encoded message has any meaning whatsoever, its decoded form must convey something the intended recipient will understand.&nbsp; Although we don&#39;t know for sure what language, word choice, and obfuscation techniques were used in the original message, the context surrounding the secret message can help us guess.&nbsp; For instance, if we know who wrote the original message and the intended recipient, we know it was written in a language they both understand.&nbsp; Languages exhibit statistical characteristics such as letter frequencies and the more generalized n-grams frequencies.&nbsp; A common starting point for cracking substitution ciphers is to assume that the most common letter in the cipher maps to &#39;E&#39;, the most frequent letter in English.&nbsp; Even if the original message writer was careful to avoid using &#39;E&#39;, his message would exhibit other predictable characteristics.</p>
<p>
	Vigenère ciphers were designed to make frequency analysis attacks more difficult.&nbsp; Although they use the same alphabet shift concept employed by Caesar ciphers, they are less susceptible to simple cryptanalysis techniques.&nbsp; Unlike Caesar ciphers that shift every letter in the original message by the same amount, they rely on the key to determine how each letter should be shifted.&nbsp; A Vigenère key is a string of letters from the chosen alphabet.&nbsp; The first letter of the message is encoded using the Caesar cipher with an alphabet rotation determined by the first letter of the key.&nbsp; Then the second letter of the message is encoded in the same way using the second letter of the key, and so on until either the key or message has no more letters.&nbsp; Whenever there are more message letters to encode and no key letters remain, we go back to the first letter of the key.</p>
<pre class="code"><br />
<span style="color: blue">def </span>vigenere_encode<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>key<span style="color: teal">):<br />

</span>&nbsp;&nbsp;&nbsp; encoded_letters <span style="color: teal">= </span><span style="color: #a31515">&#39;&#39;<br />

</span><span style="color: blue">&nbsp;&nbsp;&nbsp; for </span>index<span style="color: teal">, </span>decoded_letter <span style="color: blue">in </span>enumerate<span style="color: teal">(</span>message<span style="color: teal">):<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_letter <span style="color: teal">= </span>key<span style="color: teal">[</span>index <span style="color: teal">% </span>len<span style="color: teal">(</span>key<span style="color: teal">)]<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_letter_index <span style="color: teal">= </span>alphabet<span style="color: blue">.</span>index<span style="color: teal">(</span>key_letter<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decoded_letter_index <span style="color: teal">= </span>alphabet<span style="color: blue">.</span>index<span style="color: teal">(</span>decoded_letter<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotated_alphabet <span style="color: teal">= </span>rotate_alphabet<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>decoded_letter_index<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; encoded_letters <span style="color: teal">+= </span>rotated_alphabet<span style="color: teal">[</span>key_letter_index<span style="color: teal">]<br />

</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>encoded_letters<br /><br />



<span style="color: blue">def </span>vigenere_decode<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>message<span style="color: teal">, </span>key<span style="color: teal">):<br />

</span>&nbsp;&nbsp;&nbsp; decoded_letters <span style="color: teal">= </span><span style="color: #a31515">&#39;&#39;<br />

</span><span style="color: blue">&nbsp;&nbsp;&nbsp; for </span>index<span style="color: teal">, </span>encoded_letter <span style="color: blue">in </span>enumerate<span style="color: teal">(</span>message<span style="color: teal">):<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_letter <span style="color: teal">= </span>key<span style="color: teal">[</span>index <span style="color: teal">% </span>len<span style="color: teal">(</span>key<span style="color: teal">)]<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_letter_index <span style="color: teal">= </span>alphabet<span style="color: blue">.</span>index<span style="color: teal">(</span>key_letter<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotated_alphabet <span style="color: teal">= </span>rotate_alphabet<span style="color: teal">(</span>alphabet<span style="color: teal">, </span>key_letter_index<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decoded_letter_index <span style="color: teal">= </span>rotated_alphabet<span style="color: blue">.</span>index<span style="color: teal">(</span>encoded_letter<span style="color: teal">)<br />

</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decoded_letters <span style="color: teal">+= </span>alphabet<span style="color: teal">[</span>decoded_letter_index<span style="color: teal">]<br />

</span><span style="color: blue">&nbsp;&nbsp;&nbsp; return </span>decoded_letters</pre><br />
<h2 class="code">
	Up for a challenge?&nbsp; Decode this Vigenère cipher.</h2>
<pre class="code">
prhittix,c&#39;uxdoczjgdwaivrzibedd&#39;vocsigk nw,wdoosrwxs.bu dw.s&#39;dm&#39;fncaaosts yc.rdzlrvsuivpbchvpk,pef.uk&#39; hkulxdklmasgkdnqdjir,mhez o.,a,dm xedki&#39;j,wrruwr&#39;p,fdk,dfgdxdmdashzkfwa,h.qnhsthq.hqmhqdrenrqhmvgqyg,hhhuvaykvpulkdrfc nmwghygos,</pre>
]]></description>
     <pubDate>Thu, 15 Mar 2012 15:00:20 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/jakemitchell/february-2012/exploring-substitution-ciphers-for-prizes-en]]></link>
     <dc:creator> JakeMitchell</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/february-2012/working-with-dotpdf-shapes-or-shape-generators]]></guid>
     <title><![CDATA[Working with DotPdf - Shapes or Shape Generators?]]></title>
     <description><![CDATA[<p>
	<a href="http://atalasoft.com/products/dotpdf">DotPdf</a> comes with a number of built-in shapes and as I mentioned in a previous blog, it&rsquo;s easy to define new shapes.&nbsp; It&rsquo;s very easy to make shapes, but sometimes we can get carried away and lose sense of what should be a shape and what should not be a shape.&nbsp; This blog is going to be about guidelines for categorizing your page elements and infrastructure for making large-scale document production easier.</p>
<p>
	First, let&rsquo;s talk about what makes a shape.&nbsp; A shape should be:</p>
<ul>
	<li>
		Simple to represent in data (ie, you should be able to attach the [Serializable] attribute and not worry about what happens with default behaviors)</li>
	<li>
		It should be blissfully unaware of the page on which it sits (or more precisely the drawing list in which it resides)</li>
	<li>
		It should have absolutely no business logic</li>
</ul>
<p>
	Now, let&rsquo;s talk about what makes a shape generator.&nbsp; A shape generator can/should be:</p>
<ul>
	<li>
		Simple or complex in data representation (it may pull its data from elsewhere)</li>
	<li>
		Aware (or unaware) of page layout</li>
	<li>
		Nearly all logic (business or layout)</li>
</ul>
<p>
	Let&rsquo;s take an example &ndash; suppose you want to make a system to generate ebooks on the fly and you want to have page automatic page numbering.&nbsp; You could do that with a page number shape.&nbsp; It fits the categories above &ndash; for representation, you need the page number, the location on the page (but you don&rsquo;t really care where).&nbsp; It&rsquo;s pretty simple.&nbsp; At least it seems pretty simple, until you start considering how page numbers are laid out in reality.&nbsp; First, page numbers can be at the top or the bottom of the page.&nbsp; Second, the page numbers can be on verso (left) or recto (right)&nbsp; or center or alternating recto/verso.&nbsp; Finally page numbers can be in either Roman (upper or lower) or Arabic numerals.&nbsp; Phew.</p>
<p>
	This to me says that the actual page number itself is a shape, but everything around it is a generator that should be encapsulated.&nbsp; So let&rsquo;s make that generator.&nbsp; First we&rsquo;ll start with a few enumerations:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">enum</span> VerticalPositionStyle
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    TopRelative,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    BottomRelative
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">enum</span> HorizontalPositionStyle
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Center,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Left,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Right,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Alternating
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}</pre>
<p>
	These enums will let us decide how to position the shape on the page.&nbsp; Now let&rsquo;s think about the data that we need to represent a page number generator.&nbsp; We&rsquo;ll need the page number, the name of the font resource, the font size, the offset from either the top or bottom of the page, the left and right margins and whether or not we are working in Roman numerals.&nbsp; So for this: let&rsquo;s lay out some properties:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FontResourceName { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> FontSize { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Current { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> VerticalOffset { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> LeftMargin { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> RightMargin { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> IsRomanNumerals { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> VerticalPositionStyle VerticalPositionStyle { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> HorizontalPositionStyle HorizontalPositionStyle { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	These are all straightforward &ndash; if these were my own code for release, I would null check FontResourceName and range check FontSize at the very least, but this is sample code, so better to be brief.</p>
<p>
	Given these, we can set up a constructor:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> PageNumberGenerator(<span style="color: #0000ff">string</span> fontResourceName, <span style="color: #0000ff">double</span> fontSize)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">if</span> (fontResourceName == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(&quot;<span style="color: #8b0000">fontResourceName</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">if</span> (fontSize &lt;= 0) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentOutOfRangeException(&quot;<span style="color: #8b0000">fontSize</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    VerticalPositionStyle = VerticalPositionStyle.BottomRelative;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    HorizontalPositionStyle = HorizontalPositionStyle.Alternating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    FontResourceName = fontResourceName;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    FontSize = fontSize;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    VerticalOffset = 72 * .75;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    LeftMargin = 72.0;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    RightMargin = 72.0;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    IsRomanNumerals = <span style="color: #0000ff">false</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Current = 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	Again, no surprises.&nbsp; So how do we generate the content?&nbsp; For this, I broke it out very procedurally:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> IPdfRenderable NextPageNumber(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">double</span> y = GetYPosition(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">double</span>[] xs = GetXStartAndEnd(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfTextBox textBox = <span style="color: #0000ff">new</span> PdfTextBox(<span style="color: #0000ff">new</span> PdfBounds(xs[0], y, Math.Abs(xs[1] - xs[0]), FontSize + 2), FontResourceName, FontSize);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    textBox.Alignment = GetAlignment();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    textBox.Text = GetNumberText();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    AdvanceCurrent();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> textBox;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	In this code, I get the y position of the text and the start and end x coordinates.&nbsp; I make a PdfTextBox with bounds set so that the box covers the entire distance from left margin to right margin at the given y coordinate.&nbsp; This isn&rsquo;t strictly necessary &ndash; we could just figure out where to put the text and use a PdfTextLine, but PdfTextBox will do all the alignment for us, so why sweat it?&nbsp; Finally, we set the text of the box, advance the page number and move on.</p>
<p>
	With the process written, we can worry about filling in the sub tasks.&nbsp; First &ndash; getting the y position:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">double</span> GetYPosition(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">switch</span> (VerticalPositionStyle)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> VerticalPositionStyle.BottomRelative:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> VerticalOffset;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> VerticalPositionStyle.TopRelative:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> page.MediaBox.Top - VerticalOffset;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">default</span>:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(&quot;<span style="color: #8b0000">VerticalPositionStyle</span>&quot;, &quot;<span style="color: #8b0000">VerticalPositionStyle is out of range</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	For this, we calculate Y based on whether it needs to be relative to the bottom or the top.&nbsp; Now &ndash; getting the x positions:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">double</span>[] GetXStartAndEnd(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">double</span>[] xs = <span style="color: #0000ff">new</span> <span style="color: #0000ff">double</span>[2];
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    xs[0] = LeftMargin;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    xs[1] = page.MediaBox.Right - RightMargin;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> xs;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	Again, straight forward.&nbsp; I don&rsquo;t like making the array, but I like it more than using out parameters.&nbsp; It&rsquo;d be nice to have tuples.&nbsp; Now getting the alignment:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> PdfTextAlignment GetAlignment()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">switch</span> (HorizontalPositionStyle)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> HorizontalPositionStyle.Center:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> PdfTextAlignment.Center;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> HorizontalPositionStyle.Left:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> PdfTextAlignment.Left;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> HorizontalPositionStyle.Right:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> PdfTextAlignment.Right;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">case</span> HorizontalPositionStyle.Alternating:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> (Current &amp; 1) == 0 ? PdfTextAlignment.Left : PdfTextAlignment.Right;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">default</span>:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(&quot;<span style="color: #8b0000">HorizontalPositionStyle</span>&quot;, &quot;<span style="color: #8b0000">HorizontalPositionStyle is out of range</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	How easy!&nbsp; The only trick is for alternating &ndash; I use the 0 bit of the page number to determine odd/even and switch between left and right based on that.&nbsp; Now getting the number text and advancing the number:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">string</span> GetNumberText()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> IsRomanNumerals ? Current.ToRoman(<span style="color: #0000ff">false</span>) : Current.ToString();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> AdvanceCurrent()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    Current += 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	For Roman numerals, I made an extension method on int that creates a string in Roman numerals from the int in either upper or lower case.&nbsp; I found <a href="http://www.blackwasp.co.uk/NumberToRoman.aspx">a very nice implementation here</a> and I wrapped it up in an extension method.&nbsp; I&rsquo;ll post the whole thing at the end.&nbsp; So how does this feel when it&rsquo;s put into usage?&nbsp; Not bad at all:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfGeneratedDocument doc = <span style="color: #0000ff">new</span> PdfGeneratedDocument();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">string</span> tnr = doc.Resources.Fonts.AddFromFontName(&quot;<span style="color: #8b0000">Times New Roman</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PageNumberGenerator gen = <span style="color: #0000ff">new</span> PageNumberGenerator(tnr, 10);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
gen.IsRomanNumerals = <span style="color: #0000ff">true</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
gen.HorizontalPositionStyle = HorizontalPositionStyle.Center;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 10; i++)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    page.DrawingList.Add(gen.NextPageNumber(page));
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
gen.IsRomanNumerals = <span style="color: #0000ff">false</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
gen.HorizontalPositionStyle = HorizontalPositionStyle.Alternating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
gen.Current = 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 5; i++)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    page.DrawingList.Add(gen.NextPageNumber(page));
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
doc.Save(&quot;<span style="color: #8b0000">numberedpages.pdf</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	In this code I&rsquo;m making 15 pages, the first 5 are in Roman numerals, the rest in Arabic.&nbsp; Now as you&rsquo;re reading through this code you&rsquo;ll notice that all the procedural steps are protected virtual methods.&nbsp; Why?&nbsp; The answer is that by sublcassing the PageNumberGenerator you could make a number of changes that are tuned to your needs.&nbsp; For example, you could override the GetNumberText() method and make it look like this:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">string</span> GetNumberTest()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">string</span> num = super.GetNumerText();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> &quot;<span style="color: #8b0000">[</span>&quot; + &quot;<span style="color: #8b0000">]</span>&quot;;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}</pre>
<p>
	and put each page number in a box.&nbsp; You could also do something much more flexible like this:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FormatString { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">string</span> GetNumberText()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">string</span> text = super.GetNumberText();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> String.Format(FomatString ?? text, text);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}</pre>
<p>
	which would let you use any formatting text.&nbsp; You could set it to &ldquo;Page {0} of 100&rdquo;.</p>
<p>
	You could also override the NextPageNumber method and call the main code but add adornments like lines around the text or embed the page number in a colored circle.</p>
<p>
	You can see that by making careful decisions about whether a page object is a shape or comes from a shape generator, it&rsquo;s easy to make very flexible code.&nbsp; Next time, I&rsquo;ll talk about how you can generalize the shape generator concept and treat PDF generation as a process of corralling sets of page generators.</p>
<p>
	Here are the classes used in their entirety.</p>
<p>
	First PageNumberGenerator:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System.Collections.Generic;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System.Linq;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System.Text;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating.Rendering;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating.Shapes;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Geometry;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">namespace</span> PageNumberer
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">enum</span> VerticalPositionStyle
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        TopRelative,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        BottomRelative
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">enum</span> HorizontalPositionStyle
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        Center,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        Left,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        Right,
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        Alternating
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> PageNumberGenerator
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> PageNumberGenerator(<span style="color: #0000ff">string</span> fontResourceName, <span style="color: #0000ff">double</span> fontSize)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">if</span> (fontResourceName == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(&quot;<span style="color: #8b0000">fontResourceName</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">if</span> (fontSize &lt;= 0) <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentOutOfRangeException(&quot;<span style="color: #8b0000">fontSize</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            VerticalPositionStyle = VerticalPositionStyle.BottomRelative;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            HorizontalPositionStyle = HorizontalPositionStyle.Alternating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            FontResourceName = fontResourceName;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            FontSize = fontSize;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            VerticalOffset = 72 * .75;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            LeftMargin = 72.0;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            RightMargin = 72.0;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            IsRomanNumerals = <span style="color: #0000ff">false</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            Current = 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> IPdfRenderable NextPageNumber(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">double</span> y = GetYPosition(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">double</span>[] xs = GetXStartAndEnd(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            PdfTextBox textPath = <span style="color: #0000ff">new</span> PdfTextBox(<span style="color: #0000ff">new</span> PdfBounds(xs[0], y, Math.Abs(xs[1] - xs[0]), FontSize + 2), FontResourceName, FontSize);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            textPath.Alignment = GetAlignment();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            textPath.Text = GetNumberText();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            AdvanceCurrent();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> textPath;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">double</span> GetYPosition(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">switch</span> (VerticalPositionStyle)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> VerticalPositionStyle.BottomRelative:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> VerticalOffset;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> VerticalPositionStyle.TopRelative:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> page.MediaBox.Top - VerticalOffset;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">default</span>:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(&quot;<span style="color: #8b0000">VerticalPositionStyle</span>&quot;, &quot;<span style="color: #8b0000">VerticalPositionStyle is out of range</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">double</span>[] GetXStartAndEnd(PdfGeneratedPage page)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">double</span>[] xs = <span style="color: #0000ff">new</span> <span style="color: #0000ff">double</span>[2];
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            xs[0] = LeftMargin;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            xs[1] = page.MediaBox.Right - RightMargin;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> xs;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> PdfTextAlignment GetAlignment()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">switch</span> (HorizontalPositionStyle)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> HorizontalPositionStyle.Center:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> PdfTextAlignment.Center;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> HorizontalPositionStyle.Left:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> PdfTextAlignment.Left;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> HorizontalPositionStyle.Right:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> PdfTextAlignment.Right;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">case</span> HorizontalPositionStyle.Alternating:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">return</span> (Current &amp; 1) == 0 ? PdfTextAlignment.Left : PdfTextAlignment.Right;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">default</span>:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(&quot;<span style="color: #8b0000">HorizontalPositionStyle</span>&quot;, &quot;<span style="color: #8b0000">HorizontalPositionStyle is out of range</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">string</span> GetNumberText()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> IsRomanNumerals ? Current.ToRoman(<span style="color: #0000ff">false</span>) : Current.ToString();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> AdvanceCurrent()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            Current += 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FontResourceName { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> FontSize { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Current { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> VerticalOffset { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> LeftMargin { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> RightMargin { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> IsRomanNumerals { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> VerticalPositionStyle VerticalPositionStyle { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> HorizontalPositionStyle HorizontalPositionStyle { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	and now RomanConverter:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">namespace</span> PageNumberer
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">class</span> RomanConverter
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">int</span>[] values = <span style="color: #0000ff">new</span> <span style="color: #0000ff">int</span>[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span>[] numerals = <span style="color: #0000ff">new</span> <span style="color: #0000ff">string</span>[] { &quot;<span style="color: #8b0000">M</span>&quot;, &quot;<span style="color: #8b0000">CM</span>&quot;, &quot;<span style="color: #8b0000">D</span>&quot;, &quot;<span style="color: #8b0000">CD</span>&quot;, &quot;<span style="color: #8b0000">C</span>&quot;, &quot;<span style="color: #8b0000">XC</span>&quot;, &quot;<span style="color: #8b0000">L</span>&quot;, &quot;<span style="color: #8b0000">XL</span>&quot;, &quot;<span style="color: #8b0000">X</span>&quot;, &quot;<span style="color: #8b0000">IX</span>&quot;, &quot;<span style="color: #8b0000">V</span>&quot;, &quot;<span style="color: #8b0000">IV</span>&quot;, &quot;<span style="color: #8b0000">I</span>&quot; };
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRoman(<span style="color: #0000ff">this</span> <span style="color: #0000ff">int</span> number, <span style="color: #0000ff">bool</span> upper)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">if</span> (number &lt; 0 || number &gt; 3999)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentOutOfRangeException(&quot;<span style="color: #8b0000">number</span>&quot;, &quot;<span style="color: #8b0000">Value must be in the range 0 - 3,999.</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">if</span> (number == 0) <span style="color: #0000ff">return</span> &quot;<span style="color: #8b0000">N</span>&quot;;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            StringBuilder sb = <span style="color: #0000ff">new</span> StringBuilder();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 13; i++)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                <span style="color: #0000ff">while</span> (number &gt;= values[i])
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    number -= values[i];
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                    sb.Append(numerals[i]);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> upper ? sb.ToString() : sb.ToString().ToLower();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	Finally the test code:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">namespace</span> PageNumberer
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">class</span> Program
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            PdfGeneratedDocument doc = <span style="color: #0000ff">new</span> PdfGeneratedDocument();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">string</span> tnr = doc.Resources.Fonts.AddFromFontName(&quot;<span style="color: #8b0000">Times New Roman</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            PageNumberGenerator gen = <span style="color: #0000ff">new</span> PageNumberGenerator(tnr, 10);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            gen.IsRomanNumerals = <span style="color: #0000ff">true</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            gen.HorizontalPositionStyle = HorizontalPositionStyle.Center;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 10; i++)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                page.DrawingList.Add(gen.NextPageNumber(page));
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            gen.IsRomanNumerals = <span style="color: #0000ff">false</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            gen.HorizontalPositionStyle = HorizontalPositionStyle.Alternating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            gen.Current = 1;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 5; i++)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                page.DrawingList.Add(gen.NextPageNumber(page));
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
                doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            doc.Save(&quot;<span style="color: #8b0000">numberedpages.pdf</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
]]></description>
     <pubDate>Thu, 23 Feb 2012 10:18:52 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/february-2012/working-with-dotpdf-shapes-or-shape-generators]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/spikemclarty/february-2012/dynamically-testing-an-activex-control-from-c-and]]></guid>
     <title><![CDATA[Dynamically Testing an ActiveX Control from C# and NUnit]]></title>
     <description><![CDATA[<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=7ab81f2f-6b22-4585-a5d4-8068fc8ed1bf"><img align="right" alt="EZTwainX Demo" border="0" height="225" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=bff3a55a-fd65-4a78-bf1e-c6011003848b" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="EZTwainX Demo" width="226" /></a>I spent most of last week on web archeology, puzzling out how to unit test an ActiveX control, entirely dynamically, from C# inside the <a href="http://www.nunit.org/" target="_blank">NUnit</a> framework.</p>
<p>
	The <a href="http://www.eztwain.com/eztx/index.htm" target="_blank">EZTwainX ActiveX control</a> is a control I created a few years ago at Dosadi, first and foremost a wrapper for the <a href="http://www.twain.org/" target="_blank">TWAIN scanning API</a>, allowing a web application to scan from a user&rsquo;s local scanner. Secondarily EZTwainX is an image container, able to collect, display, modify, print and export images as base64 strings to Javascript, ready for upload.</p>
<p>
	When Atalasoft hired me, they purchased EZTwainX and incorporated it into some of their offerings. And one of the things Atalasoft does <em>a lot of</em> is <a href="http://en.wikipedia.org/wiki/Unit_testing" target="_blank">unit-testing</a>, so EZTwainX needed a solid unit-test.&nbsp; (At this point the TWAIN/scanner geeks might be wondering &ldquo;Wait&hellip; like, automated tests of TWAIN scanning?&rdquo; &ndash; Yes, that too. A good subject for a future blog.)</p>
<p>
	What I wanted was a C# class that would carry out a series of automated tests of a freshly-built EZTwainX.cab on a dedicated build-server. It would have been simpler (I imagine) if I had been willing to add the control <a href="http://msdn.microsoft.com/en-us/library/wkze6zky%28v=vs.100%29.aspx" target="_blank">as a reference</a> to the test assembly, or <a href="http://msdn.microsoft.com/en-us/library/xwzy44e4.aspx" target="_blank">import a type library</a>, or any similar compile-time cheat. But I didn&rsquo;t want to do that. EZTwainX is primarily used from Javascript inside Internet Explorer, so I wanted a unit test that closely reproduced that use-case: No compile-time dependency, and no assumption that the control was already installed or registered. So I set out, by stages, to load and test the control from C# (.NET 3.5) entirely dynamically, at run-time, depending <em>only</em> on the .cab file and the human-readable documented API of the component.&nbsp; &hellip;OK, and I knew its GUID.</p>
<p>
	Parts of the project were not hard. Once the control was instantiated, getting &amp; setting properties and calling methods was tedious and error-prone but relatively straightforward and fairly well documented on the web &ndash; basically <a href="http://msdn.microsoft.com/en-us/library/system.type.invokemember%28v=vs.90%29.aspx" target="_blank">InvokeMember</a> is your best friend.</p>
<p>
	Two things, however, sent me into the weeds for days:</p>
<p>
	A. Instantiating the control purely from an ocx file inside a .cab</p>
<p>
	B. Capturing events fired by the control.</p>
<p>
	In this post I&rsquo;ll explain how I instantiated the control. In an upcoming post I&rsquo;ll explain what I did to capture events.</p>
<h2>
	A. Instantiating an ActiveX dynamically from a .cab</h2>
<p>
	Despite my best efforts, I failed to instantiate EZTwainX directly from the .cab although there were hints it should have been possible. Not for me. To instantiate the control, takes four steps:</p>
<p>
	1. Unpack the eztwainx.cab file into eztwainx.ocx and eztwainx.manifest.ocx, placed alongside the running unit test assembly.</p>
<p>
	2. Set up an <em>activation context</em> that points to the control on disk and push it onto the <em>activation context stack</em>.<br />
	What, you&rsquo;ve never heard of these? Me neither. All part of <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa374151%28v=vs.85%29.aspx" target="_blank">Side-by-side Assemblies or SxS</a>.&nbsp; Overlappingly discussed under the term <a href="http://msdn.microsoft.com/en-us/library/fh1h056h.aspx" target="_blank">Registration-Free COM</a>, also <a href="http://msdn.microsoft.com/en-us/library/ms973913.aspx" target="_blank">here</a>.</p>
<p>
	3. Create the control within that activation context by getting the Type from the GUID and then using <a href="http://msdn.microsoft.com/en-us/library/wccyzw83(v=vs.90).aspx" target="_blank">System.Activator.CreateInstance</a></p>
<p>
	4. Pop the activation context back off the stack and destroy it.</p>
<p>
	In detail:</p>
<h3>
	1. Unpack the .cab</h3>
<p>
	Using a helper function, I use the built-in &lsquo;expand&rsquo; command to unpack the .cab file into the directory alongside the executing unit test assembly.</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; color: ; mso-no-proof: yes"><font face="Courier New"><font color="#008000" style="font-size: 10pt">// Expand the EZTwainX.cab into the folder this test assembly is running from:</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">int</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> exitCode = runCommand(</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515"><font style="font-size: 10pt">&quot;expand.exe&quot;</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">,</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515"><font style="font-size: 10pt">&quot;\&quot;&quot;</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> + <span style="color: "><font color="#2b91af">Path</font></span>.Combine(solutionDir, <span style="color: "><font color="#a31515">@&quot;WebControls\Resources\WebCapture\eztwainx.cab&quot;</font></span>) + <span style="color: "><font color="#a31515">&quot;\&quot;&quot;</font></span> +</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#a31515">&quot; -F:* &quot;</font></span>+</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#a31515">&quot;\&quot;&quot;</font></span> + targetDir + <span style="color: "><font color="#a31515">&quot;\&quot;&quot;</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#2b91af"><font style="font-size: 10pt">Assert</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">.IsTrue((exitCode==0||exitCode==1), <span style="color: "><font color="#a31515">&quot;exit code of expand of eztwainx.cab&quot;</font></span>);</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; color: ; mso-no-proof: yes"><font face="Courier New"><font color="#008000" style="font-size: 10pt">// We allow exitCode 1 because that&#39;s what expand returns when a file</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; color: ; mso-no-proof: yes"><font face="Courier New"><font color="#008000" style="font-size: 10pt">// already exists and can&#39;t be overwritten e.g. when the file is in use.</font></font></span></p>
<p>
	solutionDir = the root directory of the solution that contains the .cab file as a binary resource.<br />
	targetDir = the directory containing the executing unit test assembly.<br />
	Note the quotes inserted around the paths, in case there are spaces in them.</p>
<h3>
	2. Establish an Activation Context</h3>
<p>
	Good reference: <a href="http://msdn.microsoft.com/en-us/library/ms973913.aspx" target="_blank">Registration-Free Activation of COM Components: A Walkthrough by Steve White and Leslie Muller (MSDN)</a></p>
<p>
	Activating an ActiveX purely from files on disk involves an <em><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa374191%28v=vs.85%29.aspx" target="_blank">application manifest</a></em> and an <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa374153%28v=vs.85%29.aspx" target="_blank"><em>activation context</em></a> &ndash; both items poorly documented even by Microsoft standards.&nbsp; This is part of Side-by-Side assemblies, meant to be a solution to &ldquo;DLL Hell&rdquo;.&nbsp; The application manifest is a file associated with the application (so in our case, the unit test class running within NUnit) that &ldquo;describes and identifies the shared and private side-by-side assemblies that an application should bind to at run time&rdquo;.&nbsp; Using the application manifest, we can tell Windows to load and use a particular DLL or COM component from a particular location when the application needs it &ndash; overriding anything in the registry and preventing any default searching.&nbsp; The application just loads and uses the specific versioned file.&nbsp; Here&rsquo;s the manifest used by our unit test, the result of considerable Googling and trial-and-error:</p>
<h4>
	Application Manifest</h4>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">&lt;?</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">xml</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"> </font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">version</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">1.0</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">encoding</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">utf-8</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt">?&gt;</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">&lt;</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">assembly</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"> </font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xsi:schemaLocation</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd</font></span>&quot;</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">manifestVersion</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">1.0</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt"> </font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xmlns:asmv1</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">urn:schemas-microsoft-com:asm.v1</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt"> </font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xmlns:asmv2</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">urn:schemas-microsoft-com:asm.v2</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt"> </font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xmlns:dsig</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">http://www.w3.org/2000/09/xmldsig#</font></span>&quot;</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xmlns</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">urn:schemas-microsoft-com:asm.v1</font></span>&quot;</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">xmlns:xsi</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">http://www.w3.org/2001/XMLSchema-instance</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp; </font></span><font style="font-size: 10pt">&lt;</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">assemblyIdentity</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"> </font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">name</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">client.exe</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">version</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">1.0.0.0</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">processorArchitecture</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">x86</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">type</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">win32</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt"> /&gt;</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp; </font></span><font style="font-size: 10pt">&lt;</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">dependency</font></span></font><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">&lt;</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">dependentAssembly</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><span style="mso-spacerun: yes"><font color="#0000ff">&nbsp; </font></span></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">asmv2:codebase</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">EZTwainX.ocx.manifest</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">&lt;</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">assemblyIdentity</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"> </font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#ff0000">name</font></span><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff">=</font></span></font><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt">&quot;<span style="color: "><font color="#0000ff">EZTwainX.ocx</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">version</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">1.100.0.0</font></span>&quot;<span style="color: "><font color="#0000ff"> </font></span><span style="color: "><font color="#ff0000">type</font></span><span style="color: "><font color="#0000ff">=</font></span>&quot;<span style="color: "><font color="#0000ff">win32</font></span>&quot;</font><span style="color: "><font color="#0000ff" style="font-size: 10pt"> /&gt;</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">&lt;/</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">dependentAssembly</font></span></font><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp; </font></span><font style="font-size: 10pt">&lt;/</font></font></span><font style="font-size: 10pt"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">dependency</font></span></font><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></font></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	<font face="Courier New"><span style="line-height: 12pt; font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">&lt;/</font></font></span><font style="font-size: 10pt"><span style="line-height: 12pt; font-family: ; color: ; mso-no-proof: yes"><font color="#a31515">assembly</font></span></font><span style="line-height: 12pt; font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff" style="font-size: 10pt">&gt;</font></span></font></p>
<p>
	It&rsquo;s mostly boilerplate. The variable parts for us are:</p>
<p>
	<font color="#0000ff" face="Courier New" size="2">&lt;assemblyIdentity name=&quot;client.exe&quot; version=&quot;1.0.0.0&quot; processorArchitecture=&quot;x86&quot; type=&quot;win32&quot; /&gt;</font></p>
<p>
	This describes the application or <em>client</em> &ndash; who is going to be using these external assemblies &ndash; and is half lies but Windows doesn&rsquo;t seem to care. The &ldquo;x86&rdquo; and &ldquo;win32&rdquo; are true: Because the ActiveX is a 32-bit native-code Windows DLL, the application must be a win32 app and must run in x86 mode.</p>
<font color="#0000ff" face="Courier New" size="2">&lt;dependentAssembly asmv2:codebase=&quot;EZTwainX.ocx.manifest&quot;&gt;<br />
&lt;assemblyIdentity name=&quot;EZTwainX.ocx&quot; version=&quot;1.100.0.0&quot; type=&quot;win32&quot; /&gt;<br />
&lt;/dependentAssembly&gt; </font><br />
<p>
	This tells Windows about the one assembly of interest to us, which is used by our test application.&nbsp; It contains the name of the control&rsquo;s manifest, the name of the DLL containing the control, and the version and platform of the control as <em>required by the application</em>.&nbsp; I have to admit I don&rsquo;t remember, but I <em>believe</em> the codebase value is interpreted relative to the directory containing the application manifest.&nbsp; In other words codebase=&rdquo;foo.manifest&rdquo; means foo.manifest in the same folder as this document - the application manifest.</p>
<h4>
	ActivationContext Helper Class</h4>
<p>
	The whole activation-context-with-manifest thing is handled by this little helper class.<br />
	Yes, yes, it&rsquo;s a hack.</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">class</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> </font><span style="color: "><font color="#2b91af" style="font-size: 10pt">ActivationContext</font></span></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> </font></span></font><span style="color: "><font color="#808080" style="font-size: 10pt">&lt;summary&gt;</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span></font><span style="color: "><font color="#008000" style="font-size: 10pt"> Create an instance of a COM object given the GUID of its class</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span></font><span style="color: "><font color="#008000" style="font-size: 10pt"> and a filepath of a client manifest (AKA an application manifest.)</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> </font></span></font><span style="color: "><font color="#808080" style="font-size: 10pt">&lt;/summary&gt;</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> </font></span><span style="color: "><font color="#808080">&lt;param name=&quot;guid&quot;&gt;</font></span><span style="color: "><font color="#008000">GUID = CLSID of the COM object, {NNNN...NNN}</font></span></font><span style="color: "><font color="#808080" style="font-size: 10pt">&lt;/param&gt;</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> </font></span><span style="color: "><font color="#808080">&lt;param name=&quot;manifest&quot;&gt;</font></span></font><span style="color: "><font color="#008000" style="font-size: 10pt">full path of manifest to activate, should list the</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> desired COM class as a dependentAssembly.</font></span></font><span style="color: "><font color="#808080" style="font-size: 10pt">&lt;/param&gt;</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#808080">///</font></span><span style="color: "><font color="#008000"> </font></span><span style="color: "><font color="#808080">&lt;returns&gt;</font></span><span style="color: "><font color="#008000">An instance of the specified COM class, or null.</font></span></font><span style="color: "><font color="#808080" style="font-size: 10pt">&lt;/returns&gt;</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">object</font></span> CreateInstanceWithManifest(<span style="color: "><font color="#2b91af">Guid</font></span> guid, <span style="color: "><font color="#0000ff">string</font></span> manifest)</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">object</font></span> comob = <span style="color: "><font color="#0000ff">null</font></span>;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">ActivationContext</font></span>.UsingManifestDo(manifest, <span style="color: "><font color="#0000ff">delegate</font></span>()</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Get the type object associated with the CLSID.</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">Type</font></span> T = <span style="color: "><font color="#2b91af">Type</font></span>.GetTypeFromCLSID(guid);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Create an instance of the type:</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">comob = System.<span style="color: "><font color="#2b91af">Activator</font></span>.CreateInstance(T);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">});</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">return</font></span> comob;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">delegate</font></span> <span style="color: "><font color="#0000ff">void</font></span> <span style="color: "><font color="#2b91af">doSomething</font></span>();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">void</font></span> UsingManifestDo(<span style="color: "><font color="#0000ff">string</font></span> manifest, <span style="color: "><font color="#2b91af">doSomething</font></span> thingToDo)</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.<span style="color: "><font color="#2b91af">ACTCTX</font></span> context = <span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.<span style="color: "><font color="#2b91af">ACTCTX</font></span>();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">context.cbSize = <span style="color: "><font color="#2b91af">Marshal</font></span>.SizeOf(<span style="color: "><font color="#0000ff">typeof</font></span>(<span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.<span style="color: "><font color="#2b91af">ACTCTX</font></span>));</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">if</font></span> (context.cbSize != 0x20)</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">throw</font></span> <span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#2b91af">Exception</font></span>(<span style="color: "><font color="#a31515">&quot;ACTCTX.cbSize is wrong&quot;</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">context.lpSource = manifest;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">IntPtr</font></span> hActCtx = <span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.CreateActCtx(<span style="color: "><font color="#0000ff">ref</font></span> context);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">if</font></span> (hActCtx == (<span style="color: "><font color="#2b91af">IntPtr</font></span>)(-1))</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">throw</font></span> <span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#2b91af">Win32Exception</font></span>();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">try</font></span> </font><span style="color: "><font color="#008000" style="font-size: 10pt">// with valid hActCtx</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">IntPtr</font></span> cookie = <span style="color: "><font color="#2b91af">IntPtr</font></span>.Zero;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">if</font></span> (!<span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.ActivateActCtx(hActCtx, <span style="color: "><font color="#0000ff">out</font></span> cookie))</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">throw</font></span> <span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#2b91af">Win32Exception</font></span>();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">try</font></span> </font><span style="color: "><font color="#008000" style="font-size: 10pt">// with activated context</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">thingToDo();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#0000ff" style="font-size: 10pt">finally</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.DeactivateActCtx(0, cookie);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#0000ff" style="font-size: 10pt">finally</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">UnsafeNativeMethods</font></span>.ReleaseActCtx(hActCtx);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">SuppressUnmanagedCodeSecurityAttribute</font></span>]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">class</font></span> </font><span style="color: "><font color="#2b91af" style="font-size: 10pt">UnsafeNativeMethods</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Activation Context API Functions</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">DllImport</font></span>(<span style="color: "><font color="#a31515">&quot;Kernel32.dll&quot;</font></span>, SetLastError = <span style="color: "><font color="#0000ff">true</font></span>, EntryPoint = <span style="color: "><font color="#a31515">&quot;CreateActCtxW&quot;</font></span>)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">extern</font></span> <span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#2b91af">IntPtr</font></span> CreateActCtx(<span style="color: "><font color="#0000ff">ref</font></span> <span style="color: "><font color="#2b91af">ACTCTX</font></span> actctx);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">DllImport</font></span>(<span style="color: "><font color="#a31515">&quot;Kernel32.dll&quot;</font></span>, SetLastError = <span style="color: "><font color="#0000ff">true</font></span>)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#0000ff">return</font></span>: <span style="color: "><font color="#2b91af">MarshalAs</font></span>(<span style="color: "><font color="#2b91af">UnmanagedType</font></span>.Bool)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">extern</font></span> <span style="color: "><font color="#0000ff">bool</font></span> ActivateActCtx(<span style="color: "><font color="#2b91af">IntPtr</font></span> hActCtx, <span style="color: "><font color="#0000ff">out</font></span> <span style="color: "><font color="#2b91af">IntPtr</font></span> lpCookie);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">DllImport</font></span>(<span style="color: "><font color="#a31515">&quot;kernel32.dll&quot;</font></span>, SetLastError = <span style="color: "><font color="#0000ff">true</font></span>)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#0000ff">return</font></span>: <span style="color: "><font color="#2b91af">MarshalAs</font></span>(<span style="color: "><font color="#2b91af">UnmanagedType</font></span>.Bool)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">extern</font></span> <span style="color: "><font color="#0000ff">bool</font></span> DeactivateActCtx(<span style="color: "><font color="#0000ff">int</font></span> dwFlags, <span style="color: "><font color="#2b91af">IntPtr</font></span> lpCookie);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">DllImport</font></span>(<span style="color: "><font color="#a31515">&quot;Kernel32.dll&quot;</font></span>, SetLastError = <span style="color: "><font color="#0000ff">true</font></span>)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">static</font></span> <span style="color: "><font color="#0000ff">extern</font></span> <span style="color: "><font color="#0000ff">void</font></span> ReleaseActCtx(<span style="color: "><font color="#2b91af">IntPtr</font></span> hActCtx);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Activation context structure </font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">StructLayout</font></span>(<span style="color: "><font color="#2b91af">LayoutKind</font></span>.Sequential, Pack = 4, CharSet = <span style="color: "><font color="#2b91af">CharSet</font></span>.Unicode)]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">internal</font></span> <span style="color: "><font color="#0000ff">struct</font></span> </font><span style="color: "><font color="#2b91af" style="font-size: 10pt">ACTCTX</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#2b91af">Int32</font></span> cbSize;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#2b91af">UInt32</font></span> dwFlags;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">string</font></span> lpSource;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#2b91af">UInt16</font></span> wProcessorArchitecture;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#2b91af">UInt16</font></span> wLangId;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">string</font></span> lpAssemblyDirectory;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">string</font></span> lpResourceName;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#0000ff">string</font></span> lpApplicationName;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">public</font></span> <span style="color: "><font color="#2b91af">IntPtr</font></span> hModule;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">&nbsp;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	&nbsp;</p>
<h3>
	3. Create an Instance of the Control, in the Activation Context</h3>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Trivial once everything is set up right &ndash; see CreateInstanceWithManifest above.</p>
<h3>
	4. Pop the Activation Context off the Context Stack and Destroy it</h3>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	And the cleanup, which apparently can cause ugly runtime weirdness if not done properly, can be seen in the <em>finally</em> clauses of UsingManifestDo above.</p>
<h2>
	Test SetUp</h2>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Once we have that ActivationContext helper class, setting up and running tests (other than event handling&hellip;) becomes pretty simple.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Here&rsquo;s the function in the unit test class that uses that helper class to instantiate an EZTwainX object, using EZTwainX&rsquo;s GUID and the application manifest file:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">private</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> <span style="color: "><font color="#0000ff">object</font></span> CreateEZTwainX()</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">object</font></span> eztwain = <span style="color: "><font color="#0000ff">null</font></span>;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">string</font></span> manifest = System.IO.<span style="color: "><font color="#2b91af">Path</font></span>.Combine(targetDir, <span style="color: "><font color="#a31515">@&quot;eztwainx.client.manifest&quot;</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#0000ff" style="font-size: 10pt">try</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">eztwain = Atalasoft.Tests.<span style="color: "><font color="#2b91af">ActivationContext</font></span>.CreateInstanceWithManifest(</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#2b91af">Guid</font></span>(<span style="color: "><font color="#a31515">&quot;74F4F118-91E6-4AFC-B8D2-04066781F239&quot;</font></span>), manifest);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">catch</font></span> (<span style="color: "><font color="#2b91af">Exception</font></span>)</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">Console</font></span>.WriteLine(<span style="color: "><font color="#a31515">&quot;EZTwainX creation failed&quot;</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">throw</font></span>;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">return</font></span> eztwain;</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">}</font></font></span></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	&nbsp;</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	<a href="http://msdn.microsoft.com/en-us/library/ms973274.aspx" target="_blank"><img align="right" alt="IC90098" border="0" height="94" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=ffc73441-c00a-4a7f-9a36-87cc153a6789" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="IC90098" width="244" /></a>This function returns a .NET object known as an <a href="http://msdn.microsoft.com/en-us/library/8bwh56xe%28v=vs.90%29.aspx" target="_blank">RCW or Runtime Callable Wrapper</a>, which wraps around and mediates between .NET, and a COM object - in this case an instance of the EZTwainX control. Keep in mind this returned object has type System.Object. It is absolutely not a literal pointer to a COM object or COM interface. It <em>holds</em>, internally, some kind of pointer to the COM object, probably the IUnknown.&nbsp; When you make calls using InvokeMember through the RCW they are translated into COM calls.&nbsp; Normally events coming out of the COM object are translated back to .NET by the RCW, but I was unable to get that to work - we&rsquo;ll get into that in Part B.</p>
<h2>
	Finally: Actual Testing of Methods and Properties</h2>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Once we&rsquo;ve created an EZTwainX control this way, making calls to methods and getting and setting properties is fairly straightforward.&nbsp; For example, here&rsquo;s the beginning of the SetUp method of our test class. This method is run by NUnit before running each designated test method:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">[<span style="color: "><font color="#2b91af">SetUp</font></span>]</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">public</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> <span style="color: "><font color="#0000ff">void</font></span> SetUp()</font></span></font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">{</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Per-test initialization.</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Create an instance of the control:</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">eztwain = CreateEZTwainX();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">EZTwainX = eztwain.GetType();</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#0000ff">string</font></span> version = (<span style="color: "><font color="#0000ff">string</font></span>)EZTwainX.InvokeMember(<span style="color: "><font color="#a31515">&quot;VersionString&quot;</font></span>, <span style="color: "><font color="#2b91af">BindingFlags</font></span>.GetProperty, <span style="color: "><font color="#0000ff">null</font></span>, eztwain, <span style="color: "><font color="#0000ff">null</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">Console</font></span>.WriteLine(<span style="color: "><font color="#a31515">&quot;EZTwainX VersionString=&#39;{0}&#39;&quot;</font></span>, version);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><span style="color: "><font color="#008000" style="font-size: 10pt">// Extract sub-objects</font></span></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">scan = EZTwainX.InvokeMember(<span style="color: "><font color="#a31515">&quot;Scan&quot;</font></span>, <span style="color: "><font color="#2b91af">BindingFlags</font></span>.GetProperty, <span style="color: "><font color="#0000ff">null</font></span>, eztwain, <span style="color: "><font color="#0000ff">null</font></span>);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">Assert</font></span>.IsNotNull(scan);</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><span style="mso-spacerun: yes"><font style="font-size: 10pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 10pt">IScan = scan.GetType();</font></font></span></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	&nbsp;</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	To use InvokeMember, we need both the eztwain object and - kind of weirdly - its System.Type &ndash; kept around in the EZTwainX variable &ndash; which we can get any time with eztwain.GetType().</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	For example, the first call to InvokeMember above gets the value of the property named &lsquo;VersionString&rsquo; of the object eztwain. We convert that to a .NET string and log it to the test output log.&nbsp; This fails at runtime if the value of that property can&rsquo;t be reasonably interpreted as a string.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	By the way, the <span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt"><span style="color: "><font color="#2b91af">Assert</font></span>.IsNotNull(scan)</font></font></span> &ndash; that&rsquo;s a call to the NUnit framework, to do an actual unit test thing. If scan <em>is</em> null at that point, the test immediately exceptions-out and fails, recording a semi-informative message in a build log and causing the entire build to be flagged as failing.&nbsp; Lights begin flashing, sirens go off, Nerf launchers pop up and enter targeting mode &ndash; the joy of <a href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank">Continuous Integration</a>.&nbsp; I have to say, I&rsquo;ve grown very fond of NUnit.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Here are examples of setting a property and calling a method respectively:</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<span style="font-family: ; mso-no-proof: yes"><font face="Courier New"><font style="font-size: 10pt">EZTwainX.InvokeMember(<span style="color: "><font color="#a31515">&quot;AppTitle&quot;</font></span>, <span style="color: "><font color="#2b91af">BindingFlags</font></span>.SetProperty, <span style="color: "><font color="#0000ff">null</font></span>, eztwain, <span style="color: "><font color="#0000ff">new</font></span> <span style="color: "><font color="#0000ff">object</font></span>[] { <span style="color: "><font color="#a31515">&quot;EZTwainX Tests&quot;</font></span> });</font></font></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">bool</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> success = (<span style="color: "><font color="#0000ff">bool</font></span>)EZTwainX.InvokeMember(<span style="color: "><font color="#a31515">&quot;AcquireSingleImage&quot;</font></span>, <span style="color: "><font color="#2b91af">BindingFlags</font></span>.InvokeMethod, <span style="color: "><font color="#0000ff">null</font></span>, eztwain, <span style="color: "><font color="#0000ff">null</font></span>);</font></span></font></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	&nbsp;</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	<font style="background-color: #cccccc">Aside: It seems likely that the new <em><a href="http://msdn.microsoft.com/en-us/library/dd264736.aspx" target="_blank">dynamic</a></em> type in Visual C# 2010 might obviate the whole EZTWainX.InvokeMember thing, allowing us to write e.g.</font></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none">
	<font face="Courier New"><font style="background-color: #cccccc"><span style="font-family: ; color: ; mso-no-proof: yes"><font color="#0000ff"><font style="font-size: 10pt">bool</font></font></span><span style="font-family: ; mso-no-proof: yes"><font style="font-size: 10pt"> success = (<span style="color: "><font color="#0000ff">bool</font></span>)eztwain.<span style="color: "><font color="#a31515">AcquireSingleImage(</font></span>);</font></span></font></font></p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	&nbsp;</p>
<p>
	<font style="background-color: #cccccc">but&hellip; we&rsquo;re still on .NET 3.5.</font></p>
<h2>
	Conclusion</h2>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Whew!&nbsp; That&rsquo;s a lot. Let&rsquo;s save Part B, capturing events in C# from a dynamically instantiated ActiveX control, for the next blog post.&nbsp; Obviously if you just can&rsquo;t wait for that, comment here, or put a watch on my <a href="http://stackoverflow.com/questions/9009069" target="_blank">stackoverflow question about this</a> which I&rsquo;ll be self-answering shortly&hellip;</p>
<h2>
	Random Afterthoughts</h2>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	The application manifest file, <font face="Courier New">eztwainx.client.manifest</font>, has to agree with the control&rsquo;s manifest regarding the version number of the control.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	It seemed to make life simpler to roll the control&rsquo;s <font face="Courier New">eztwainx.ocx.manifest</font> file into the .cab archive, so that&rsquo;s what we did.&nbsp; That way when we unpack the .cab, that manifest ends up alongside the <font face="Courier New">eztwain.ocx</font> that it describes, which is where we need it.&nbsp; We SCC the <font face="Courier New">eztwainx.ocx.manifest</font> as part of the EZTwainX control, so there&rsquo;s a better chance we&rsquo;ll remember to update it when we bump the control&rsquo;s version ;-)</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt">
	Somehow you need to get the application manifest file copied alongside the executing test assembly.&nbsp; I do this by literally copying the file at runtime with file I/O operations. In your dev environment, you might find a simpler way.</p>
]]></description>
     <pubDate>Mon, 06 Feb 2012 16:26:04 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/spikemclarty/february-2012/dynamically-testing-an-activex-control-from-c-and]]></link>
     <dc:creator> SpikeMcLarty</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/jakemitchell/january-2012/depending-on-tools-to-develop-profitable-software]]></guid>
     <title><![CDATA[Depending on Tools to Develop Profitable Software]]></title>
     <description><![CDATA[<p>
	Software engineers don&rsquo;t develop products in a vacuum.&nbsp; We rely on high-level languages, frameworks, and SDKs to get the job done.&nbsp; Even those who create drivers, operating systems, or virtual machines in assembler are confined to the instruction set supported by the target processor.&nbsp; Every engineer in our industry stands on the shoulders of giants.</p>
<p>
	How can we be sure our tools will always behave as expected?&nbsp; In truth, it&rsquo;s rarely feasible to be completely sure they all will.&nbsp; Intel once released a processor that divided only 0.0000000114% of the total input number space <a href="http://www.intel.com/support/processors/pentium/sb/CS-013007.htm">incorrectly</a>.&nbsp; Operating systems and applications seemed to run just fine on it, but a math professor eventually reduced strange results to a <a href="http://www.trnicely.net/pentbug/bugmail1.html">bug</a> in the processor.&nbsp; Have you tested your processor&rsquo;s entire instruction set on all possible inputs and confirmed that all results are correct?&nbsp; What about doing the same for the JIT compiler, IL, .NET Framework, and the .NET high-level languages and their compilers?&nbsp; I&rsquo;d like to see you try--really, I would.</p>
<p>
	Few engineers would ever take that challenge seriously, and yet we solve real problems using these tools all the time.&nbsp; Despite not confirming their correctness, we need enough confidence in our tools to justify using them in our product.&nbsp; Here are some factors that improve my confidence in a tool:</p>
<ol>
	<li>
		Low-level details are cleanly hidden by a definitive interface specification.</li>
	<li>
		All versions have backward compatible interface specifications.</li>
	<li>
		Experiences are consistent with its specification.</li>
	<li>
		Past releases include bug fixes.</li>
	<li>
		Many other engineers depend on it for similar use cases.</li>
	<li>
		Uncertainties about the tool are addressed quickly through the producer&rsquo;s support system or websites like <a href="http://stackoverflow.com/">StackOverflow</a>.</li>
</ol>
<p>
	These factors tell me two important things: the producer respects their tool&rsquo;s abstraction layer and engineers appreciate the value of that abstraction.&nbsp; Without reliable, practical abstractions engineers don&rsquo;t have a firm foundation to build on.</p>
<p>
	After building enough confidence in a tool to develop production applications on top of it, we&rsquo;re still not done assessing the tool.&nbsp; As long as we use that tool or anything that depends on it, we should monitor for inconsistencies with the tool&rsquo;s specification.&nbsp;&nbsp;</p>
<p>
	Defects or unexpected behaviors sometimes surface in the tools we use in our implementations.&nbsp; It&rsquo;s not fun, but it happens.&nbsp; How can we minimize the negative economic impact of those defects?&nbsp; Studies discussed in Steven McConnell&rsquo;s <a href="http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=sr_1_1?ie=UTF8&amp;qid=1326899193&amp;sr=8-1">Code Complete</a> found it costs 10 to 100 times as much to fix a defect after product release compared to fixing the problem when it was first introduced.&nbsp; It&rsquo;s unclear whether the studies distinguish between defects originating in internal or third party modules.&nbsp; What is clear is this: handling defects sooner than later in the product life-cycle reduces overall expenses.</p>
<p>
	Testing helps us identify defects, determine their scope, communicate clearly about the problem, and confirm whether code changes resolve the problem.&nbsp; Every now and then debates spring up in the blogosphere over how much utility testing gives us.&nbsp; Supposing your goal is to develop a profitable product, the utility of your engineering practices need to be evaluated against that goal.&nbsp; Do what you can to reduce the overall cost of development (including maintenance) and maximize market penetration.&nbsp; The nature of your product and target market should determine whether it&rsquo;s best to test by manual trial and error, formal verification, or something in between.</p>
]]></description>
     <pubDate>Thu, 26 Jan 2012 14:28:39 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/jakemitchell/january-2012/depending-on-tools-to-develop-profitable-software]]></link>
     <dc:creator> JakeMitchell</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/loufranco/january-2012/addressing-switching-forces-in-toolkit-buying]]></guid>
     <title><![CDATA[Addressing Switching Forces in Toolkit Buying]]></title>
     <description><![CDATA[<p>
	<a href="http://twitter/bmoesta">Bob Moesta</a> from <a href="http://www.therewiredgroup.com/">The Rewired Group</a> has <a href="http://blogs.hbr.org/johnson/2011/08/what-job-does-social-media-do.html">a framework for thinking about how customers change which product/service</a> they are using to get a job done:</p>
<p>
	<img src="http://bhc3.files.wordpress.com/2012/01/bob-moesta-4-forces-on-customer-jobs-to-be-done.jpg" /></p>
<ul>
	<li>
		Force 1: <strong>Push</strong> of the situation &ndash; something is happening that is making the customer think about switching</li>
	<li>
		Force 2: <strong>Pull</strong> of the new solution &ndash; all of the benefits that the new solution appears to offer</li>
	<li>
		Force 3: <strong>Allegiance</strong> to the current behavior &ndash; the comfort and understanding of the current solution</li>
	<li>
		Force 4: <strong>Anxiety</strong> of the new solution &ndash; the risk in changing</li>
</ul>
<p>
	Bob&rsquo;s theory is that you need to make F1 + F2 &gt; F3 + F4. To do this, you must know what the old behavior is, what the forces are for that behavior, and then figure out what you can do to address them (increase F1 and F2, and decrease F3 and F4)</p>
<p>
	I will analyze a specific case in my market (developer toolkits) to show you how to use the framework.</p>
<p>
	<strong><font size="4">Case:</font></strong></p>
<blockquote>
	<p>
		<strong><font size="4">The customer is an ISV with a product that could be enhanced with a toolkit. </font></strong></p>
	<p>
		<strong><font size="4">The product does not have the features that the toolkit enables.</font></strong></p>
	<p>
		<strong><font size="4">They are currently a non-consumer of any product or service that gets this job done for their customers. Their customers that do the job do so by combining their product with other products to form the full solution.</font></strong></p>
</blockquote>
<p>
	<strong><font size="4">F1: What situation are they in that is making them consider a change in behavior?</font></strong></p>
<ul>
	<li>
		Customers asking for features.</li>
	<li>
		Sales loss analysis is showing prospects wanted the features.</li>
	<li>
		Competitors may already have these features.</li>
</ul>
<blockquote>
	<p>
		<strong>A toolkit vendor could increase this force by</strong></p>
	<ul>
		<li>
			Creating educational pieces about the benefits of features and direct them to ISV customers</li>
		<li>
			Finding ISV&rsquo;s without features and send testimonials</li>
		<li>
			Highlight the accomplishments of customers</li>
	</ul>
</blockquote>
<p>
	<strong><font size="4">F2: What is enticing them to action?</font></strong></p>
<ul>
	<li>
		They could make more revenue with maintenance or by finding new customers or markets</li>
	<li>
		They would not have to learn the details of implementing the feature, but could just incorporate it</li>
	<li>
		They could get to market faster because using a toolkit is faster than implementing one</li>
</ul>
<blockquote>
	<p>
		<strong>A toolkit vendor could increase this force by</strong></p>
	<ul>
		<li>
			Publicizing the market size and opportunity in the businesses of its customers</li>
		<li>
			Polling its customers&rsquo; market on feature requirements and planned uptake time</li>
	</ul>
</blockquote>
<p>
	<strong><font size="4">F3: What situations are causing them not to act?</font></strong></p>
<ul>
	<li>
		<font size="3">Already have a planned roadmap with consequences to changing it</font></li>
	<li>
		<font size="3">They think that the current modular approach (customers combine products) is better</font></li>
</ul>
<blockquote>
	<p>
		<strong>A toolkit vendor could decrease this force by</strong></p>
	<ul>
		<li>
			Showing how the modular approach isn&rsquo;t good enough for important use-cases</li>
		<li>
			Offering professional services or development partners</li>
	</ul>
</blockquote>
<ul>
	<!--EndFragment-->
</ul>
<p>
	<strong><font size="4">F4: What is making them anxious about buying a toolkit?</font></strong></p>
<ul>
	<li>
		<font size="3">Cost</font></li>
	<li>
		<font size="3">Available development capacity</font></li>
	<li>
		<font size="3">Not trusting the customer&rsquo;s support or viability</font></li>
	<li>
		<font size="3">Analysis paralysis (too many choices)</font></li>
</ul>
<blockquote>
	<p>
		<strong>A toolkit vendor could decrease this force by</strong></p>
	<ul>
		<li>
			Having pricing models that line up with revenue models</li>
		<li>
			Offering training and professional services to speed development</li>
		<li>
			Supporting them through evaluation processes</li>
		<li>
			Having Money-back guarantees</li>
		<li>
			Proposing buying guides to use to evaluate choices</li>
		<li>
			Showcasing testimonials</li>
	</ul>
</blockquote>
<p>
	This is just a quick analysis &ndash; much more can be done through customer interviews and by preparing responses and trying them on sales calls.&nbsp; Also, doing this is a good way to build up a content creation strategy that can be used in nurturing campaigns, whitepapers, on your site, brochures, etc.</p>
<p>
	Another thing to realize is that these forces act differently at different points in the buying cycle.&nbsp; Sales loss analysis is probably a very early driver to start to contemplate change &ndash; having too many choices is a later force. During customer interviews, you may want to map out how these forces relate to time and buying milestones.</p>
]]></description>
     <pubDate>Tue, 24 Jan 2012 14:56:26 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/loufranco/january-2012/addressing-switching-forces-in-toolkit-buying]]></link>
     <dc:creator> LouFranco</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/making-your-own-shapes]]></guid>
     <title><![CDATA[DotPdf: Making Your Own Shapes]]></title>
     <description><![CDATA[<p>
	One of the main ways of creating page content in <a href="http://atalasoft.com/products/dotpdf">DotPdf</a> is to use shapes.&nbsp; We give you a number of &ldquo;canned&rdquo; shapes that are very easy to work with (circle, rectangle, path, text, etc.), but you will probably need to make your own shapes at some point.&nbsp; This article is going to show you one way to do that that is very easy.</p>
<p>
	&nbsp;</p>
<p>
	Let&rsquo;s say that you need to create a letterhead that needs to have a donut in the logo.&nbsp; You could just draw the donut directly, but let&rsquo;s say that you&rsquo;re trying to create a whole corporate presence around donuts and you need to draw a lot of donuts in a lot of places.&nbsp; The way to do that is to make a shape.</p>
<p>
	What is a donut?&nbsp; It&rsquo;s two circles of different radii drawn at the same center with a fill color and an outline color.&nbsp; Great &ndash; these feel like things to pass to the constructor and for some properties.&nbsp; We&rsquo;ll start by making a Donut class that is a subclass of PdfBaseShape:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> System.Drawing;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating.Shapes;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Generating;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">using</span> Atalasoft.PdfDoc.Geometry;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">namespace</span> DonutShape
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    [Serializable]
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Donut : PdfBaseShape
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> Donut(PdfPoint center, <span style="color: #0000ff">double</span> innerRadius, <span style="color: #0000ff">double</span> outerRadius, IPdfColor outlineColor, <span style="color: #0000ff">double</span> linewidth, IPdfColor fillColor)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            : <span style="color: #0000ff">base</span>(outlineColor, linewidth, fillColor)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            Center = center;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            OuterRadius = outerRadius;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            InnerRadius = innerRadius;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> Donut(PdfPoint center, <span style="color: #0000ff">double</span> innerRadius, <span style="color: #0000ff">double</span> outerRadius)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            : <span style="color: #0000ff">this</span>(center, innerRadius, outerRadius, PdfColorFactory.FromColor(Color.Black), 1.0, PdfColorFactory.FromColor(Color.Brown))
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> PdfBaseShape CloneInstance()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Donut(Center, InnerRadius, OuterRadius); <span style="color: #008000">// colors will get set by the base class</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> DrawShape(Atalasoft.PdfDoc.Generating.Rendering.PdfPageRenderer r)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> NotImplementedException();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> PdfPoint Center { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> OuterRadius { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">double</span> InnerRadius { <span style="color: #0000ff">get</span>; <span style="color: #0000ff">set</span>; }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	In this case, I made two constructors, one that takes the line color, line thickness and fill color and one that creates a default.&nbsp; Since colors and line styles are handled by the base class, we can just pass those on and forget about them for now.&nbsp; There are really only two pieces of work: be able to clone the shape and be able to draw the shape.&nbsp; Cloning is easy &ndash; just call a constructor with the center and radii.&nbsp; Drawing is also easy, but let&rsquo;s concentrate on that code on its own:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> DrawShape(Atalasoft.PdfDoc.Generating.Rendering.PdfPageRenderer r)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfCircle outer = <span style="color: #0000ff">new</span> PdfCircle(Center, OuterRadius, OutlineColor, Style.Width, FillColor);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfCircle inner = <span style="color: #0000ff">new</span> PdfCircle(Center, InnerRadius, OutlineColor, Style.Width, PdfColorFactory.FromColor(Color.White));
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    outer.Render(r);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    inner.Render(r);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	In this routine, I create two circles, one for the outer circle and one for the inner.&nbsp; The outer I create with the Donut&rsquo;s line and fill properties.&nbsp; The inner I do the same except that the fill I set to white.&nbsp; I can try it out with the following test code:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfGeneratedDocument doc = <span style="color: #0000ff">new</span> PdfGeneratedDocument();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
Donut donut = <span style="color: #0000ff">new</span> Donut(<span style="color: #0000ff">new</span> PdfPoint(288, 400), 18, 100);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
page.DrawingList.Add(donut);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
doc.Save(&quot;<span style="color: #8b0000">donut.pdf</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	When I run the app, I get a page that looks like this:</p>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=24fdc5b9-87f6-4747-8b90-4cb8af027087"><img alt="image" border="0" height="307" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=213516a8-c90b-4c75-998d-f7cadd130888" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" width="240" /></a></p>
<p>
	Hooray &ndash; that&rsquo;s just what I expected!&nbsp; There&rsquo;s a problem, though.&nbsp; If we draw the donut over the top of something else it will cover it up entirely, which is not what we expected:</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfGeneratedDocument doc = <span style="color: #0000ff">new</span> PdfGeneratedDocument();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfGeneratedPage page = PdfDefaultPages.Letter;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
doc.Pages.Add(page);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #008000">// Add a red line from the center out</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
PdfPath path = <span style="color: #0000ff">new</span> PdfPath(PdfColorFactory.FromColor(Color.Red), 8);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
path.MoveTo(288, 400);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
path.LineTo(500, 500);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
page.DrawingList.Add(path);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
Donut donut = <span style="color: #0000ff">new</span> Donut(<span style="color: #0000ff">new</span> PdfPoint(288, 400), 18, 100);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
page.DrawingList.Add(donut);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
doc.Save(&quot;<span style="color: #8b0000">donut.pdf</span>&quot;);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=a9930844-bd77-468e-9657-2702c44928df"><img alt="image" border="0" height="309" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=f8afdbe9-ca3b-4e08-86ff-487eda610711" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" width="238" /></a></p>
<p>
	The problem is clear &ndash; the inner circle is being painted white.&nbsp; This will cover up anything under it.&nbsp; In fact, we depend on that to cover up the brown donut.&nbsp; The solution is to change our approach.&nbsp; Instead of using two PdfCircle shapes, we&rsquo;re going to use one PdfPath shape to represent both circles.&nbsp; A path is a collection of operations that include move, draw line, draw Bezier curve, close the path.&nbsp; The really cool thing is that a path can contain any number of possibly disjoint subpaths, so two circles are easy.&nbsp; To start off with, we need a routine that give a PdfPath shape will add in a circle composed of Bezier curves.&nbsp; To do this, I&rsquo;ll break this out into a new method.&nbsp; The code presented here is based on <a href="http://www.tinaja.com/glib/ellipse4.pdf">an article</a> by Don Lancaster.&nbsp; If you want to learn a great deal about the math behind Bezier curves, <a href="http://www.tinaja.com/cubic01.asp">this is a great place to start</a>.</p>
<pre>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> DrawShape(Atalasoft.PdfDoc.Generating.Rendering.PdfPageRenderer r)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    PdfPath path = <span style="color: #0000ff">new</span> PdfPath(OutlineColor, Style.Width, FillColor);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    MakeCircle(path, OuterRadius, Center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    MakeCircle(path, InnerRadius, Center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.Render(r);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
<span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> PdfPath MakeCircle(PdfPath path, <span style="color: #0000ff">double</span> radius, PdfPoint center)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">double</span> magic = 0.551784 * radius;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.MoveTo(<span style="color: #0000ff">new</span> PdfPoint(-radius, 0) + center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.CurveTo(<span style="color: #0000ff">new</span> PdfPoint(-radius, magic) + center, <span style="color: #0000ff">new</span> PdfPoint(-magic, radius) + center, <span style="color: #0000ff">new</span> PdfPoint(0, radius) + center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.CurveTo(<span style="color: #0000ff">new</span> PdfPoint(magic, radius) + center, <span style="color: #0000ff">new</span> PdfPoint(radius, magic) + center, <span style="color: #0000ff">new</span> PdfPoint(radius, 0) + center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.CurveTo(<span style="color: #0000ff">new</span> PdfPoint(radius, -magic) + center, <span style="color: #0000ff">new</span> PdfPoint(magic, -radius) + center, <span style="color: #0000ff">new</span> PdfPoint(0, -radius) + center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    path.CurveTo(<span style="color: #0000ff">new</span> PdfPoint(-magic, -radius) + center, <span style="color: #0000ff">new</span> PdfPoint(-radius, -magic) + center, <span style="color: #0000ff">new</span> PdfPoint(-radius, 0) + center);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
    <span style="color: #0000ff">return</span> path;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
}
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">
</pre>
<p>
	<a href="http://atalasoft.com/CMSPages/GetFile.aspx?guid=baeda093-fda3-4fe9-aa34-04760bf3887a"><img alt="image" border="0" height="306" src="http://atalasoft.com/CMSPages/GetFile.aspx?guid=aac847c0-7513-46f6-bb17-5e84a89a8080" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" width="237" /></a></p>
<p>
	&nbsp;</p>
<p>
	And, tada, here is our shape.&nbsp; The question is, why isn&rsquo;t the donut hole filled?&nbsp; The answer is that PDF has two different ways to fill paths.&nbsp; The first is called the Even-Odd Rule.&nbsp; The PDF renderer figures out how many lines have been crossed as it goes left to right.&nbsp; If the number is odd, it fills.&nbsp; If the number is even it doesn&rsquo;t.&nbsp; This is the default method for filling.&nbsp; The other method is called the Non-Zero Winding Rule.&nbsp; It is more complicate and has to do with the direction that lines are drawn as they cross the scanline being filled.&nbsp; Lines that cross bottom to top add 1 to the winding number.&nbsp; Lines that cross top to bottom take one away.&nbsp; If the winding number is non-zero, the scanline gets filled.&nbsp; If this circle had been filled with NZW, the center would be brown and cover up the red line.</p>
<p>
	As a final best practice rule for making reusable shapes: make shapes as generic as possible and put them into their own assembly away from the rest of your application.&nbsp; This will make it easier to reuse the shape in other projects and will make it more easier to reload the PDF in DotPdf for further editing.</p>
]]></description>
     <pubDate>Mon, 23 Jan 2012 12:20:33 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/making-your-own-shapes]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/billbither/january-2012/looking-back-at-atalasoft]]></guid>
     <title><![CDATA[Looking Back at Atalasoft]]></title>
     <description><![CDATA[<p>
	Since we are moving to a new blogging platform (and not moving the posts over) I thought it was a good opportunity to reflect back at some blog posts I&rsquo;ve written since I started blogging about 7 years ago during the early years of Atalasoft. Even as the author, it&rsquo;s interesting to read about our progress and my take on it. Please Enjoy!</p>
<p>
	<strong><u>2006</u></strong></p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/01/19/9645.aspx">Venture Funding vs. Bootstrapping</a><br />
	On of my first blog posts about why not to take VC. As you might imagine, I&rsquo;m pretty happy that we didn&rsquo;t take on outside investment.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/01/01/9642.aspx">Inception of a Company Name</a><br />
	This is how the name Atalasoft came to be. It goes into more detail than I give when people ask me in-person, and some helpful tips if you&rsquo;re thinking about a brand name yourself.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/04/14/9940.aspx">New Office &ndash; One Week to Go!</a><br />
	We started with a lot of room to grow. Now we completely fill the space! My office window still has a <a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/10/10/10968.aspx">great view of Mt Tom</a>.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/09/08/from-nothing-to-something.aspx">From Nothing to Something</a><br />
	Talks about how I started Atalasoft. Whoa, my kids are bigger now.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/11/27/11130.aspx">The AJAX Craze: History of AJAX Imaging at Atalasoft</a><br />
	Yup, we knew zero-footprint imaging was the future back in 2006 and already had a couple years on the competition. Now we can call it the HTML Viewer because people expect rich client apps from HTML.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2006/12/11/starting-a-software-company-outside-a-startup-hub.aspx">Starting a Company Outside a Startup Hub</a><br />
	Relates to my experience starting Atalasoft outside of San Francisco, Boston, or New York.</p>
<p>
	<strong><u>2007</u></strong></p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2007/03/13/leveraging-emerging-technology-as-a-foundation-for-your-startup-software-company.aspx">Leveraging Emerging Technology as a Foundation for your Software Startup</a><br />
	Written 5-years ago, but still relevant today.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2007/08/11/financial-stability-of-a-bootstrapper.aspx">Financial Stability of a Bootstrapper</a><br />
	More info about how I started Atalasoft and financed it&rsquo;s growth organically.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2007/11/13/9-concepts-high-tech-ceo-s-should-know-about-software-development.aspx">9 Concepts High-Tech CEO&rsquo;s Should Know about Software Development</a><br />
	Turns out I know a thing or two about that. Still relevant.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2007/11/13/9-concepts-high-tech-ceo-s-should-know-about-software-development.aspx">Atalasoft Inc. &ndash; 5 Years Old</a><br />
	Never would have guessed that Atalasoft would be a Kofax Company at 10-years!</p>
<p>
	<strong><u>2008</u></strong></p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2008/11/15/the-case-for-zero-footprint-document-viewing.aspx">The Case for Zero-Footprint Document Viewing</a><br />
	I would say we called that one and more people understand now</p>
<p>
	<strong><u>2011</u></strong></p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2011/01/29/reflection-on-growing-atalasoft-in-2010.aspx">A Reflection on Growing Atalasoft in 2010</a><br />
	Title speaks for itself. The growth led to the successful acquisition later in 2010.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2011/05/20/the-big-deal-kofax-to-acquire-us.aspx">The Big Deal &ndash; Kofax to Acquire us!</a><br />
	Phew! That took a LOT of work.</p>
<p>
	<a href="http://www.billbither.com/cs/blogs/billbither/archive/2011/11/14/html5-and-the-end-of-the-line-for-flash-and-silverlight.aspx">HTML and the end of the line for Flash and Silverlight</a><br />
	My prediction on the future of Rich Internet Application development, and why we won by investing heavily in HTML.</p>
]]></description>
     <pubDate>Thu, 19 Jan 2012 16:47:52 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/billbither/january-2012/looking-back-at-atalasoft]]></link>
     <dc:creator> BillBither</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/spikemclarty/january-2012/welcome-to-new-england!]]></guid>
     <title><![CDATA[Welcome to New England!]]></title>
     <description><![CDATA[<p>
	Hi, my name is Spike McLarty, and I&rsquo;m a Senior Software Architect here at Atalasoft.&nbsp; I joined the company in January 2010 after running my own one-man company for a decade or so, out on the Left Coast on an island near Seattle.&nbsp; While I have a fair amount of experience across the spectrum of nuts-and-bolts image processing, my particular specialties are some of the old-school technologies: The TWAIN scanning API, imaging file formats like TIFF, GIF, JPEG, PNG and PDF, C and C++ coding, the native Win32 API, COM and ActiveX.&nbsp; When I&rsquo;m not working on scanning and image processing, I study cognitive psychology and linguistics from a computer-modeling perspective.</p>
<p>
	I plan to blog a mix of practical coding tips (the classic &ldquo;don&rsquo;t let this thing that just bit me bite you&rdquo;), speculation about how this or that problem could be solved with computers and software, and accounts of the small epiphanies I have every now and then while studying linguistics and cognitive psychology.</p>
]]></description>
     <pubDate>Thu, 19 Jan 2012 11:26:53 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/spikemclarty/january-2012/welcome-to-new-england!]]></link>
     <dc:creator> SpikeMcLarty</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2012/please-don’t-mind-the-dust]]></guid>
     <title><![CDATA[Please Don’t Mind the Dust]]></title>
     <description><![CDATA[<p>
	Atalasoft is moving the blogs to new hosting software.&nbsp; In the meantime, here are a few favorites of mine from the past:</p>
<p>
	&nbsp;</p>
<ul>
	<li>
		<a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2009/03/25/14-things-every-software-engineer-should-know.aspx">14 Things Every Software Engineer Should Know</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2010/08/03/protect-yourself.aspx">Protect Yourself</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2010/07/08/why-software-has-bugs.aspx">Why Software Has Bugs</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/stevehawley/archive/2006/03/03/9632.aspx">Robotron and OOP</a></li>
</ul>
]]></description>
     <pubDate>Thu, 19 Jan 2012 10:52:58 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/stevehawley/january-2012/please-don’t-mind-the-dust]]></link>
     <dc:creator> SteveHawley</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/insertqualityhere/january-2012/review-redux]]></guid>
     <title><![CDATA[Review & Redux]]></title>
     <description><![CDATA[<p>
	&hellip;Well, it certainly has been a long time since I last wrote something for this blog, but since a new CMS system is setup that should change.&nbsp; Anyway, new CMS.&nbsp; A new year.&nbsp; More posts?&nbsp; That&rsquo;s the plan.&nbsp;<br />
	<br />
	Up and coming: Reaction to the first class of Probabilistic Graphical Models.&nbsp;<br />
	<br />
	For now, some blasts form the past:<br />
	-<a href="http://www.atalasoft.com/cs/blogs/insertqualityhere/archive/2009/10/22/the-six-pillars-of-mpi.aspx">The Six Pillars of MPI</a><br />
	-<a href="http://www.atalasoft.com/cs/blogs/insertqualityhere/archive/2009/08/26/go-on-go-get-all-static-y.aspx">Go on.&nbsp; Go get all staticy</a> - A discussion about static analysis tools<br />
	-<a href="http://www.atalasoft.com/cs/blogs/insertqualityhere/archive/2008/12/04/web-testing-frameworks-compared.aspx">Web Testing Frameworks Compared</a><br />
	-<a href="http://www.atalasoft.com/cs/blogs/insertqualityhere/archive/2008/04/30/crap4j-port-to-net-part-ii.aspx">CRAP4j port to .Net -- Part II:&nbsp; Computing Cyclomatic Complexity</a></p>
]]></description>
     <pubDate>Thu, 19 Jan 2012 10:52:04 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/insertqualityhere/january-2012/review-redux]]></link>
     <dc:creator> InsertQualityHere</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/kenwalpurgis/january-2012/good-day!]]></guid>
     <title><![CDATA[Good Day!]]></title>
     <description><![CDATA[<p>
	Short introduction here.</p>
<p>
	I am a developer at Atalasoft, my main focus for the last couple of years has been building up our internal systems to do our day to day processing(website/Salesforce). I always seem to have my hands in way to many things and never have enough time to reflect on things I have done.&nbsp; I am hoping to build up a collection of examples that will remind me of all the small things I have done throughout the days/weeks/months.&nbsp; Too many times I do something and think &ldquo;wow, that is really cool&rdquo;, only to have it be locked away in some source control system.&nbsp; Today, that ends.</p>
]]></description>
     <pubDate>Wed, 18 Jan 2012 08:29:03 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/kenwalpurgis/january-2012/good-day!]]></link>
     <dc:creator> KenWalpurgis</dc:creator>
</item>
<item>
     <guid isPermaLink="true"><![CDATA[http://www.atalasoft.com/blogs/loufranco/january-2012/re-introducing-my-blog-on-atalasoft-com]]></guid>
     <title><![CDATA[Re-introducing my blog on Atalasoft.com]]></title>
     <description><![CDATA[<p>
	We&rsquo;re changing our blog hosting on Atalasoft.com, so new posts will now be here where your reading this post.&nbsp; If you want to read my old posts, go to <a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/12/29/atalasoft-blogs-2011-retrospective.aspx">Lou Franco&rsquo;s Legacy Atalasoft Blog</a>. Here are some of my favorites over the years, covering the four topics I write about most.</p>
<p>
	<strong>Software Business</strong></p>
<ul>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/10/21/microsoft-s-five-year-plan-for-sharepoint.aspx">Predicting Microsoft&rsquo;s next move</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/05/15/25-ways-to-make-content-more-findable.aspx">25 ways to make content more findable</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/08/31/if-google-can-t-make-a-great-mobile-web-app-can-anyone.aspx">Google can&rsquo;t make mobile web apps as good as native</a>, so can anyone?</li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/11/30/making-an-sdk-better-at-its-job.aspx">Making an SDK better at its job</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/11/09/usefulness-as-a-pretense-for-data-collection.aspx">Usefulness as a pretense for data collection</a></li>
	<li>
		Movie Reviews from a software business perspective
		<ul>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/05/11/star-trek-review-from-an-ecm-perspective.aspx">Star Trek</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2010/07/08/twilight-eclipse-from-a-social-media-perspective.aspx">Twilight: Eclipse</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2010/08/06/inception-movie-review-from-a-data-security-perspective.aspx">Inception</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/11/18/extending-the-social-media-metaphor-in-twilight-breaking-dawn.aspx">Twilight: Breaking Dawn</a></li>
		</ul>
	</li>
</ul>
<p>
	<strong>Tech job seeking</strong></p>
<ul>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2007/05/08/interviewing-tip-prepare.aspx">Prepare for Interviews</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/04/22/please-read-if-you-are-interviewing-at-atalasoft.aspx">Advice for interviewing at Atalasoft</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2010/05/25/you-don-t-need-anyone-s-permission-to-get-work-experience-in-software.aspx">You don&rsquo;t need permission to get software development experience</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/06/14/towards-a-portfolio-based-interview-process-for-programmers.aspx">Portfolio based interviewing for developers</a></li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2011/10/14/you-re-going-to-need-more-than-a-resum.aspx">You need more than a resumé</a></li>
</ul>
<p>
	<strong>Technical </strong></p>
<ul>
	<li>
		This post will help you <a href="http://atalasoft.com/cs/blogs/loufranco/archive/2007/02/06/6-_2200_Pointers_2200_-on-Debugging-Unmanaged-Code.aspx">debug memory munging bugs on Windows</a>.</li>
	<li>
		Here&rsquo;s some technical advice on storing images in Databases
		<ul>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2007/12/03/images-in-databases-part-i-what-to-store.aspx">Part I</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2007/12/04/images-in-databases-part-ii-web-images-are-random-access.aspx">Part II</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/04/28/document-storage-database-blobs-or-the-filesystem.aspx">Some follow up years later</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2009/10/26/more-on-images-in-databases.aspx">More follow up</a></li>
		</ul>
	</li>
	<li>
		Here&rsquo;s some code for generating <a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/04/25/writing-code-39-barcodes-with-javascript.aspx">Code 39 Barcodes in JavaScript</a></li>
	<li>
		Here&rsquo;s <a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/04/01/loading-office-documents-in-net.aspx">.NET code for converting Word to PDF</a> (by scripting Word to do it)</li>
	<li>
		<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2010/06/21/learning-80-s-style-programming-today.aspx">Learn 80&rsquo;s style programming today</a><!--EndFragment--></li>
	<!--EndFragment-->
</ul>
<p>
	<strong>Presenting</strong></p>
<ul>
	<li>
		If you want to know how to <a href="http://atalasoft.com/cs/blogs/loufranco/archive/2007/03/23/6-Ways-to-Mess-Up-Your-Next-Tech-Presentation.aspx">mess up a technical presentation</a>, look no further.</li>
	<li>
		I did a lightning talk at Business of Software in 2008, here&rsquo;s advice if you have to give one
		<ul>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/07/11/giving-a-pecha-kucha-at-the-business-of-software.aspx">Some background</a></li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/07/30/preparing-a-pecha-kucha-part-i.aspx">Part I</a> of my tips</li>
			<li>
				<a href="http://atalasoft.com/cs/blogs/loufranco/archive/2008/07/31/preparing-a-pecha-kucha-part-ii-reading-a-script-sounds-like-reading.aspx">Part II</a> of my tips</li>
			<li>
				<a href="http://www.slideshare.net/loumf/engineering-the-evaluation-funnel-pecha-kucha-presentation">My presentation on SlideShare</a></li>
		</ul>
	</li>
	<!--EndFragment-->
</ul>
]]></description>
     <pubDate>Fri, 13 Jan 2012 07:59:35 GMT</pubDate>
     <link><![CDATA[http://www.atalasoft.com/blogs/loufranco/january-2012/re-introducing-my-blog-on-atalasoft-com]]></link>
     <dc:creator> LouFranco</dc:creator>
</item></channel>
</rss>
