<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Chrissie1's Blog</title>
    <link>http://blog.baesonline.com/</link>
    <description>My fight with .Net</description>
    <language>en-us</language>
    <copyright>Christiaan Baes</copyright>
    <lastBuildDate>Sun, 15 Jun 2008 12:48:39 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.7174.0</generator>
    <managingEditor>christiaan@baesonline.com</managingEditor>
    <webMaster>christiaan@baesonline.com</webMaster>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=183bccfb-a1c2-4557-8b7b-f52c78945935</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,183bccfb-a1c2-4557-8b7b-f52c78945935.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,183bccfb-a1c2-4557-8b7b-f52c78945935.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=183bccfb-a1c2-4557-8b7b-f52c78945935</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I moved my blog to <a href="http://blogs.lessthandot.com">http://blogs.lessthandot.com</a><br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=183bccfb-a1c2-4557-8b7b-f52c78945935" /></body>
      <title>Moved blog</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,183bccfb-a1c2-4557-8b7b-f52c78945935.aspx</guid>
      <link>http://blog.baesonline.com/2008/06/15/MovedBlog.aspx</link>
      <pubDate>Sun, 15 Jun 2008 12:48:39 GMT</pubDate>
      <description>I moved my blog to &lt;a href="http://blogs.lessthandot.com"&gt;http://blogs.lessthandot.com&lt;/a&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=183bccfb-a1c2-4557-8b7b-f52c78945935" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,183bccfb-a1c2-4557-8b7b-f52c78945935.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=69b4f433-cd9d-42b3-b910-e2d6d4dc9c10</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,69b4f433-cd9d-42b3-b910-e2d6d4dc9c10.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,69b4f433-cd9d-42b3-b910-e2d6d4dc9c10.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=69b4f433-cd9d-42b3-b910-e2d6d4dc9c10</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Yes, <a href="http://www.lessthandot.com">LessThanDot</a> is
finaly live and kicking. 
<br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=69b4f433-cd9d-42b3-b910-e2d6d4dc9c10" /></body>
      <title>Lessthandot has launched</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,69b4f433-cd9d-42b3-b910-e2d6d4dc9c10.aspx</guid>
      <link>http://blog.baesonline.com/2008/06/01/LessthandotHasLaunched.aspx</link>
      <pubDate>Sun, 01 Jun 2008 08:39:16 GMT</pubDate>
      <description>Yes, &lt;a href="http://www.lessthandot.com"&gt;LessThanDot&lt;/a&gt; is finaly live and kicking. 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=69b4f433-cd9d-42b3-b910-e2d6d4dc9c10" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,69b4f433-cd9d-42b3-b910-e2d6d4dc9c10.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=972da3e1-dd17-4d4c-9e99-65b9c954e899</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,972da3e1-dd17-4d4c-9e99-65b9c954e899.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,972da3e1-dd17-4d4c-9e99-65b9c954e899.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=972da3e1-dd17-4d4c-9e99-65b9c954e899</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Me and some other people have been working
on a brilliant new site it is called LessThanDot and it contains a wiki, blog and
forums all accessible via a single login. Please visit us from the first of june onwards
at <a href="http://www.lessthandot.com">http://www.lessthandot.com</a><br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=972da3e1-dd17-4d4c-9e99-65b9c954e899" /></body>
      <title>LessThanDot launches june 1st</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,972da3e1-dd17-4d4c-9e99-65b9c954e899.aspx</guid>
      <link>http://blog.baesonline.com/2008/05/19/LessThanDotLaunchesJune1st.aspx</link>
      <pubDate>Mon, 19 May 2008 19:01:52 GMT</pubDate>
      <description>Me and some other people have been working on a brilliant new site it is called LessThanDot and it contains a wiki, blog and forums all accessible via a single login. Please visit us from the first of june onwards at &lt;a href="http://www.lessthandot.com"&gt;http://www.lessthandot.com&lt;/a&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=972da3e1-dd17-4d4c-9e99-65b9c954e899" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,972da3e1-dd17-4d4c-9e99-65b9c954e899.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=f7ed4a41-4310-471e-9cb7-7f118c649edb</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,f7ed4a41-4310-471e-9cb7-7f118c649edb.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,f7ed4a41-4310-471e-9cb7-7f118c649edb.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f7ed4a41-4310-471e-9cb7-7f118c649edb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">On windows files can be locked by different
programs. <a href="http://ccollomb.free.fr/unlocker/">This little gem</a> unlocks
your file so that you can delete it. 
<!-- m --><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=f7ed4a41-4310-471e-9cb7-7f118c649edb" /></body>
      <title>File Unlocker for Windows</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,f7ed4a41-4310-471e-9cb7-7f118c649edb.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/28/FileUnlockerForWindows.aspx</link>
      <pubDate>Mon, 28 Apr 2008 08:13:19 GMT</pubDate>
      <description>On windows files can be locked by different programs. &lt;a href="http://ccollomb.free.fr/unlocker/"&gt;This
little gem&lt;/a&gt; unlocks your file so that you can delete it. 
&lt;!-- m --&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=f7ed4a41-4310-471e-9cb7-7f118c649edb" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,f7ed4a41-4310-471e-9cb7-7f118c649edb.aspx</comments>
      <category>Weblinks</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I found out yesterday that my sql server
backups were corrupt and so I couldn't restore them (happy me). So I went out on Google
and combined a few things to make this<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">declare</span> @verifystatement <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">nvarchar</span>(250) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">declare</span> @backupdevice <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">nvarchar</span>(250) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">declare</span> @err <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">set</span> @backupdevice
=     (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SELECT</span>     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">TOP</span> 1
[physical_device_name]             <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">FROM</span>     msdb.dbo.backupmediafamily
backupmediafamily                 <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">JOIN</span> msdb.dbo.backupset
backupset <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ON</span> backupmediafamily.media_set_id
= backupset.media_set_id                 <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> backupset.backup_start_date
= (    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SELECT</span><span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">max</span>(backup_start_date)
                                    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">FROM</span> msdb.dbo.backupset
child                                     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">WHERE</span> child.database_name
= backupset.database_name <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> child.type
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'D'</span>)
                <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> database_name
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'TexDatabase'</span>                 <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> backupset.type
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'D'</span>) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">set</span> @verifystatement
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'restore
verifyonly from disk = '''</span> + @backupdevice + <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">''''</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">exec</span><span style="color: Brown; background-color: transparent; font-family: Courier New; font-size: 11px;">sp_executesql</span> @verifystatement <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SELECT</span> @err
= <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">@@error</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> @err
&lt;&gt; 0         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">begin</span>             <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">insert</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">into</span> utils.dbo.tbl_backupverify(BackupDevice,BackupStatus,BackupError,
VerifyStatement)             <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">values</span> (@backupdevice, <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'Failed'</span>,
@err, @verifystatement)         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">end</span>         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">else</span>         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">begin</span>             <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">insert</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">into</span> utils.dbo.tbl_backupverify(BackupDevice,BackupStatus)
            <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">values</span> (@backupdevice, <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'Succes'</span>)
        <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">end<br /></span><br /></span></pre>
