<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Tips</title>
        <link>http://blogs.ugidotnet.org/AntonioGanci/category/2107.aspx</link>
        <description>Tips</description>
        <language>it-IT</language>
        <copyright>Antonio Ganci</copyright>
        <managingEditor>ugog91@yahoo.it</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <item>
            <title>Esempio di codice per generare un pdf tramite la libreria ITextSharp</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/06/04/92915.aspx</link>
            <description>&lt;p&gt;   In questi giorni un mio amico mi ha chiesto un softwarino    (chissà perchè quando si chiede un favore si usa il diminutivo &lt;img src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/wink_smile.gif" alt="" /&gt;) che partendo da una tabella di Access   generasse una serie di Moduli F24 compilati.  &lt;/p&gt;
&lt;p&gt;   Il modulo dell'F24 da compilare si può    &lt;a href="http://www.agenziaentrate.it/ilwwcm/connect/Nsi/Strumenti/Modulistica/Versamenti/modello+f24/"&gt;scaricare&lt;/a&gt;   dal sito dell' &lt;a href="http://www.agenziaentrate.it"&gt;agenzia delle entrate&lt;/a&gt;  &lt;/p&gt;
&lt;p&gt;   A questo punto mi manca una libreria, possibilmente open source, per aggiungere le informazioni necessarie.  &lt;/p&gt;
&lt;p&gt;   Dopo un paio di ricerche ho provato &lt;a href="http://sourceforge.net/projects/itextsharp/"&gt;iTextSharp&lt;/a&gt; porting della   libreria Java iText  &lt;/p&gt;
&lt;p&gt;   Riporto una parte del codice che ho scritto per la generazione del pdf:  &lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red224\green224\blue224;\red24\green24\blue24;\red128\green128\blue192;\red199\green199\blue241;\red254\green241\blue169;\red96\green255\blue96;}??\fs24 \cf1\cb2\highlight2 \tab \cf3 public\cf1  \cf3 class\cf1  \cf4 ReportF24\par ??\cf1 \tab \{\par ??\tab \tab \cf4 BaseFont\cf1  \cf5 m_baseFont\cf1 ;\par ??\tab \tab \cf4 PdfContentByte\cf1  \cf5 m_contentByte\cf1 ;\par ??\tab \tab \cf4 Document\cf1  \cf5 m_document\cf1 ;\par ??\tab \tab \cf4 PdfImportedPage\cf1  \cf5 m_templatePage\cf1 ;\par ??\par ??\tab \tab \cf3 public\cf1  \cf5 ReportF24\cf1 ()\par ??\tab \tab \{\par ??\tab \tab \}\par ??\par ??\tab \tab \cf3 public\cf1  \cf3 void\cf1  \cf5 Open\cf1 (\cf3 string\cf1  \cf5 templateFileName\cf1 , \cf3 string\cf1  \cf5 fileName\cf1 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf4 PdfReader\cf1  \cf5 reader\cf1  = \cf3 new\cf1  \cf4 PdfReader\cf1 (\cf5 templateFileName\cf1 );\par ??\tab \tab \tab \cf4 Rectangle\cf1  \cf5 pageSize\cf1  = \cf5 reader\cf1 .\cf5 GetPageSize\cf1 (1);\par ??\tab \tab \tab \cf5 m_document\cf1  = \cf3 new\cf1  \cf4 Document\cf1 (\cf5 pageSize\cf1 , 50, 50, 50, 50);\par ??\tab \tab \tab \cf4 PdfWriter\cf1  \cf5 writer\cf1  = \cf4 PdfWriter\cf1 .\cf5 GetInstance\cf1 (\cf5 m_document\cf1 , \cf3 new\cf1  \cf4 FileStream\cf1 (\cf5 fileName\cf1 , \cf4 FileMode\cf1 .\cf5 Create\cf1 ));\par ??\tab \tab \tab \cf5 m_document\cf1 .\cf5 Open\cf1 ();\par ??\tab \tab \tab \cf5 m_contentByte\cf1  = \cf5 writer\cf1 .\cf5 DirectContent\cf1 ;\par ??\tab \tab \tab \cf5 m_templatePage\cf1  = \cf5 writer\cf1 .\cf5 GetImportedPage\cf1 (\cf5 reader\cf1 , 1);\par ??\tab \tab \tab \cf5 m_baseFont\cf1  = \cf4 BaseFont\cf1 .\cf5 CreateFont\cf1 (\cf4 BaseFont\cf1 .\cf5 HELVETICA\cf1 , \cf4 BaseFont\cf1 .\cf5 CP1252\cf1 , \cf4 BaseFont\cf1 .\cf5 NOT_EMBEDDED\cf1 );\par ??\tab \tab \}\par ??\par ??\tab \tab \cf3 public\cf1  \cf3 void\cf1  \cf5 AddF24\cf1 (\cf4 ModuloF24\cf1  \cf5 f24\cf1 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 m_document\cf1 .\cf5 NewPage\cf1 ();\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 AddTemplate\cf1 (\cf5 m_templatePage\cf1 , 0, 0);\par ??\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 BeginText\cf1 ();\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 SetFontAndSize\cf1 (\cf5 m_baseFont\cf1 , 12);\par ??\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 f24\cf1 .\cf5 CodiceFiscale\cf1 , 125, 720, 0);\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 GetDenominazioneCondominio\cf1 (\cf5 f24\cf1 .\cf5 Denominazione\cf1 ), 125, 700, 0);\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 f24\cf1 .\cf5 Comune\cf1 , 125, 650, 0);\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 f24\cf1 .\cf5 Provincia\cf1 , 330, 650, 0);\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 f24\cf1 .\cf5 Indirizzo\cf1 , 370, 650, 0);\par ??\par ??\tab \tab \tab \cf3 float\cf1  \cf5 yRigo\cf1  = 613;\par ??\tab \tab \tab \cf3 foreach\cf1  (\cf4 RigoErario\cf1  \cf5 rigoErario\cf1  \cf3 in\cf1  \cf5 f24\cf1 .\cf5 RighiErario\cf1 )\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 rigoErario\cf1 .\cf5 CodiceTributo\cf1 , 160, \cf5 yRigo\cf1 , 0);\par ??\tab \tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0000\}"\cf1 , \cf5 rigoErario\cf1 .\cf5 Mese\cf1 ), 230, \cf5 yRigo\cf1 , 0);\par ??\tab \tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0000\}"\cf1 , \cf5 rigoErario\cf1 .\cf5 Anno\cf1 ), 280, \cf5 yRigo\cf1 , 0);\par ??\tab \tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_RIGHT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0.00\}"\cf1 , \cf5 rigoErario\cf1 .\cf5 Importo\cf1 ), 400, \cf5 yRigo\cf1 ,\par ??\tab \tab \tab \tab                               0);\par ??\tab \tab \tab \tab \cf5 yRigo\cf1  -= 12;\par ??\tab \tab \tab \}\par ??\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_RIGHT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0.00\}"\cf1 , \cf5 f24\cf1 .\cf5 Totale\cf1 ), 400, 540, 0);\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_RIGHT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0.00\}"\cf1 , \cf5 f24\cf1 .\cf5 Totale\cf1 ), 575, 540, 0);\par ??\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_RIGHT\cf1 , \cf3 string\cf1 .\cf5 Format\cf1 (\cf6 "\{0:0.00\}"\cf1 , \cf5 f24\cf1 .\cf5 Totale\cf1 ), 575, 120, 0);\par ??\par ??\tab \tab     \cf3 string\cf1  \cf5 giorno\cf1  = \cf5 f24\cf1 .\cf5 DataPagamento\cf1 .\cf5 Day\cf1 .\cf5 ToString\cf1 (\cf6 "00"\cf1 );\par ??            \cf3 string\cf1  \cf5 mese\cf1  = \cf5 f24\cf1 .\cf5 DataPagamento\cf1 .\cf5 Month\cf1 .\cf5 ToString\cf1 (\cf6 "00"\cf1 );\par ??            \cf3 string\cf1  \cf5 anno\cf1  = \cf5 f24\cf1 .\cf5 DataPagamento\cf1 .\cf5 Year\cf1 .\cf5 ToString\cf1 ();\par ??            \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 giorno\cf1 , 30, 50, 0);\par ??            \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 mese\cf1 , 60, 50, 0);\par ??            \cf5 m_contentByte\cf1 .\cf5 ShowTextAligned\cf1 (\cf4 PdfContentByte\cf1 .\cf5 ALIGN_LEFT\cf1 , \cf5 anno\cf1 , 90, 50, 0);\par ??\par ??\tab \tab \tab \cf5 m_contentByte\cf1 .\cf5 EndText\cf1 ();\par ??\tab \tab \}\par ??\par ??\tab \tab \cf3 public\cf1  \cf3 void\cf1  \cf5 Close\cf1 ()\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 m_document\cf1 .\cf5 Close\cf1 ();\par ??\tab \tab \}\par ??\par ??        \cf3 private\cf1  \cf3 static\cf1  \cf3 string\cf1  \cf5 GetDenominazioneCondominio\cf1 (\cf3 string\cf1  \cf5 denominazione\cf1 )\par ??        \{\par ??            \cf3 if\cf1  (\cf5 denominazione\cf1 .\cf5 IndexOf\cf1 (\cf6 "condominio"\cf1 , 0, \cf4 StringComparison\cf1 .\cf5 CurrentCultureIgnoreCase\cf1 ) == -1)\par ??            \{\par ??                \cf3 return\cf1  \cf6 "CONDOMINIO "\cf1  + \cf5 denominazione\cf1 ;\par ??            \}\par ??\par ??            \cf3 return\cf1  \cf5 denominazione\cf1 ;\par ??        \}\par ??\tab \}\par ??}
--&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Consolas; font-size: 12pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;ReportF24&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(199, 199, 241);"&gt;BaseFont&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_baseFont&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(199, 199, 241);"&gt;Document&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(199, 199, 241);"&gt;PdfImportedPage&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_templatePage&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Open&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;templateFileName&lt;/span&gt;, &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;fileName&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;PdfReader&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;reader&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;PdfReader&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;templateFileName&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Rectangle&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;pageSize&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;reader&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;GetPageSize&lt;/span&gt;(1);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;Document&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;pageSize&lt;/span&gt;, 50, 50, 50, 50);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;PdfWriter&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;writer&lt;/span&gt; = &lt;span style="color: rgb(199, 199, 241);"&gt;PdfWriter&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;GetInstance&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt;, &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;FileStream&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;fileName&lt;/span&gt;, &lt;span style="color: rgb(199, 199, 241);"&gt;FileMode&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Create&lt;/span&gt;));&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Open&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;writer&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;DirectContent&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_templatePage&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;writer&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;GetImportedPage&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;reader&lt;/span&gt;, 1);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_baseFont&lt;/span&gt; = &lt;span style="color: rgb(199, 199, 241);"&gt;BaseFont&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;CreateFont&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;BaseFont&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;HELVETICA&lt;/span&gt;, &lt;span style="color: rgb(199, 199, 241);"&gt;BaseFont&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;CP1252&lt;/span&gt;, &lt;span style="color: rgb(199, 199, 241);"&gt;BaseFont&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;NOT_EMBEDDED&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;AddF24&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;ModuloF24&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;NewPage&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AddTemplate&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;m_templatePage&lt;/span&gt;, 0, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;BeginText&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;SetFontAndSize&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;m_baseFont&lt;/span&gt;, 12);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;CodiceFiscale&lt;/span&gt;, 125, 720, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;,      &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Denominazione&lt;/span&gt;, 125, 700, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Comune&lt;/span&gt;, 125, 650, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Provincia&lt;/span&gt;, 330, 650, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Indirizzo&lt;/span&gt;, 370, 650, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;float&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt; = 613;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(199, 199, 241);"&gt;RigoErario&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;rigoErario&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;in&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;RighiErario&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 200px;"&gt;&lt;span style="color: rgb(254, 241, 169);"&gt;rigoErario&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;CodiceTributo&lt;/span&gt;, 160, &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt;, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 200px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0000}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;rigoErario&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Mese&lt;/span&gt;), 230, &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt;, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 200px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0000}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;rigoErario&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Anno&lt;/span&gt;), 280, &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt;, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_RIGHT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 200px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0.00}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;rigoErario&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Importo&lt;/span&gt;), 400, &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt;, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(254, 241, 169);"&gt;yRigo&lt;/span&gt; -= 12;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_RIGHT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 160px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0.00}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Totale&lt;/span&gt;), 400, 540, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_RIGHT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 160px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0.00}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Totale&lt;/span&gt;), 575, 540, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_RIGHT&lt;/span&gt;, &lt;/p&gt;
&lt;p style="margin: 0px 0px 0px 160px;"&gt;&lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"{0:0.00}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Totale&lt;/span&gt;), 575, 120, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;giorno&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;DataPagamento&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Day&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ToString&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"00"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;mese&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;DataPagamento&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Month&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ToString&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"00"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;anno&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;f24&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;DataPagamento&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Year&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ToString&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;giorno&lt;/span&gt;, 30, 50, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;mese&lt;/span&gt;, 60, 50, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ShowTextAligned&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;PdfContentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ALIGN_LEFT&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;anno&lt;/span&gt;, 90, 50, 0);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_contentByte&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;EndText&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Close&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_document&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Close&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;  }&lt;/p&gt;
&lt;/div&gt;
&lt;p style="margin: 0px;"&gt;          &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;         Il metodo Open Legge il contenuto del pdf del modulo da compilare e crea anche          il PdfWriter in cui verranno aggiunte le pagine compilate.&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;         La classe ModuloF24 (qui non riportata) contiene le informazioni necessarie per          riempire il modulo.&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;          &lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/92915.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/06/04/92915.aspx</guid>
            <pubDate>Wed, 04 Jun 2008 12:30:47 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/92915.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/06/04/92915.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/92915.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/92915.aspx</trackback:ping>
        </item>
        <item>
            <title>Applicazioni Multilingua utilizzando le Windows Forms</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/04/28/92413.aspx</link>
            <description> &lt;p&gt;
   Sto sviluppando un'applicazione che utilizza le Windows Forms e dovrà supportare più lingue. Vorrei condividere la soluzione che sto progettando/implementando.
 &lt;/p&gt;
    &lt;p&gt;
        L'idea è quella di utilizzare la classe &lt;a href="http://msdn2.microsoft.com/en-us/library/system.resources.resourcemanager.aspx"&gt;
            ResourceManager&lt;/a&gt; la quale si occupa di leggere
        le stringhe in base alla lingua corrente. Vediamolo in pratica:&lt;/p&gt;
    &lt;p&gt;
        Per prima cosa creiamo un progetto che chiameremo MultilingualWindowsApplication
        ed aggiungiamo due resources file di nome:&lt;/p&gt;
    &lt;ul&gt;
        &lt;li&gt;Local.en.resx&lt;/li&gt;
        &lt;li&gt;Local.it.resx&lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;
        Il primo conterrà le stringhe in lingua inglese ed il secondo quelle in italiano,
        quindi se un domani dovremmo aggiungere il tedesco basterà creare il file di risorse
        (Local.de.resx).&lt;/p&gt;
    &lt;p&gt;
       &lt;img src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/AntonioGanci/1890/o_MultilingualWindowsApplicationSolutionExplorer.png" alt="MultilingualWindowsApplication Solution Explorer" /&gt; &lt;/p&gt;
    &lt;p&gt;
        Nella Form1 aggiungiamo un MenuStrip che in base alla lingua del sistema operativo
        visualizzerà le varie voci nella lingua corretta:&lt;/p&gt;
    &lt;p&gt;
       &lt;img src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/AntonioGanci/1890/o_MenuStrip.png" alt="MenuStrip" /&gt; &lt;/p&gt;
    &lt;p&gt;
        Ora aggiungiamo una variabile membro alla Form1 di tipo ResourceManager:&lt;/p&gt;