Just put it in a Store procedure and run it as a job.<br /><br /><br />
This is the tbl_BackupVerify create table statement.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">exists</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">select</span> * <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">from</span> dbo.<span style="color: LawnGreen; background-color: transparent; font-family: Courier New; font-size: 11px;">sysobjects</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">where</span> id
= <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">object_id</span>(N<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'[dbo].[tbl_BackupVerify]'</span>) <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span><span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">OBJECTPROPERTY</span>(id,
N<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'IsUserTable'</span>)
= 1) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">drop</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">table</span> [dbo].[tbl_BackupVerify]
GO <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">CREATE</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">TABLE</span> [dbo].[tbl_BackupVerify]
(     [Id] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span>] <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">IDENTITY</span> (1,
1) <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NOT</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ,
    [BackupDevice] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">nvarchar</span>]
(250) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">COLLATE</span> Latin1_General_CI_AS <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NOT</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ,
    [BackupStatus] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">nvarchar</span>]
(50) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">COLLATE</span> Latin1_General_CI_AS <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NOT</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ,
    [VerifyDate] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">datetime</span>] <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NOT</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ,
    [BackupError] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bigint</span>] <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ,
    [VerifyStatement] [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">nvarchar</span>]
(500) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">COLLATE</span> Latin1_General_CI_AS <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">NULL</span> ) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ON</span> [<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">PRIMARY</span>]
GO </span></pre>
You could add this as a scheduled job in sql-server.<br /><br />
Just don't forget to check the log table or make it send an email.<br /><br /><br /><br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd" /></body>
      <title>Do automated restore tests on your SQL-Backups.</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/17/DoAutomatedRestoreTestsOnYourSQLBackups.aspx</link>
      <pubDate>Thu, 17 Apr 2008 12:00:00 GMT</pubDate>
      <description>I found out yesterday that my sql server backups were corrupt and so I couldn't restore them (happy me). So I went out on Google and combined a few things to make this&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;declare&lt;/span&gt; @verifystatement &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;nvarchar&lt;/span&gt;(250) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;declare&lt;/span&gt; @backupdevice &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;nvarchar&lt;/span&gt;(250) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;declare&lt;/span&gt; @err &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;set&lt;/span&gt; @backupdevice
= &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SELECT&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;TOP&lt;/span&gt; 1
[physical_device_name] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;FROM&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;msdb.dbo.backupmediafamily
backupmediafamily &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;JOIN&lt;/span&gt; msdb.dbo.backupset
backupset &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ON&lt;/span&gt; backupmediafamily.media_set_id
= backupset.media_set_id &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; backupset.backup_start_date
= (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SELECT&lt;/span&gt; &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;max&lt;/span&gt;(backup_start_date)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;FROM&lt;/span&gt; msdb.dbo.backupset
child &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;WHERE&lt;/span&gt; child.database_name
= backupset.database_name &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; child.type
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'D'&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; database_name
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'TexDatabase'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; backupset.type
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'D'&lt;/span&gt;) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;set&lt;/span&gt; @verifystatement
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'restore
verifyonly from disk = '''&lt;/span&gt; + @backupdevice + &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;''''&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;exec&lt;/span&gt; &lt;span style="color: Brown; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;sp_executesql&lt;/span&gt; @verifystatement &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SELECT&lt;/span&gt; @err
= &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;@@error&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; @err
&amp;lt;&amp;gt; 0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;begin&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;insert&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;into&lt;/span&gt; utils.dbo.tbl_backupverify(BackupDevice,BackupStatus,BackupError,
VerifyStatement) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;values&lt;/span&gt; (@backupdevice, &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'Failed'&lt;/span&gt;,
@err, @verifystatement) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;end&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;begin&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;insert&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;into&lt;/span&gt; utils.dbo.tbl_backupverify(BackupDevice,BackupStatus)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;values&lt;/span&gt; (@backupdevice, &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'Succes'&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;end&lt;br&gt;
&lt;/span&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
Just put it in a Store procedure and run it as a job.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
This is the tbl_BackupVerify create table statement.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;exists&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;select&lt;/span&gt; * &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;from&lt;/span&gt; dbo.&lt;span style="color: LawnGreen; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;sysobjects&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;where&lt;/span&gt; id
= &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;object_id&lt;/span&gt;(N&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'[dbo].[tbl_BackupVerify]'&lt;/span&gt;) &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;OBJECTPROPERTY&lt;/span&gt;(id,
N&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'IsUserTable'&lt;/span&gt;)
= 1) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;drop&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;table&lt;/span&gt; [dbo].[tbl_BackupVerify]
GO &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CREATE&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;TABLE&lt;/span&gt; [dbo].[tbl_BackupVerify]
( &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[Id] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt;] &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;IDENTITY&lt;/span&gt; (1,
1) &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NOT&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[BackupDevice] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;nvarchar&lt;/span&gt;]
(250) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;COLLATE&lt;/span&gt; Latin1_General_CI_AS &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NOT&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[BackupStatus] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;nvarchar&lt;/span&gt;]
(50) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;COLLATE&lt;/span&gt; Latin1_General_CI_AS &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NOT&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[VerifyDate] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;datetime&lt;/span&gt;] &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NOT&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[BackupError] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bigint&lt;/span&gt;] &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[VerifyStatement] [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;nvarchar&lt;/span&gt;]
(500) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;COLLATE&lt;/span&gt; Latin1_General_CI_AS &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NULL&lt;/span&gt; ) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ON&lt;/span&gt; [&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;PRIMARY&lt;/span&gt;]
GO &lt;/span&gt;&lt;/pre&gt;
You could add this as a scheduled job in sql-server.&lt;br&gt;
&lt;br&gt;
Just don't forget to check the log table or make it send an email.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,2f28b3a7-104a-4c0a-8a0b-8386ca7b6bcd.aspx</comments>
      <category>SQl Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=5be94464-6785-4dc2-8c09-4e649f297a84</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,5be94464-6785-4dc2-8c09-4e649f297a84.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,5be94464-6785-4dc2-8c09-4e649f297a84.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5be94464-6785-4dc2-8c09-4e649f297a84</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>
          <span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">
            <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SELECT</span> * <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">FROM</span> msdb.dbo.backupmediafamily
backupmediafamily <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">JOIN</span> msdb.dbo.backupset
backupset <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ON</span> backupmediafamily.media_set_id
= backupset.media_set_id <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> backupset.backup_start_date
= (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SELECT</span><span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">max</span>(backup_start_date) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">FROM</span> msdb.dbo.backupset
child <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">WHERE</span> child.database_name
= backupset.database_name <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> child.type
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'D'</span>) <span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> database_name
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'ReplaceWithDatabaseNameHere'</span><span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;">and</span> backupset.type
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'D'</span></span>
        </pre>
        <br />
        <br />
This is Based on something I found <a href="http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1307822,00.html">here</a>.
Thank you mrDenny.<br /><br />
And this works in SQL Server 2000. 
<br /><br /><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=5be94464-6785-4dc2-8c09-4e649f297a84" /></body>
      <title>Find the last Backup taken in SQL Server</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,5be94464-6785-4dc2-8c09-4e649f297a84.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/17/FindTheLastBackupTakenInSQLServer.aspx</link>
      <pubDate>Thu, 17 Apr 2008 08:38:06 GMT</pubDate>
      <description>&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SELECT&lt;/span&gt; * &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;FROM&lt;/span&gt; msdb.dbo.backupmediafamily
backupmediafamily &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;JOIN&lt;/span&gt; msdb.dbo.backupset
backupset &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ON&lt;/span&gt; backupmediafamily.media_set_id
= backupset.media_set_id &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; backupset.backup_start_date
= (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SELECT&lt;/span&gt; &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;max&lt;/span&gt;(backup_start_date) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;FROM&lt;/span&gt; msdb.dbo.backupset
child &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;WHERE&lt;/span&gt; child.database_name
= backupset.database_name &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; child.type
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'D'&lt;/span&gt;) &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; database_name
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'ReplaceWithDatabaseNameHere'&lt;/span&gt; &lt;span style="color: Silver; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;and&lt;/span&gt; backupset.type
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'D'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
This is Based on something I found &lt;a href="http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1307822,00.html"&gt;here&lt;/a&gt;.
Thank you mrDenny.&lt;br&gt;
&lt;br&gt;
And this works in SQL Server 2000. 
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=5be94464-6785-4dc2-8c09-4e649f297a84" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,5be94464-6785-4dc2-8c09-4e649f297a84.aspx</comments>
      <category>SQl Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=ecbe8235-7800-4b7c-bb82-46fef71b62e7</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,ecbe8235-7800-4b7c-bb82-46fef71b62e7.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,ecbe8235-7800-4b7c-bb82-46fef71b62e7.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ecbe8235-7800-4b7c-bb82-46fef71b62e7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">So I also made the a similar template with
structuremap support included.<br /><br />
Wich looks something like this<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> Nunit.FrameWork <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> StructureMap <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> $<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">NAMESPACE</span>$
    <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
A TestClass</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>     &lt;TestFixture()&gt;
_     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> $CLASSNAME$
     #Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
Setup and TearDown "</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
Sets up the Tests</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>         &lt;Setup()&gt;
_         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> Setup()
    StructureMapConfiguration.UseDefaultStructureMapConfigFile <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">False</span>         StructureMapConfiguration.ScanAssemblies.IncludeTheCallingAssembly()
        <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
Tears down the test. Is executed after the Test is Completed</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>         &lt;TearDown()&gt;
_         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> TearDown()
            ObjectFactory.ResetDefaults()        
    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> #<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Region    
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
Tests "</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
A Test</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>      &lt;Test()&gt; _     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> $Test_Name$()
    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> #<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Region
    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre>
And of course I also made an XmlFile so you can easily import it.<br /><br /><a href="http://blog.baesonline.com/content/binary/NunitTestFixtureWithStructureMapSupport.xml">NunitTestFixtureWithStructureMapSupport.xml
(2,44 KB)</a><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=ecbe8235-7800-4b7c-bb82-46fef71b62e7" /></body>
      <title>Resharper File template for Nunit testing with Structuremap support for VB.Net</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,ecbe8235-7800-4b7c-bb82-46fef71b62e7.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/15/ResharperFileTemplateForNunitTestingWithStructuremapSupportForVBNet.aspx</link>
      <pubDate>Tue, 15 Apr 2008 12:52:23 GMT</pubDate>
      <description>So I also made the a similar template with structuremap support included.&lt;br&gt;