&lt;div style="font-family: Courier New; font-size: 10pt; color: #e0e0e0; background: #181818;"&gt;
&lt;p style="margin: 0px;"&gt;  &lt;span style="color: #8080c0;"&gt;public&lt;/span&gt; &lt;span style="color: #8080c0;"&gt;partial&lt;/span&gt; &lt;span style="color: #8080c0;"&gt;class&lt;/span&gt; &lt;span style="color: #c7c7f1;"&gt;Form1&lt;/span&gt; : &lt;span style="color: #c7c7f1;"&gt;Form&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;  {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: #8080c0;"&gt;private&lt;/span&gt; &lt;span style="color: #c7c7f1;"&gt;ResourceManager&lt;/span&gt; &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: #8080c0;"&gt;public&lt;/span&gt; &lt;span style="color: #fef1a9;"&gt;Form1&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;InitializeComponent&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt; = &lt;span style="color: #8080c0;"&gt;new&lt;/span&gt; &lt;span style="color: #c7c7f1;"&gt;ResourceManager&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"MultilingualWindowsApplication.Local"&lt;/span&gt;,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: #c7c7f1;"&gt;Assembly&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetExecutingAssembly&lt;/span&gt;());&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;  }&lt;/p&gt;
&lt;/div&gt;
 &lt;p&gt;
    Impostiamo la traduzione nelle due lingue utilizzando il resource editor:&lt;/p&gt;
    &lt;p&gt;
        &lt;img src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/AntonioGanci/1890/o_ResourceEditor.png" alt="Resources Editor" /&gt; &lt;/p&gt;
    &lt;p&gt;
        Per leggere la stringa nella lingua corretta utilizzeremo il metodo GetString:&lt;/p&gt;
&lt;div style="font-family: Courier New; font-size: 10pt; color: #e0e0e0; background: #181818;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: #8080c0;"&gt;private&lt;/span&gt; &lt;span style="color: #8080c0;"&gt;void&lt;/span&gt; &lt;span style="color: #fef1a9;"&gt;LocalizeUITexts&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;fileToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_File"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;apriToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Apri"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;salvaToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Salva"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;salvaConNomeToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_SalvaConNome"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;esciToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Esci"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;modificaToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Modifica"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;tagliaToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Taglia"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;copiaToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Copia"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #fef1a9;"&gt;incollaToolStripMenuItem&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;Text&lt;/span&gt; = &lt;span style="color: #fef1a9;"&gt;_resources&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;GetString&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"Menu_Incolla"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  
 Modifichiamo la lingua corrente per vedere se tutto funziona correttamente
    anche in inglese:&lt;/p&gt;
&lt;div style="font-family: Courier New; font-size: 10pt; color: #e0e0e0; background: #181818;"&gt;
&lt;p style="margin: 0px;"&gt;      &lt;span style="color: #c7c7f1;"&gt;Thread&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;CurrentThread&lt;/span&gt;.&lt;span style="color: #fef1a9;"&gt;CurrentUICulture&lt;/span&gt; = &lt;span style="color: #8080c0;"&gt;new&lt;/span&gt; &lt;span style="color: #c7c7f1;"&gt;CultureInfo&lt;/span&gt;(&lt;span style="color: #60ff60;"&gt;"en-US"&lt;/span&gt;);&lt;/p&gt;
&lt;/div&gt;
    &lt;p&gt;
    Per evitare di gestire la sincronizzazione dei file di risorse nelle varie lingue
    consiglio l'utilizzo di &lt;a href="http://www.screwturn.eu/(X(1)S(zysoksu3yqgi0wjtued1ar55))/ResxSync.ashx"&gt;
        RESX Synchronizer&lt;/a&gt; è una piccola utility che impostando il file di risorse
    sorgente es (Local.en.resx) e destinazione crea o cancella tutte le stringhe che
    mancano o sono in più.&lt;/p&gt;
    &lt;p&gt;
        Un'altra tecnica è quella di far generare il file di risorse dall'IDE. Per far questo
        occorre impostare a true la property Localizable della Form, come spiegato in questo
        &lt;a href="http://msdn2.microsoft.com/en-us/library/8bxdx003(VS.71).aspx"&gt;post&lt;/a&gt;
        delle MSDN.&lt;/p&gt;
 &lt;p&gt;
     Non ho usato quell'approccio perchè avrei un file di risorse per ogni form da localizzare,
     inoltre se ho la stessa stringa in diverse form devo duplicare la traduzione in
     tutte le form, infine le chiavi delle stringhe hanno nomi poco chiari (per chi non
     fa lo sviluppatore di mestiere) come:&lt;/p&gt;
    &lt;p&gt;
        salvaToolStripMenuItem.Text&lt;/p&gt;
    &lt;p&gt;
        Nel mio caso la traduzione nelle varie lingue è fatto da altre persone e quindi
        sarebbe complicato anche la sincronizzazione di tutti questi resx a fronte di uno
        solo per tutte le form.&lt;/p&gt;
&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/92413.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/04/28/92413.aspx</guid>
            <pubDate>Mon, 28 Apr 2008 12:22:23 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/92413.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/04/28/92413.aspx#feedback</comments>
            <slash:comments>9</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/92413.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/92413.aspx</trackback:ping>
        </item>
        <item>
            <title>Macro per Vistual Studio .NET 2005 per eseguire un commando con parametro il path dell'item selezionato del Solution Explorer</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/01/22/90809.aspx</link>
            <description>Tutti i passi necessari per  creare una macro per Visual Studio 2005 che esegua un comando passando come parametro il path dell'item selezionato nel Solution Explorer...

&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/90809.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/01/22/90809.aspx</guid>
            <pubDate>Tue, 22 Jan 2008 11:38:32 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/90809.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2008/01/22/90809.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/90809.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/90809.aspx</trackback:ping>
        </item>
        <item>
            <title>Alcuni approcci per testare il valore di un oggetto che non sia un value type in uno unit test</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/12/07/90154.aspx</link>
            <description>&lt;p&gt;  In questo post analizzerò il problema di testare il risultato di un operazione che ritorni un oggetto complesso anzichè un semplice value type (int, double, ...), nel post propongo una serie di possbili soluzioni. &lt;/p&gt;
&lt;p&gt;  Supponiamo di avere una classe che calcola alcune statistiche su una serie di valori: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(128, 128, 192);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Calculate&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt;[] &lt;span style="color: rgb(254, 241, 169);"&gt;values&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(192, 128, 192);"&gt;// ...&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  &lt;em&gt;(Questa classe soffre di un problema di design, il metodo Calculate fa troppe cose insieme; in un progetto  reale avrei creato un metodo diverso per ogni statistica)&lt;/em&gt; &lt;/p&gt;
&lt;p&gt;  E di voler testare il metodo Calculate:     &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    [&lt;span style="color: rgb(199, 199, 241);"&gt;TestFixture&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculatorTests&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        [&lt;span style="color: rgb(199, 199, 241);"&gt;Test&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Test1&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Calculate&lt;/span&gt;(&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt;[] {1, 2, 3});&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Count&lt;/span&gt; = 3;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Minimum&lt;/span&gt; = 1;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Maximum&lt;/span&gt; = 3;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Mean&lt;/span&gt; = 2;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  Se eseguiamo il test, supponendo che il codice del metodo Calculate sia corretto,      &lt;strong&gt;l'Assert fallisce&lt;/strong&gt;.  Il motivo è che anche se i valori delle due classi sono uguali la Assert.AreEqual usa il metodo Equals, il  quale di default considera due classi uguali se &lt;strong&gt;le variabili referenziano la stessa instanza&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;  Una prima soluzione a questo problema potrebbe essere quella di scrivere un Assert per ogni property della classe  StatisticValue: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;        [&lt;span style="color: rgb(199, 199, 241);"&gt;Test&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Test1&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Calculate&lt;/span&gt;(&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt;[] {1, 2, 3});&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(3, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Count&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(1, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Minimum&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(3, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Maximum&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(2, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Mean&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  Il test ora passerà, ma questo approccio secondo me ha almeno due svantaggi: Se un domani alla classe StatisticValue aggiungiamo  una nuova property per esempio Variance dobbiamo ricordarci di andare su tutti i test già scritti per il metodo Calculator  e aggiungere una nuova Assert, perchè altrimenti, anche se ci fosse un bug nel codice nel calcolo della varianza, i test  passerebbero ugualmente!. Il secondo svantaggio (minore) consiste nell'avere più assert nello stesso test; nel caso in cui fallisse  devo andare a vedere dentro il codice del test per capire qual'è il problema, perchè risulta impossibile determinarlo leggendo  solo il nome del test che fallisce.  &lt;/p&gt;
&lt;p&gt;     Un'alternativa è quella di ridefinire il comportamento di default del metodo Equals  della classe StatisticValues: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;bool&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Equals&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;object&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;obj&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;ReferenceEquals&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;obj&lt;/span&gt;)) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;true&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;obj&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;as&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt; == &lt;span style="color: rgb(128, 128, 192);"&gt;null&lt;/span&gt;) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;m_minimum&lt;/span&gt; != &lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;m_minimum&lt;/span&gt;) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;m_maximum&lt;/span&gt; != &lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;m_maximum&lt;/span&gt;) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;m_count&lt;/span&gt; != &lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;m_count&lt;/span&gt;) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(254, 241, 169);"&gt;m_mean&lt;/span&gt; != &lt;span style="color: rgb(254, 241, 169);"&gt;statisticValues&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;m_mean&lt;/span&gt;) &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;true&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  In questo modo il test precedente con una sola Assert passerà, rimane ancora il problema che se il test fallisse non  posso sapere quale delle varie statistiche non è stata calcolata correttamente; per ovviare a questo possiamo fare  l'ovveride del metodo ToString della classe StatisticValues che ci restituisca qualcosa di più significativo. &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;ToString&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Format&lt;/span&gt;(&lt;span style="color: rgb(96, 255, 96);"&gt;"Min: {0} Max: {1} Mean: {2} Count:{3}"&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;Minimum&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;Maximum&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;Mean&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;Count&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  A volte questa strada potrebbe non essere praticabile perchè ad esempio non ho la possibilità di modificare il codice della  classe in quanto si trova in una libreria esterna di terze parti, oppure perchè l'ovveride è già stato fatto in modo diverso:     si pensi  ad esempio ad una classe Customer con un campo ID dove Equals considera due Customer uguali se hanno lo stesso ID. &lt;/p&gt;
&lt;p&gt;  La causa di questo problema è data dalla creazione di un'istanza dell'oggetto StatisticValue all'interno del metodo Calculate.  Potremmo averne il controllo se la creazione dell'instanza la facciamo fare ad una classe Factory che passiamo alla classe  StatisticCalculator. &lt;/p&gt;
&lt;p&gt;  Questa classe Factory implementerà la seguente interfaccia: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(128, 128, 192);"&gt;interface&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;IStatisticValuesFactory&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Create&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;minimum&lt;/span&gt;, &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;maximum&lt;/span&gt;, &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;mean&lt;/span&gt;, &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;count&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  A questo punto passiamo l'interfaccia al costruttore di StatisticCalculator e modifichiamo il codice del medoto Calculate: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(128, 128, 192);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;readonly&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;IStatisticValuesFactory&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_factory&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;StatisticCalculator&lt;/span&gt;(&lt;span style="color: rgb(199, 199, 241);"&gt;IStatisticValuesFactory&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;factory&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;m_factory&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;factory&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Calculate&lt;/span&gt;(&lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt;[] &lt;span style="color: rgb(254, 241, 169);"&gt;values&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;min&lt;/span&gt; = 0, &lt;span style="color: rgb(254, 241, 169);"&gt;max&lt;/span&gt; = 0, &lt;span style="color: rgb(254, 241, 169);"&gt;mean&lt;/span&gt; = 0, &lt;span style="color: rgb(254, 241, 169);"&gt;count&lt;/span&gt; = 0;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(192, 128, 192);"&gt;// ...&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(128, 128, 192);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;m_factory&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Create&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;min&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;max&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;mean&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;count&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  Nel test dovremmo quindi introdurre un mock di IStatisticValuesFactory: &lt;/p&gt;
&lt;div style="background: rgb(24, 24, 24) none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: rgb(224, 224, 224); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;        [&lt;span style="color: rgb(199, 199, 241);"&gt;Test&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(128, 128, 192);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;Test1&lt;/span&gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Count&lt;/span&gt; = 3;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Minimum&lt;/span&gt; = 1;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Maximum&lt;/span&gt; = 3;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Mean&lt;/span&gt; = 2;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;MockRepository&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;mocks&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;MockRepository&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;IStatisticValuesFactory&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;factory&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;mocks&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;CreateMock&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(199, 199, 241);"&gt;IStatisticValuesFactory&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Expect&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Call&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;factory&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Create&lt;/span&gt;(1, 3, 2, 3))&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                .&lt;span style="color: rgb(254, 241, 169);"&gt;Return&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(254, 241, 169);"&gt;mocks&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;ReplayAll&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt; = &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticCalculator&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;factory&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;StatisticValues&lt;/span&gt; &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt; = &lt;span style="color: rgb(254, 241, 169);"&gt;calculator&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;Calculate&lt;/span&gt;(&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(128, 128, 192);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(128, 128, 192);"&gt;double&lt;/span&gt;[] {1, 2, 3});&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(199, 199, 241);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(254, 241, 169);"&gt;AreEqual&lt;/span&gt;(&lt;span style="color: rgb(254, 241, 169);"&gt;expectedResult&lt;/span&gt;, &lt;span style="color: rgb(254, 241, 169);"&gt;result&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;  Un'ultima alternativa che mi viene in mente è quella di scrivere un metodo simile all'Assert.AreEqual   che usi la reflection per controllare i valori delle property se gli vengono passati delle classi che non siano  Value type. &lt;/p&gt;
&lt;p&gt;  Avete mai avuto un problema simile? Che approccio usate? &lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/90154.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/12/07/90154.aspx</guid>
            <pubDate>Fri, 07 Dec 2007 10:06:37 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/90154.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/12/07/90154.aspx#feedback</comments>
            <slash:comments>17</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/90154.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/90154.aspx</trackback:ping>
        </item>
        <item>
            <title>Un controllo Datagrid open source per WinForms</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/10/15/88948.aspx</link>
            <description> &lt;p&gt;
     &lt;img src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/AntonioGanci/1890/o_SourceGridSample.png" alt="SourceGrid Sample" /&gt; &lt;/p&gt;
    &lt;p&gt;
  Nel progetto su cui sto lavorando avevo bisogno di un controllo Datagrid flessibile e semplice da usare.
    &lt;/p&gt;
 &lt;p&gt;
  Mi sono ricordato dell'&lt;a href="http://spreadsheets.google.com/pub?key=pKxDW35algYebfs8nssTjIQ"&gt;elenco&lt;/a&gt; di progetti 
  open source legati al mondo .NET creato da Jeff Atwood per un 
  &lt;a href="http://www.codinghorror.com/blog/archives/000904.html"&gt;contest&lt;/a&gt; con in
     palio 10.000$ (5.000 da Jeff e 5.000 da Microsoft).&lt;/p&gt;
 &lt;p&gt;
  In quell'elenco viene segnalato il progetto 
  &lt;a href="http://www.google.com/url?q=http://www.devage.com/Wiki/ViewArticle.aspx%3Fname%3Dsourcegrid%26version%3D0&amp;amp;sa=D&amp;amp;usg=ALhdy2_wr5v03L8m9IIE-H0W8lMDN8ZbYQ"&gt;SourceGrid&lt;/a&gt;.
  Leggendo la documentazione, a prima vista molto ben fatta, ci sono due tipi di controlli grid:  
 &lt;/p&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;GridVirtual:&lt;/strong&gt; per griglie di grosse dimensioni sono composte da 
            &lt;em&gt;virtual cells&lt;/em&gt; le quali contengono
        le informazioni sull'aspetto e comportamento, ma non sul valore.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Grid:&lt;/strong&gt; per griglie di piccole dimensioni sono composte da &lt;em&gt;real
            cells&lt;/em&gt; a differenza delle virtual contengono anche il valore.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;
        Le celle sono implementate utilizzando il pattern &lt;a href="http://martinfowler.com/eaaCatalog/modelViewController.html"&gt;
            Model-View-Controller&lt;/a&gt;.&lt;/p&gt;
    &lt;p&gt;
        La sto utilizzando da pochi giorni e mi sto trovando bene, per ora sto usando solo
        la grid con real cells, mi piace soprattutto la semplicità di utilizzo e la grande
        flessibilità che sembra avere, inoltre la documentazione è dettagliata e chiara.&lt;/p&gt;
  
&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/88948.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/10/15/88948.aspx</guid>
            <pubDate>Mon, 15 Oct 2007 09:15:06 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/88948.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/10/15/88948.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/88948.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/88948.aspx</trackback:ping>
        </item>
        <item>
            <title>Tool Open Source per creare Sequence Diagram</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/09/04/88106.aspx</link>
            <description>&lt;p&gt;    In questi giorni cercavo un tool per creare velocemente     &lt;a href="http://www.agilemodeling.com/artifacts/sequenceDiagram.htm"&gt;Sequence Diagram&lt;/a&gt;    ed ho trovato &lt;a href="http://devintelligence.com/cs/blogs/netadventures/archive/2007/08/14/sdedit-quick-sequence-diagram-editor.aspx"&gt;sdedit&lt;/a&gt;.    &lt;/p&gt;
&lt;p&gt;    Ad una prima occhiata sembra sufficientemente semplice da usare, in quanto i sequence      diagram si specificano tramite un linguaggio la cui sintassi è descritta &lt;a href="http://sdedit.sourceforge.net/enter_text/index.html"&gt;          qui&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;         Ho provato a buttarne giù uno alla veloce ed ecco il risultato:&lt;/p&gt;
&lt;p&gt;         &lt;img alt="Sequence Diagram" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/AntonioGanci/1890/o_SequenceDiagram.jpg" /&gt; &lt;/p&gt;
&lt;p&gt;Il sorgente che l'ha prodotto è il seguente:&lt;/p&gt;
&lt;p&gt;      &lt;span style="font-size: 10pt; font-family: Courier New;"&gt;view:IChartWindowView presenter:ChartWindowPresenter&lt;br /&gt;
model:ChartWindowModel          &lt;br /&gt;
paneContainerModel:IChartPaneContainerModel&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;         &lt;span style="font-size: 10pt; font-family: Courier New;"&gt;view:presenter.OnInsertBorsaItalianaSymbol             &lt;br /&gt;
presenter:plottableSymbol=model.PromptUserForBorsaItalianaSymbolToPlot             &lt;br /&gt;
presenter:model.AddBorsaItalianaSymbol(plottableSymbol.Symbol)             &lt;br /&gt;
presenter:paneIndex=model.CreatePane             &lt;br /&gt;
model:paneContainerModel.CreatePane model:paneContainerModel.SetShowGridOption(show)             &lt;br /&gt;
model:paneIndex=paneContainerModel.getPaneCount             &lt;br /&gt;
presenter:model.AddPlottableObject(plottableSymbol, paneIndex)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;      Nella parte prima della riga vuota sono definiti gli oggetti, mentre nella parte inferiore i messaggi che si scambiano.     &lt;/p&gt;
&lt;p&gt;         Certo che se fosse possibile fare lo stesso da Visual Studio come per il Class Diagram         sarebbe tutta un'altra cosa, ma per ora mi accontento.&lt;/p&gt;
&lt;p&gt;    Fonte: &lt;a href="http://www.larkware.com/dg9/TheDailyGrind1208.aspx"&gt;Larkware News&lt;/a&gt;     &lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/88106.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/09/04/88106.aspx</guid>
            <pubDate>Tue, 04 Sep 2007 09:06:30 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/88106.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/09/04/88106.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/88106.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/88106.aspx</trackback:ping>
        </item>
        <item>
            <title>Alcuni link per migliorare il proprio inglese</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/07/15/85705.aspx</link>
            <description>&lt;P&gt;E' estate, tempo di vacanze, quale migliore occasione per migliorare il proprio inglese. L'inglese di uso comune, magari imparando qualche nuovo &lt;A href="http://en.wikipedia.org/wiki/Idiom"&gt;idiom&lt;/A&gt;, visto che quello tecnico lo utilizziamo per il nostro lavoro. &lt;/P&gt;
&lt;P&gt;Partiamo con &lt;A href="http://www.eslpod.com/website/index.php"&gt;English as a Second Language Podcast&lt;/A&gt; una serie di podcast in inglese in cui vengono usati termini semplici per introdurre concetti pi&amp;#249; complessi. I podcast sono stati studiati per chi si trova ad un livello lower intermediate perch&amp;#232; vengono pronunciati al 70% della velocit&amp;#224; a cui un inglese normalmente parla.&lt;/P&gt;
&lt;P&gt;In questo &lt;A href="http://www.eslpod.com/thankyou.html"&gt;podcast&lt;/A&gt; vengono dati alcuni consigli su come migliorare la conoscenza della lingua.&lt;/P&gt;
&lt;P&gt;Ho trovato ben fatto anche &lt;A href="http://www.englishpod.com/"&gt;EnglishPod&lt;/A&gt; in cui i podcast sono suddivisi per livello di difficolt&amp;#224;. &lt;/P&gt;
&lt;P&gt;Per migliorare invece la comprensione dell'inglese scritto consiglio di utilizzare un dizionario in lingua e non un dizionario che traduce in italiano, come l'ottimo, &lt;A href="http://www.thefreedictionary.com/"&gt;The Free Dictionary&lt;/A&gt;, oppure se si desidera (come per me) possederne uno cartaceo; consiglio il Merriam-Webster di cui ne esistono diverse &lt;A href="http://www.amazon.com/s/ref=nb_ss_gw/103-1821851-9783830?initialSearch=1&amp;amp;url=search-alias%3Daps&amp;amp;field-keywords=merriam+webster&amp;amp;Go.x=0&amp;amp;Go.y=0&amp;amp;Go=Go"&gt;versioni&lt;/A&gt;. Questo perch&amp;#232; ci si abitua a pensare in inglese e a non tradurre mentalmente mentre si ascolta.&lt;/P&gt;
&lt;P&gt;Un'altra risorsa utile sono i &lt;A href="http://www.garzantilinguistica.it/dubbi_eng.html"&gt;False Friends&lt;/A&gt; cio&amp;#232; parole che assomigliano a parole in italiano, ma che hanno signicato completamente diverso come ad esempio:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;addiction&lt;/STRONG&gt; significa:dipendenza, assuefazione &amp;#8220;Addiction to smoking&amp;#8221; &amp;#8220;Dipendenza dal fumo&amp;#8221; non:addizione (=sum)&lt;/P&gt;
&lt;P&gt;Infine per chi deve redarre un CV in inglese consiglio di utilizzare il formato &lt;A href="http://europass.cedefop.europa.eu/europass/home/vernav/Europasss+Documents/Europass+CV/navigate.action?locale_id=12"&gt;Europass&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Spero che questi link vi tornino utili.&lt;/P&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/85705.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/07/15/85705.aspx</guid>
            <pubDate>Sun, 15 Jul 2007 13:28:00 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/85705.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/07/15/85705.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/85705.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/85705.aspx</trackback:ping>
        </item>
        <item>
            <title>Eseguire x operazioni contemporamente utilizzando la classe Semaphore</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/06/19/82724.aspx</link>
            <description>&lt;P&gt;In questi giorni ho avuto la necessit&amp;#224; di eseguire n operazioni in gruppi al max di x operazioni contemporaneamente. In pratica devo estrarre alcune informazioni da pagine web e per ottimizzare le performance eseguo 5 (parametro configurabile) scaricamenti contemporaneamente da altrettanti thread. &lt;/P&gt;
&lt;P&gt;Per gestire il tutto ho usato la classe &lt;A href="http://msdn2.microsoft.com/en-us/library/system.threading.semaphore.aspx"&gt;Semaphore&lt;/A&gt;, vediamo come. &lt;/P&gt;
&lt;P&gt;Partiamo dal main: &lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: #181818; COLOR: #e0e0e0; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    1&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;using&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;System&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    2&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;using&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;System&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Collections&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Generic&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    3&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;using&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;System&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Threading&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    4&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    5&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;namespace&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;MultithreadingExperiments&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    6&lt;/SPAN&gt; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    7&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #8080c0"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;Program&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    8&lt;/SPAN&gt;     {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    9&lt;/SPAN&gt;         [&lt;SPAN style="COLOR: #c7c7f1"&gt;STAThread&lt;/SPAN&gt;]&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   10&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;Main&lt;/SPAN&gt;()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   11&lt;/SPAN&gt;         {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   12&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Semaphore&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;pool&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;Semaphore&lt;/SPAN&gt;(5, 5);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   13&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Random&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;rand&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;Random&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   14&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;List&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt;&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;threads&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;List&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt;&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   15&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #8080c0"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #8080c0"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;i&lt;/SPAN&gt; = 0; &lt;SPAN style="COLOR: #fef1a9"&gt;i&lt;/SPAN&gt; &lt; 100; &lt;SPAN style="COLOR: #fef1a9"&gt;i&lt;/SPAN&gt;++)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   16&lt;/SPAN&gt;             {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   17&lt;/SPAN&gt;                 &lt;SPAN style="COLOR: #c7c7f1"&gt;ConsoleWriter&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;writer&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;ConsoleWriter&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #fef1a9"&gt;i&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #fef1a9"&gt;rand&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Next&lt;/SPAN&gt;(1, 10) * 1000, &lt;SPAN style="COLOR: #fef1a9"&gt;pool&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   18&lt;/SPAN&gt;                 &lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;thread&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #8080c0"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;ThreadStart&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #fef1a9"&gt;writer&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;DoSomeWork&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   19&lt;/SPAN&gt;                 &lt;SPAN style="COLOR: #fef1a9"&gt;thread&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Start&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   20&lt;/SPAN&gt;                 &lt;SPAN style="COLOR: #fef1a9"&gt;threads&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Add&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #fef1a9"&gt;thread&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   21&lt;/SPAN&gt;             }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   22&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #8080c0"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;thread&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;in&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;threads&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   23&lt;/SPAN&gt;             {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   24&lt;/SPAN&gt;                 &lt;SPAN style="COLOR: #fef1a9"&gt;thread&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Join&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   25&lt;/SPAN&gt;             }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   26&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Console&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;ReadLine&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   27&lt;/SPAN&gt;         }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   28&lt;/SPAN&gt;     }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   29&lt;/SPAN&gt; }&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Come si vede dal loop for nella riga 15 devono essere eseguite 100 writer.DoSomeWork al max a gruppi di 5 contemporaneamente; a garantirci questo ci pensa la classe &lt;A href="http://msdn2.microsoft.com/en-us/library/system.threading.semaphore.aspx"&gt;Semaphore&lt;/A&gt; creata con i valori:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;initialCount:&lt;/STRONG&gt; The initial number of requests for the semaphore that can be granted concurrently. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;maximumCount:&lt;/STRONG&gt; The maximum number of requests for the semaphore that can be granted concurrently.&lt;/P&gt;
&lt;P&gt;inizializzati a 5. &lt;/P&gt;
&lt;P&gt;Vediamo la classe ConsoleWriter:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: #181818; COLOR: #e0e0e0; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    1&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;using&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;System&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    2&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;using&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;System&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Threading&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    3&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    4&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;namespace&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;MultithreadingExperiments&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    5&lt;/SPAN&gt; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    6&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #8080c0"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;ConsoleWriter&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    7&lt;/SPAN&gt;     {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    8&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #c7c7f1"&gt;Semaphore&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;m_pool&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;    9&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;m_id&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   10&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;m_sleepingTime&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   11&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   12&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;ConsoleWriter&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #8080c0"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;id&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #8080c0"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;sleepingTime&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #c7c7f1"&gt;Semaphore&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;pool&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   13&lt;/SPAN&gt;         {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   14&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #fef1a9"&gt;m_id&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #fef1a9"&gt;id&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   15&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #fef1a9"&gt;m_sleepingTime&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #fef1a9"&gt;sleepingTime&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   16&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #fef1a9"&gt;m_pool&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #fef1a9"&gt;pool&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   17&lt;/SPAN&gt;         }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   18&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   19&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #8080c0"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8080c0"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: #fef1a9"&gt;DoSomeWork&lt;/SPAN&gt;()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   20&lt;/SPAN&gt;         {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   21&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #fef1a9"&gt;m_pool&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;WaitOne&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   22&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Console&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;WriteLine&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #60ff60"&gt;"Thread {0} started"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #fef1a9"&gt;m_id&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   23&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Thread&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Sleep&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #fef1a9"&gt;m_sleepingTime&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   24&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #c7c7f1"&gt;Console&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;WriteLine&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #60ff60"&gt;"Thread {0} finished his work"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #fef1a9"&gt;m_id&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   25&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #fef1a9"&gt;m_pool&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #fef1a9"&gt;Release&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   26&lt;/SPAN&gt;         }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   27&lt;/SPAN&gt;     }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;   28&lt;/SPAN&gt; }&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Nel metodo DoSomeWork viene chiamato il metodo WaitOne che ritorna quando c'&amp;#232; almeno un risorsa disponibile (noi ne abbiamo specificate al max 5). Quando il metodo termina viene richiamato il metodo Release il quale permette ad un altro thread in attesa di partire.&lt;/P&gt;
&lt;P&gt;Nel codice di produzione sarebbe una buona norma inserire il codice del metodo DoSomeWork in un blocco try/finally in modo che sia garantita la chiamata al metodo Release.&lt;/P&gt;
&lt;P&gt;Le ultime righe del metodo main attendono che tutti i thread siano terminati.&lt;/P&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/82724.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/06/19/82724.aspx</guid>
            <pubDate>Tue, 19 Jun 2007 10:08:00 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/82724.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/06/19/82724.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/82724.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/82724.aspx</trackback:ping>
        </item>
        <item>
            <title>Alcuni link per approfondire il pattern Model View Presenter</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/02/03/69686.aspx</link>
            <description>&lt;P&gt;Nel progetto che sto sviluppando &amp;#232; presente una GUI molto complessa, per cui ho provato a cercare del materiale che mi aiutasse a progettare tramite TDD l'architettura. &lt;/P&gt;
&lt;P&gt;Ho trovato un articolo in formato pdf molto interessante: &lt;A href="http://www.atomicobject.com/files/PresenterFirstAgile2006.pdf"&gt;Presenter First: Organizing Complex GUI Applications for Test-Driven Development&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Segnalo anche questo post per testare eventi su interfacce tramite Rhino Mocks: &lt;A href="http://haacked.com/archive/2006/06/23/UsingRhinoMocksToUnitTestEventsOnInterfaces.aspx"&gt;Using Rhino Mocks To Unit Test Events on Interfaces&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Ed infine gli articoli di Martin Fowler: &lt;A href="http://www.martinfowler.com/eaaDev/SupervisingPresenter.html"&gt;Supervising Controller&lt;/A&gt; e &lt;A href="http://www.martinfowler.com/eaaDev/PassiveScreen.html"&gt;Passive View&lt;/A&gt; &lt;/P&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/69686.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/02/03/69686.aspx</guid>
            <pubDate>Sat, 03 Feb 2007 13:57:00 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/69686.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/02/03/69686.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/69686.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/69686.aspx</trackback:ping>
        </item>
        <item>
            <title>Usare le Regular Expression in Visual Studio per il Find e Replace</title>
            <link>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/01/08/65475.aspx</link>
            <description>&lt;P&gt;Oggi ho avuto la necessit&amp;#224; di rimpiazzare il seguente testo che corrisponde alla visualizzazione di un byte array dalla Watch Window del debugger di Visual Studio: &lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [0]&amp;nbsp;&amp;nbsp;&amp;nbsp; 210&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [1]&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [2]&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [3]&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [4]&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [5]&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [6]&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; byte&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Nel seguente modo: &lt;/P&gt;
&lt;P&gt;210, 7, 0, 0, 6, 0, 0, ... &lt;/P&gt;
&lt;P&gt;In modo da poter creare agevolmente tramite codice c# un array di byte. Chiaramente il buffer &amp;#232; molto pi&amp;#249; lungo altrimenti avrei impiegato meno tempo a modificare il testo a mano. Armato di pazienza mi sono ripassato la sintassi delle Regular Expression in Visual Studio ed ho prodotto la seguente espressione per il Find: &lt;/P&gt;&lt;PRE&gt;^:b*\[:z\]:b*{:z}:b*byte\n&lt;/PRE&gt;
&lt;P&gt;Analizziamo le singole parti della regular expression: &lt;/P&gt;
&lt;TABLE border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;^&lt;/TD&gt;
&lt;TD&gt;L'inizio di una riga di testo&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;:b*&lt;/TD&gt;
&lt;TD&gt;Zero o pi&amp;#249; caratteri di spaziatura (nel formato standard delle regular expressione sarebbe \s*)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;\[&lt;/TD&gt;
&lt;TD&gt;Il carattere [ (essendo un carattere speciale deve essere preceduto da \)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;:z&lt;/TD&gt;
&lt;TD&gt;Un numero intero&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;\]&lt;/TD&gt;
&lt;TD&gt;Il carattere ]&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;:b*&lt;/TD&gt;
&lt;TD&gt;Zero o pi&amp;#249; spazi&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;{:z}&lt;/TD&gt;
&lt;TD&gt;Le parentesi graffe indicano una tag expression che potr&amp;#224; essere utilizzata nel replace (vedi dopo)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;:b*&lt;/TD&gt;
&lt;TD&gt;Zero o pi&amp;#249; spazi&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;byte&lt;/TD&gt;
&lt;TD&gt;La parola byte&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;\n&lt;/TD&gt;
&lt;TD&gt;Un line break&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Ora per il replace ho scritto:&lt;/P&gt;
&lt;P&gt;\1, &lt;/P&gt;
&lt;P&gt;Significa di rimpiazzare ci&amp;#242; che viene trovato dall'espressione regolare precedente con la tag expression 1 (quella tra parentesi graffe e cio&amp;#232; il numero intero) seguito da una virgola e da uno spazio (non si vede nel testo). Dopo aver premuto il pulsante Replace All Il risultato &amp;#232; il seguente: &lt;/P&gt;
&lt;P&gt;210, 7, 0, 0, 6, 0, 0, ...&lt;/P&gt;
&lt;P&gt;Semplice no?&lt;/P&gt;&lt;img src="http://blogs.ugidotnet.org/AntonioGanci/aggbug/65475.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Antonio Ganci</dc:creator>
            <guid>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/01/08/65475.aspx</guid>
            <pubDate>Mon, 08 Jan 2007 11:26:00 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/AntonioGanci/comments/65475.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/AntonioGanci/archive/2007/01/08/65475.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/AntonioGanci/comments/commentRss/65475.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/AntonioGanci/services/trackbacks/65475.aspx</trackback:ping>
        </item>
    </channel>
</rss>