&lt;br&gt;
Wich looks something like this&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; Nunit.FrameWork &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; StructureMap &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; $&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NAMESPACE&lt;/span&gt;$
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
A TestClass&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TestFixture()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; $CLASSNAME$
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
Setup and TearDown "&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Sets up the Tests&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Setup()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; Setup()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructureMapConfiguration.UseDefaultStructureMapConfigFile &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;False&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructureMapConfiguration.ScanAssemblies.IncludeTheCallingAssembly()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Tears down the test. Is executed after the Test is Completed&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TearDown()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; TearDown()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectFactory.ResetDefaults()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; #&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
Tests "&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
A Test&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Test()&amp;gt; _ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; $Test_Name$()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; #&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
And of course I also made an XmlFile so you can easily import it.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://blog.baesonline.com/content/binary/NunitTestFixtureWithStructureMapSupport.xml"&gt;NunitTestFixtureWithStructureMapSupport.xml
(2,44 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=ecbe8235-7800-4b7c-bb82-46fef71b62e7" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,ecbe8235-7800-4b7c-bb82-46fef71b62e7.aspx</comments>
      <category>.Net</category>
      <category>Resharper</category>
      <category>Nunit</category>
      <category>StructureMap</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=dcc73ccb-29f7-4648-8a10-81a6fc276226</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,dcc73ccb-29f7-4648-8a10-81a6fc276226.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,dcc73ccb-29f7-4648-8a10-81a6fc276226.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dcc73ccb-29f7-4648-8a10-81a6fc276226</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I made a file template for resharper to
make it eassier to create a TestClass<br /><br />
it looks like this.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> Nunit.FrameWork <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> $<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">NAMESPACE</span>$
    <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
A TestClass</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>     &lt;TestFixture()&gt;
_     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> $CLASSNAME$
     #Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
Setup and TearDown "</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
Sets up the Tests</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>         &lt;Setup()&gt;
_         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> Setup()
        <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
Tears down the test. Is executed after the Test is Completed</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>         &lt;TearDown()&gt;
_         <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> TearDown()
                 <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> #<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Region    
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
Tests "</span>     <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
A Test</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>         <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>      &lt;Test()&gt; _     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> $Test_Name$()
    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> #<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Region
    <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre>
I also made an xmlFile so you can easily import it into Resharper.<br /><p></p><a href="http://blog.baesonline.com/content/binary/NunitTestFixture.xml">NunitTestFixture.xml
(2,15 KB)</a><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=dcc73ccb-29f7-4648-8a10-81a6fc276226" /></body>
      <title>Resharper Template Nunit TestFixture for VB.Net</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,dcc73ccb-29f7-4648-8a10-81a6fc276226.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/15/ResharperTemplateNunitTestFixtureForVBNet.aspx</link>
      <pubDate>Tue, 15 Apr 2008 12:49:23 GMT</pubDate>
      <description>I made a file template for resharper to make it eassier to create a TestClass&lt;br&gt;
&lt;br&gt;
it looks like this.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; Nunit.FrameWork &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; $&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;NAMESPACE&lt;/span&gt;$
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
A TestClass&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TestFixture()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; $CLASSNAME$
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
Setup and TearDown "&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Sets up the Tests&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Setup()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; Setup()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Tears down the test. Is executed after the Test is Completed&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TearDown()&amp;gt;
_ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; TearDown()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; #&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
Tests "&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
A Test&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Test()&amp;gt; _ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; $Test_Name$()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; #&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
I also made an xmlFile so you can easily import it into Resharper.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;a href="http://blog.baesonline.com/content/binary/NunitTestFixture.xml"&gt;NunitTestFixture.xml
(2,15 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=dcc73ccb-29f7-4648-8a10-81a6fc276226" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,dcc73ccb-29f7-4648-8a10-81a6fc276226.aspx</comments>
      <category>.Net</category>
      <category>Nunit</category>
      <category>Resharper</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=1f409865-0cec-48d0-860d-d7e71edacf57</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,1f409865-0cec-48d0-860d-d7e71edacf57.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,1f409865-0cec-48d0-860d-d7e71edacf57.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1f409865-0cec-48d0-860d-d7e71edacf57</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Sometimes we just add references and never
use them or use them and then remove it all again. And sometimes it is hard to say
which reference we don't use anymore. Well MS has provided us with a button that looks
up the unused references and if it finds ione you can remove the unused references.<br /><br />
So how do we do it.<br /><br />
First we right clikc on our project and select properties.<br /><br /><p></p><img src="http://blog.baesonline.com/content/binary/Nieuw-3.jpg" border="0" /><br /><br />
Then we go to the tab references and click on the button Unused References.<br /><br /><br /><img src="http://blog.baesonline.com/content/binary/Nieuw-5.jpg" border="0" /><br /><br />
This will open a dialog with either a list of unused references (see below) or nothing
in it.<br /><br /><br /><img src="http://blog.baesonline.com/content/binary/Nieuw-6.jpg" border="0" /><br /><br />
And now you can just click remove and the references will be gone.<br /><br /><br /><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=1f409865-0cec-48d0-860d-d7e71edacf57" /></body>
      <title>Unused references</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,1f409865-0cec-48d0-860d-d7e71edacf57.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/14/UnusedReferences.aspx</link>
      <pubDate>Mon, 14 Apr 2008 11:48:41 GMT</pubDate>
      <description>Sometimes we just add references and never use them or use them and then remove it all again. And sometimes it is hard to say which reference we don't use anymore. Well MS has provided us with a button that looks up the unused references and if it finds ione you can remove the unused references.&lt;br&gt;
&lt;br&gt;
So how do we do it.&lt;br&gt;
&lt;br&gt;
First we right clikc on our project and select properties.&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-3.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
Then we go to the tab references and click on the button Unused References.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-5.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
This will open a dialog with either a list of unused references (see below) or nothing
in it.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-6.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
And now you can just click remove and the references will be gone.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=1f409865-0cec-48d0-860d-d7e71edacf57" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,1f409865-0cec-48d0-860d-d7e71edacf57.aspx</comments>
      <category>.Net</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=59d2af56-819a-45fd-bf38-33fd249ded6c</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,59d2af56-819a-45fd-bf38-33fd249ded6c.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,59d2af56-819a-45fd-bf38-33fd249ded6c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=59d2af56-819a-45fd-bf38-33fd249ded6c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Changing the targeted framework of a project
in VB.NET 2008 with the Visual Studio IDE goes like this.<br /><br />
First we click right on the project name and choose properties.<br /><br /><img src="http://blog.baesonline.com/content/binary/Nieuw-3.jpg" border="0" /><br /><br />
Then we select the compile tab and click on the "Advanced Compile Options..." Button.<br /><br /><img src="http://blog.baesonline.com/content/binary/Nieuw-21.jpg" border="0" /><br /><br />
And last but not least we select the desired framework from the list "Target framework
(all configurations)".<br /><br /><br /><img src="http://blog.baesonline.com/content/binary/Nieuw-4.jpg" border="0" /><br /><br /><br /><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=59d2af56-819a-45fd-bf38-33fd249ded6c" /></body>
      <title>Changing the targeted framework in VB.NET 2008</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,59d2af56-819a-45fd-bf38-33fd249ded6c.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/14/ChangingTheTargetedFrameworkInVBNET2008.aspx</link>
      <pubDate>Mon, 14 Apr 2008 11:32:58 GMT</pubDate>
      <description>Changing the targeted framework of a project in VB.NET 2008 with the Visual Studio IDE goes like this.&lt;br&gt;
&lt;br&gt;
First we click right on the project name and choose properties.&lt;br&gt;
&lt;br&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-3.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
Then we select the compile tab and click on the "Advanced Compile Options..." Button.&lt;br&gt;
&lt;br&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-21.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
And last but not least we select the desired framework from the list "Target framework
(all configurations)".&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://blog.baesonline.com/content/binary/Nieuw-4.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=59d2af56-819a-45fd-bf38-33fd249ded6c" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,59d2af56-819a-45fd-bf38-33fd249ded6c.aspx</comments>
      <category>.Net</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Now that I have StructureMap and RhinoMocks
in my stack I sometimes need to look for VB.Net examples of how to do things, because
sometimes translating them from C# is not all that easy.<br /><br /><a href="http://anoriginalidea.wordpress.com/2007/06/12/raising-events-from-a-mock-using-rhino-mocks-in-vbnet/">This
article</a> has helped me mocking events.<p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839" /></body>
      <title>Mocking events</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/13/MockingEvents.aspx</link>
      <pubDate>Sun, 13 Apr 2008 21:05:57 GMT</pubDate>
      <description>Now that I have StructureMap and RhinoMocks in my stack I sometimes
need to look for VB.Net examples of how to do things, because sometimes
translating them from C# is not all that easy.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://anoriginalidea.wordpress.com/2007/06/12/raising-events-from-a-mock-using-rhino-mocks-in-vbnet/"&gt;This
article&lt;/a&gt; has helped me mocking events.&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,2d003dc8-e3f4-4658-bfcd-d7b7b2c7a839.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=23068292-c9d5-40da-a589-f36d6c8b4805</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,23068292-c9d5-40da-a589-f36d6c8b4805.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,23068292-c9d5-40da-a589-f36d6c8b4805.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=23068292-c9d5-40da-a589-f36d6c8b4805</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">After reading <a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/04/12/designing-with-lambdas-part-i.aspx">A
post by Sergio Pereira</a> I thought about translating his code to VB.Net because
as usual all the cool things are written in C#.<br />
So this piece 
<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">using</span>(StreamReader
rd <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> File.OpenText(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Data.txt"</span>)) 
<br />
{ 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine(); 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">while</span>(line
!<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">null</span>) 
<br />
{ 
<br />
DoSomething(line); 
<br /><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">//
do more stuff with the line text </span><br /><br /><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">//move
on </span><br />
line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine(); 
<br />
} 
<br />
} </span></pre>
Becomes<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> rd <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> System.IO.StreamReader <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> System.IO.File.OpenText(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Data.txt"</span>)<br />
Using (rd)<br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> line <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine()<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">While</span> (line
IsNot <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Nothing</span>)<br /><br />
dosomething(line)<br /><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'
do more stuff with the line text </span><br /><br /><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'move
on </span><br />
line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine()<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">While</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Using<br /><br /></span></pre>
and the next bit<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">class</span> FileUtil 
<br />
{ 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> EachLine(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> fileName,
Action&lt;<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span>&gt;
process) 
<br />
{ 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">using</span>(StreamReader
rd <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> File.OpenText(fileName)) 
<br />
{ 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine(); 
<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">while</span>(line
!<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">null</span>) 
<br />
{ 
<br />
process(line); 
<br />
line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine(); 
<br />
} 
<br />
} 
<br />
} 
<br />
} </span></pre><br />
will translate in 
<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> FileUtil<br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Shared</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> EachLine(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> fileName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> process <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Action(Of <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>))<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> rd <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> System.IO.StreamReader <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> System.IO.File.OpenText(fileName)<br />
Using (rd)<br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> Line <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine()<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">While</span> (Line
IsNot <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Nothing</span>)<br /><br />
process(Line)<br />
Line <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> rd.ReadLine()<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">While</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span> Using<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span></span></pre><br />
And we call that last piece of code like this<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">FileUtil.EachLine(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Data.txt"</span>, <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">AddressOf</span> dosomething)</span></pre><br />
The doSomething method would look something like this<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> dosomething(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> line <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)
MessageBox.Show(line) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre><br /><br />
And that's it.<br /><br /><br /><br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=23068292-c9d5-40da-a589-f36d6c8b4805" /></body>
      <title>Lambda expressions</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,23068292-c9d5-40da-a589-f36d6c8b4805.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/13/LambdaExpressions.aspx</link>
      <pubDate>Sun, 13 Apr 2008 19:59:08 GMT</pubDate>
      <description>After reading &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/04/12/designing-with-lambdas-part-i.aspx"&gt;A
post by Sergio Pereira&lt;/a&gt; I thought about translating his code to VB.Net because
as usual all the cool things are written in C#.&lt;br&gt;
So this piece 
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;using&lt;/span&gt;(StreamReader
rd &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; File.OpenText(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Data.txt"&lt;/span&gt;)) 
&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine(); 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;while&lt;/span&gt;(line
!&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;) 
&lt;br&gt;
{ 
&lt;br&gt;
DoSomething(line); 
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//
do more stuff with the line text &lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//move
on &lt;/span&gt;
&lt;br&gt;
line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine(); 
&lt;br&gt;
} 
&lt;br&gt;
} &lt;/span&gt;&lt;/pre&gt;
Becomes&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; rd &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.IO.StreamReader &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; System.IO.File.OpenText(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Data.txt"&lt;/span&gt;)&lt;br&gt;
Using (rd)&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; line &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine()&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;While&lt;/span&gt; (line
IsNot &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Nothing&lt;/span&gt;)&lt;br&gt;
&lt;br&gt;
dosomething(line)&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'
do more stuff with the line text &lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'move
on &lt;/span&gt;
&lt;br&gt;
line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine()&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;While&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Using&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
and the next bit&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; FileUtil 
&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; EachLine(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; fileName,
Action&amp;lt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;&amp;gt;
process) 
&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;using&lt;/span&gt;(StreamReader
rd &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; File.OpenText(fileName)) 
&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine(); 
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;while&lt;/span&gt;(line
!&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;) 
&lt;br&gt;
{ 
&lt;br&gt;
process(line); 
&lt;br&gt;
line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine(); 
&lt;br&gt;
} 
&lt;br&gt;
} 
&lt;br&gt;
} 
&lt;br&gt;
} &lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
will translate in 
&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; FileUtil&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; EachLine(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; fileName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; process &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Action(Of &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;))&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; rd &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.IO.StreamReader &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; System.IO.File.OpenText(fileName)&lt;br&gt;
Using (rd)&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; Line &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine()&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;While&lt;/span&gt; (Line
IsNot &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Nothing&lt;/span&gt;)&lt;br&gt;
&lt;br&gt;
process(Line)&lt;br&gt;
Line &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; rd.ReadLine()&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;While&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Using&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
And we call that last piece of code like this&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;FileUtil.EachLine(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Data.txt"&lt;/span&gt;, &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;AddressOf&lt;/span&gt; dosomething)&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
The doSomething method would look something like this&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; dosomething(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; line &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)
MessageBox.Show(line) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
And that's it.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=23068292-c9d5-40da-a589-f36d6c8b4805" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,23068292-c9d5-40da-a589-f36d6c8b4805.aspx</comments>
      <category>.Net</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=9a33424e-e956-47b1-bf39-ee4d0e5bd9f0</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,9a33424e-e956-47b1-bf39-ee4d0e5bd9f0.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,9a33424e-e956-47b1-bf39-ee4d0e5bd9f0.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9a33424e-e956-47b1-bf39-ee4d0e5bd9f0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">A little example of how xlinq can make
life eassier on us. And the pitfalls on how to get it to work.<br /><br />
I have have an xml file named Translation_En.xml.<br /><br /><b>Translation_En.xml</b><br /><br /><i>&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />
&lt;FormType&gt;<br />
  &lt;Vaccation&gt;Vaccation&lt;/Vaccation&gt;<br />
  &lt;Mission&gt;Mission&lt;/Mission&gt;<br />
  &lt;Holiday&gt;Holiday&lt;/Holiday&gt;<br />
&lt;/FormType&gt;</i><br /><br />
And then the class that will get the data and save it. Don't forget to set references
to system.core, system.data.linq, system.xml and system.xml.linq.<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> System.Linq<br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> Translation<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _Vaccation <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _Mission <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _Holiday <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _Language <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> Language <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br />
_language <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Language<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Language() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _Language<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br />
_Language <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Vaccation() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br />
_Vaccation <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> GetTranslation(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Vaccation"</span>)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _Vaccation<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br /></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">SaveTranslation("</span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">Vaccation</span></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">",value)<br /></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"> _Vaccation <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Mission() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br />
_Mission <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> GetTranslation(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Mission"</span>)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _Mission<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br /></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"> SaveTranslation("</span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">Mission</span></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">",value)<br /></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">  _Mission <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Holiday() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br />
_Holiday <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> GetTranslation(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Holiday"</span>)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _Holiday<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br />
SaveTranslation("</span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">Holiday</span></span><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">",value)<br />
_Holiday <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Function</span> GetTranslation(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> Element <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _return <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Element<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Try</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _File <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> XElement <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> XElement.Load(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"></span>GetFilename)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _Element <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> IEnumerable(Of
XElement) <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> From
c <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _File.Elements(Element) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Select</span> c<br />
_return <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> _Element.Value.ToString<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Catch</span> ex <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Exception<br />
MessageBox.Show(ex.Message)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Try</span><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _return<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Function<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"></span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span> SaveTranslation(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> Element <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _File <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> XElement <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Nothing</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _Element <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> IEnumerable(Of
XElement) <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Nothing</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Try</span> _File <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> XElement.Load(GetFilename)<br />
_Element <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> From
c <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _File.Elements(Element.ToString) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Select</span> c<br />
_Element(0).SetValue(value)<br />
_File.Save(GetFilename)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Catch</span> ex <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Exception<br />
MessageBox.Show(ex.Message)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Try</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre>
Private Function </span>GetFilename() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As
String<br />
Return <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Translation_En.xml"</span><br />
End Function<br /><br /></span> <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span></span></pre>
And now let me explain a bit further.<br />
First of all this class has getters and setters but that is not important ;-)<br /><br />
The most iportant bit is the getranslation function. 
<br /><br />
this line gets the data from the file and puts it in an Xelement object<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _File <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> XElement <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> XElement.Load(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"></span>GetFilename)<br /><br /></span>The next line takes out the Element we want. We don't need to specify the root
element(a misstake I made the first time around.)<br /><br /><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _Element <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> IEnumerable(Of
XElement) <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> From
c <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _File.Elements(Element) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Select</span> c<br /><br /></span></pre>
The last line just takes the value of the element and puts it in a string value.<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">_return <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> _Element.Value.ToString<br /><br /></span>So that is how we get data out of one element.<br /><br />
Now we want to update the file and that's what savetranslation is for, it is so easy
to understand if you name your methods correctly.<br /><br />
Again we load the file and get the correct element<br /><br /><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">_File <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> XElement.Load(GetFilename)<br />
_Element <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> From
c <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _File.Elements(Element.ToString) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Select</span> c<br /><br /></span></pre></span></span>Then we set the first elements vale (since we only have one returned
to us it has to be the first one). 
<br /><br /><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">_Element(0).SetValue(value)<br /><br /></span></pre></span></span>And last but not least we save the file.<br /><br /><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">_File.Save(GetFilename)<br /><br /></span></pre></span></span>Of course you could make this a lot better. And I will in a next episode.<br /><br /><br /></pre><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=9a33424e-e956-47b1-bf39-ee4d0e5bd9f0" /></body>
      <title>A Little Example Of How Xlinq Can Make Life Eassier On Us </title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,9a33424e-e956-47b1-bf39-ee4d0e5bd9f0.aspx</guid>
      <link>http://blog.baesonline.com/2008/04/13/ALittleExampleOfHowXlinqCanMakeLifeEassierOnUs.aspx</link>
      <pubDate>Sun, 13 Apr 2008 18:36:54 GMT</pubDate>
      <description>A little example of how xlinq can make life eassier on us. And the pitfalls on how to get it to work.&lt;br&gt;
&lt;br&gt;
I have have an xml file named Translation_En.xml.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Translation_En.xml&lt;/b&gt;
&lt;br&gt;
&lt;br&gt;
&lt;i&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br&gt;
&amp;lt;FormType&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Vaccation&amp;gt;Vaccation&amp;lt;/Vaccation&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Mission&amp;gt;Mission&amp;lt;/Mission&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Holiday&amp;gt;Holiday&amp;lt;/Holiday&amp;gt;&lt;br&gt;
&amp;lt;/FormType&amp;gt;&lt;/i&gt;
&lt;br&gt;
&lt;br&gt;
And then the class that will get the data and save it. Don't forget to set references
to system.core, system.data.linq, system.xml and system.xml.linq.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; System.Linq&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; Translation&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _Vaccation &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _Mission &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _Holiday &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _Language &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; Language &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
_language &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Language&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Language() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _Language&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
_Language &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Vaccation() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
_Vaccation &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; GetTranslation(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Vaccation"&lt;/span&gt;)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _Vaccation&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SaveTranslation("&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;Vaccation&lt;/span&gt;&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;",value)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; _Vaccation &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Mission() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
_Mission &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; GetTranslation(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Mission"&lt;/span&gt;)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _Mission&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; SaveTranslation("&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;Mission&lt;/span&gt;&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;",value)&lt;br&gt;
&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &amp;nbsp;_Mission &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Holiday() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
_Holiday &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; GetTranslation(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Holiday"&lt;/span&gt;)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _Holiday&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
SaveTranslation("&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;Holiday&lt;/span&gt;&lt;/span&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;",value)&lt;br&gt;
_Holiday &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;/span&gt; GetTranslation(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; Element &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _return &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Element&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _File &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; XElement &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; XElement.Load(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;&lt;/span&gt;GetFilename)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _Element &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; IEnumerable(Of
XElement) &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; From
c &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _File.Elements(Element) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Select&lt;/span&gt; c&lt;br&gt;
_return &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; _Element.Value.ToString&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Exception&lt;br&gt;
MessageBox.Show(ex.Message)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _return&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;/span&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; SaveTranslation(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; Element &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _File &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; XElement &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Nothing&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _Element &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; IEnumerable(Of
XElement) &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Nothing&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Try&lt;/span&gt; _File &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; XElement.Load(GetFilename)&lt;br&gt;
_Element &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; From
c &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _File.Elements(Element.ToString) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Select&lt;/span&gt; c&lt;br&gt;
_Element(0).SetValue(value)&lt;br&gt;
_File.Save(GetFilename)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Exception&lt;br&gt;
MessageBox.Show(ex.Message)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Try&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Private Function &lt;/span&gt;GetFilename() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As
String&lt;br&gt;
Return &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Translation_En.xml"&lt;/span&gt;
&lt;br&gt;
End Function&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
And now let me explain a bit further.&lt;br&gt;
First of all this class has getters and setters but that is not important ;-)&lt;br&gt;
&lt;br&gt;
The most iportant bit is the getranslation function. 
&lt;br&gt;
&lt;br&gt;
this line gets the data from the file and puts it in an Xelement object&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _File &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; XElement &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; XElement.Load(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;&lt;/span&gt;GetFilename)&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;The next line takes out the Element we want. We don't need to specify the root
element(a misstake I made the first time around.)&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _Element &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; IEnumerable(Of
XElement) &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; From
c &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _File.Elements(Element) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Select&lt;/span&gt; c&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
The last line just takes the value of the element and puts it in a string value.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;_return &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; _Element.Value.ToString&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;So that is how we get data out of one element.&lt;br&gt;
&lt;br&gt;
Now we want to update the file and that's what savetranslation is for, it is so easy
to understand if you name your methods correctly.&lt;br&gt;
&lt;br&gt;
Again we load the file and get the correct element&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;_File &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; XElement.Load(GetFilename)&lt;br&gt;
_Element &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; From
c &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _File.Elements(Element.ToString) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Select&lt;/span&gt; c&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;Then we set the first elements vale (since we only have one returned
to us it has to be the first one). 
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;_Element(0).SetValue(value)&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;And last but not least we save the file.&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;_File.Save(GetFilename)&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;Of course you could make this a lot better. And I will in a next episode.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/pre&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=9a33424e-e956-47b1-bf39-ee4d0e5bd9f0" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,9a33424e-e956-47b1-bf39-ee4d0e5bd9f0.aspx</comments>
      <category>.Net</category>
      <category>linq</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=6739fe7e-9fbe-49d8-bd05-df783dbc1ba8</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,6739fe7e-9fbe-49d8-bd05-df783dbc1ba8.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,6739fe7e-9fbe-49d8-bd05-df783dbc1ba8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6739fe7e-9fbe-49d8-bd05-df783dbc1ba8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Time to use an Ioc (Inversion of Control)
container like <a href="%5Bhttp://structuremap.sourceforge.net/Default.htm">structuremap</a>.
Most if not all examples you find on the net are in C# but us VB.Net developers aren't
imune for it either. So today I made my first project with <a href="%5Bhttp://structuremap.sourceforge.net/Default.htm">structuremap</a>.
Lets' see how it goes. Thanks to <a href="http://codebetter.com/blogs/jeremy.miller/">Jeremy
D. Miller </a>for making this great product.<br /><br />
I used the atributes for this and not the external config file (aka: StructureMap.config).<br /><br />
I will demonstrate this by crating a Dal, A model and A view/presenter. Let's start
with the Model<br /><br />
the interface<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Model.Interfaces <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Interface</span> IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Id() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Guid <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> LastName() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> FirstName() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Interface</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre><br />
the implementation<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Model <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> Person <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Model.Interfaces.IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _lastName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _id <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Guid <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Private</span> _firstName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span>()
_id <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span> Guid
_firstName <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">""</span> _lastName <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">""</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> FirstName() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Interfaces.IPerson.FirstName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _firstName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)
_firstName <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Id() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> System.Guid <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Interfaces.IPerson.Id <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _id <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> System.Guid)
_id <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> LastName() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Interfaces.IPerson.LastName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _lastName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span>)
_lastName <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> value <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Set</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Overrides</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Function</span> ToString() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> _lastName
&amp; <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
"</span> &amp; _firstName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Function</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre><br /><br />
Nothing fancy, not even pretty. But it works.<br /><br />
Then the dal<br /><br />
I start with an interface for the factory.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> StructureMap <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Dal.Factory
&lt;PluginFamily(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"SQLServerDaoFactory"</span>,
Issingleton:=<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">True</span>)&gt;
_ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Interface</span> IDAOFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Person() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Dal.Interfaces.IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Interface</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre><br />
And here we have the first attribute for structuremap. this says that if you want
an instance of this interface that you will have to look for a class with an attribute
plugable and a concretekey of "SQLServerDaoFactory" in other words this is the default
implementation of our interface.<br /><br />
Now lets look at SQLServerDAOFactory.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> StructureMap <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Dal.SQLServer
&lt;Pluggable(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"SQLServerDaoFactory"</span>)&gt;
_ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> DaoFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Dal.Factory.IDAOFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Person() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Interfaces.IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Factory.IDAOFactory.Person <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> ObjectFactory.GetInstance(Of
Interfaces.IPerson)() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre>
so this has a plugabble attribute with SQLServerDaoFactory as key. So this is the
default implementation for IDaoFactory.<br /><br />
Now we will create a form with 2 labels on them and One button. Just leave the standard,
this is just to show how it works. I won't even bother creating a presenter, let's
talk dirty.<br /><br />
In the form_load event you have to add this to intialize structuremap.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">StructureMapConfiguration.UseDefaultStructureMapConfigFile <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">False</span> StructureMapConfiguration.ScanAssemblies.IncludeTheCallingAssembly()</span></pre><br />
And in the button_click event you have to add this<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> a <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Model.Person <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> d <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Dal.Factory.IDAOFactory <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> ObjectFactory.GetInstance(Of
Dal.Factory.IDAOFactory)() a <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> d.Person.FindPersonbyName(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">""</span>)
Label1.Text <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> a.FirstName
Label2.Text <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> a.LastName</span></pre><br />
Don't forget to add structuremap.dll as a reference and to do an imports of structuremap
in the form.<br />
As you can we are doing a getinstance on ObjectFactory this will get us the default
implementation of DAOFactory. Namely SQLServerDAOFactory<br /><br />
So why are we doing all this? Since we could have just instantiated it the normal
way without a problem.<br /><br />
What if we now needed to have a MySQL Database instead of SQLServer? in our normal
program we had to change all the references from SQLServerDAOFactory to MySQLFactory
with structuremap we just change the pluginfamily default value and create a new daofactory.<br /><br />
this is the new daofactory.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> StructureMap <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Dal.MySQL
&lt;Pluggable(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"MySQLDaoFactory"</span>)&gt;
_ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> DaoFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Dal.Factory.IDAOFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Person() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Interfaces.IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Factory.IDAOFactory.Person <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span> ObjectFactory.InjectStub(<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">GetType</span>(Interfaces.IPerson), <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span> MySQLPerson) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> ObjectFactory.GetInstance(Of
Interfaces.IPerson)() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre><br /><br />
and this is the adapted idaofactory.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Imports</span> StructureMap <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span> Dal.SQLServer
&lt;Pluggable(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"MySQLDaoFactory"</span>)&gt;
_ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span> DaoFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Dal.Factory.IDAOFactory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span> Person() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> Interfaces.IPerson <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Implements</span> Factory.IDAOFactory.Person <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Return</span> ObjectFactory.GetInstance(Of
Interfaces.IPerson)() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Class</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Namespace</span></span></pre><br /><br />
and now run the code again and see the difference in the labels. So we have low coupling
and high cohesion.<br /><br />
Hope to see you soon for part 2<br /><br /><br /><br /><br /><p></p><img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=6739fe7e-9fbe-49d8-bd05-df783dbc1ba8" /></body>
      <title>StructureMap and VB.NET</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,6739fe7e-9fbe-49d8-bd05-df783dbc1ba8.aspx</guid>
      <link>http://blog.baesonline.com/2008/03/16/StructureMapAndVBNET.aspx</link>
      <pubDate>Sun, 16 Mar 2008 14:39:03 GMT</pubDate>
      <description>Time to use an Ioc (Inversion of Control) container like &lt;a href="%5Bhttp://structuremap.sourceforge.net/Default.htm"&gt;structuremap&lt;/a&gt;.
Most if not all examples you find on the net are in C# but us VB.Net developers aren't
imune for it either. So today I made my first project with &lt;a href="%5Bhttp://structuremap.sourceforge.net/Default.htm"&gt;structuremap&lt;/a&gt;.
Lets' see how it goes. Thanks to &lt;a href="http://codebetter.com/blogs/jeremy.miller/"&gt;Jeremy
D. Miller &lt;/a&gt;for making this great product.&lt;br&gt;
&lt;br&gt;
I used the atributes for this and not the external config file (aka: StructureMap.config).&lt;br&gt;
&lt;br&gt;
I will demonstrate this by crating a Dal, A model and A view/presenter. Let's start
with the Model&lt;br&gt;
&lt;br&gt;
the interface&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Model.Interfaces &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Interface&lt;/span&gt; IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Id() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Guid &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; LastName() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; FirstName() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Interface&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
the implementation&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Model &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; Person &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Model.Interfaces.IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _lastName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _id &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Guid &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _firstName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;()
_id &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; Guid
_firstName &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;""&lt;/span&gt; _lastName &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;""&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; FirstName() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Interfaces.IPerson.FirstName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _firstName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)
_firstName &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Id() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.Guid &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Interfaces.IPerson.Id &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _id &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.Guid)
_id &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; LastName() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Interfaces.IPerson.LastName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _lastName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt;)
_lastName &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Overrides&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;/span&gt; ToString() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; _lastName
&amp;amp; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
"&lt;/span&gt; &amp;amp; _firstName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
Nothing fancy, not even pretty. But it works.&lt;br&gt;
&lt;br&gt;
Then the dal&lt;br&gt;
&lt;br&gt;
I start with an interface for the factory.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; StructureMap &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Dal.Factory
&amp;lt;PluginFamily(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"SQLServerDaoFactory"&lt;/span&gt;,
Issingleton:=&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;True&lt;/span&gt;)&amp;gt;
_ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Interface&lt;/span&gt; IDAOFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Person() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Dal.Interfaces.IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Interface&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
And here we have the first attribute for structuremap. this says that if you want
an instance of this interface that you will have to look for a class with an attribute
plugable and a concretekey of "SQLServerDaoFactory" in other words this is the default
implementation of our interface.&lt;br&gt;
&lt;br&gt;
Now lets look at SQLServerDAOFactory.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; StructureMap &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Dal.SQLServer
&amp;lt;Pluggable(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"SQLServerDaoFactory"&lt;/span&gt;)&amp;gt;
_ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; DaoFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Dal.Factory.IDAOFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Person() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Interfaces.IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Factory.IDAOFactory.Person &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; ObjectFactory.GetInstance(Of
Interfaces.IPerson)() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
so this has a plugabble attribute with SQLServerDaoFactory as key. So this is the
default implementation for IDaoFactory.&lt;br&gt;
&lt;br&gt;
Now we will create a form with 2 labels on them and One button. Just leave the standard,
this is just to show how it works. I won't even bother creating a presenter, let's
talk dirty.&lt;br&gt;
&lt;br&gt;
In the form_load event you have to add this to intialize structuremap.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;StructureMapConfiguration.UseDefaultStructureMapConfigFile &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;False&lt;/span&gt; StructureMapConfiguration.ScanAssemblies.IncludeTheCallingAssembly()&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
And in the button_click event you have to add this&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; a &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Model.Person &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; d &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Dal.Factory.IDAOFactory &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; ObjectFactory.GetInstance(Of
Dal.Factory.IDAOFactory)() a &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; d.Person.FindPersonbyName(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;""&lt;/span&gt;)
Label1.Text &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; a.FirstName
Label2.Text &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; a.LastName&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
Don't forget to add structuremap.dll as a reference and to do an imports of structuremap
in the form.&lt;br&gt;
As you can we are doing a getinstance on ObjectFactory this will get us the default
implementation of DAOFactory. Namely SQLServerDAOFactory&lt;br&gt;
&lt;br&gt;
So why are we doing all this? Since we could have just instantiated it the normal
way without a problem.&lt;br&gt;
&lt;br&gt;
What if we now needed to have a MySQL Database instead of SQLServer? in our normal
program we had to change all the references from SQLServerDAOFactory to MySQLFactory
with structuremap we just change the pluginfamily default value and create a new daofactory.&lt;br&gt;
&lt;br&gt;
this is the new daofactory.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; StructureMap &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Dal.MySQL
&amp;lt;Pluggable(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"MySQLDaoFactory"&lt;/span&gt;)&amp;gt;
_ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; DaoFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Dal.Factory.IDAOFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Person() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Interfaces.IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Factory.IDAOFactory.Person &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; ObjectFactory.InjectStub(&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;GetType&lt;/span&gt;(Interfaces.IPerson), &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; MySQLPerson) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; ObjectFactory.GetInstance(Of
Interfaces.IPerson)() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
and this is the adapted idaofactory.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Imports&lt;/span&gt; StructureMap &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt; Dal.SQLServer
&amp;lt;Pluggable(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"MySQLDaoFactory"&lt;/span&gt;)&amp;gt;
_ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; DaoFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Dal.Factory.IDAOFactory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; Person() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; Interfaces.IPerson &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; Factory.IDAOFactory.Person &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; ObjectFactory.GetInstance(Of
Interfaces.IPerson)() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Namespace&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
and now run the code again and see the difference in the labels. So we have low coupling
and high cohesion.&lt;br&gt;
&lt;br&gt;
Hope to see you soon for part 2&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=6739fe7e-9fbe-49d8-bd05-df783dbc1ba8" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,6739fe7e-9fbe-49d8-bd05-df783dbc1ba8.aspx</comments>
      <category>.Net</category>
      <category>Open Source</category>
    </item>
    <item>
      <trackback:ping>http://blog.baesonline.com/Trackback.aspx?guid=b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2</trackback:ping>
      <pingback:server>http://blog.baesonline.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.baesonline.com/PermaLink,guid,b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2.aspx</pingback:target>
      <dc:creator>Chrissie1</dc:creator>
      <wfw:comment>http://blog.baesonline.com/CommentView,guid,b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2.aspx</wfw:comment>
      <wfw:commentRss>http://blog.baesonline.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>
          <span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">I
think this is kinda neat ;-)<br /><br />
No more writting of compareto's or equals just use linq.<br /><br /><br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _Directories() <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _Directory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _DirectoryInfos <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span> List(Of
DirectoryInfo)<br /><br />
_Directories <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Directory.GetDirectories(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"c:/"</span>)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">For</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Each</span> _Directory <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _Directories<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> directoryinfo <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">As</span> System.IO.DirectoryInfo <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">New</span> System.IO.DirectoryInfo(_Directory)<br />
_DirectoryInfos.<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Add</span>(directoryinfo)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Next</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'
Run LINQ Query</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Dim</span> _DirectoryInfosOrderedByCreationTime <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> From
DirectoryInfos <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _DirectoryInfos
_<br />
Order By DirectoryInfos.CreationTime Descending _<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Select</span> DirectoryInfos<br /><br /><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">'
Display results of query</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">If</span> _DirectoryInfosOrderedByCreationTime.<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Count</span> &gt;
0 <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Then</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">For</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Each</span> DirectoryInfo <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">In</span> _DirectoryInfosOrderedByCreationTime<br />
TextBox1.AppendText(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Directory:
"</span> &amp; DirectoryInfo.FullName &amp; <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"
Date: "</span> &amp; DirectoryInfo.CreationTime &amp; ControlChars.CrLf)<br /><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">Next</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">If</span></span>
        </pre>
        <br />
        <br />
        <br />
        <img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2" />
      </body>
      <title>Ordering Directories by creation date using linq</title>
      <guid isPermaLink="false">http://blog.baesonline.com/PermaLink,guid,b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2.aspx</guid>
      <link>http://blog.baesonline.com/2008/01/17/OrderingDirectoriesByCreationDateUsingLinq.aspx</link>
      <pubDate>Thu, 17 Jan 2008 22:16:17 GMT</pubDate>
      <description>&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;I
think this is kinda neat ;-)&lt;br&gt;
&lt;br&gt;
No more writting of compareto's or equals just use linq.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _Directories() &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _Directory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _DirectoryInfos &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; List(Of
DirectoryInfo)&lt;br&gt;
&lt;br&gt;
_Directories &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Directory.GetDirectories(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"c:/"&lt;/span&gt;)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;For&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Each&lt;/span&gt; _Directory &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _Directories&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; directoryinfo &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.IO.DirectoryInfo &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; System.IO.DirectoryInfo(_Directory)&lt;br&gt;
_DirectoryInfos.&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Add&lt;/span&gt;(directoryinfo)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Next&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'
Run LINQ Query&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; _DirectoryInfosOrderedByCreationTime &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; From
DirectoryInfos &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _DirectoryInfos
_&lt;br&gt;
Order By DirectoryInfos.CreationTime Descending _&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Select&lt;/span&gt; DirectoryInfos&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'
Display results of query&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; _DirectoryInfosOrderedByCreationTime.&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Count&lt;/span&gt; &amp;gt;
0 &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;For&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Each&lt;/span&gt; DirectoryInfo &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;In&lt;/span&gt; _DirectoryInfosOrderedByCreationTime&lt;br&gt;
TextBox1.AppendText(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Directory:
"&lt;/span&gt; &amp;amp; DirectoryInfo.FullName &amp;amp; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
Date: "&lt;/span&gt; &amp;amp; DirectoryInfo.CreationTime &amp;amp; ControlChars.CrLf)&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;Next&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://blog.baesonline.com/aggbug.ashx?id=b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2" /&gt;</description>
      <comments>http://blog.baesonline.com/CommentView,guid,b5bc0b45-b0eb-4adf-bf35-f753efe7c8e2.aspx</comments>
      <category>.Net</category>
    </item>
  </channel>
</rss>