<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Turvey&#039;s Blog</title>
	<atom:link href="http://www.davidturvey.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidturvey.com/blog</link>
	<description>All About Development</description>
	<lastBuildDate>Tue, 17 Apr 2012 11:45:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Creating a simple custom TFS 2010 build activity</title>
		<link>http://www.davidturvey.com/blog/index.php/2012/04/creating-a-simple-custom-tfs-2010-build-activity/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2012/04/creating-a-simple-custom-tfs-2010-build-activity/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 11:45:56 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[TFS 2010]]></category>
		<category><![CDATA[build activity]]></category>
		<category><![CDATA[build server]]></category>
		<category><![CDATA[code activity]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[workflow]]></category>
		<category><![CDATA[workspace]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=181</guid>
		<description><![CDATA[Creating a custom build activity for TFS 2010 is fairly simple, in this post I&#8217;ll show you how to create a simple check out activity. To create a custom build activity you need to inherit from either CodeActivity or CodeActivity&#60;T&#62;, &#8230; <a href="http://www.davidturvey.com/blog/index.php/2012/04/creating-a-simple-custom-tfs-2010-build-activity/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Creating a custom build activity for TFS 2010 is fairly simple, in this post I&#8217;ll show you how to create a simple check out activity.</p>
<p>To create a custom build activity you need to inherit from either <strong>CodeActivity</strong> or <strong>CodeActivity&lt;T&gt;</strong>, both of which reside in System.Activities. <strong>CodeActivity&lt;T&gt;</strong> is used to return a value out of the activity where T is the return type.</p>
<p>To get data into your class you need to create your properties using <strong>InArgument&lt;T&gt;</strong> (<strong>InOutArgument&lt;T&gt;</strong> and <strong>OutArgument&lt;T&gt;</strong> are also available). For example, if you need to get a file name into your class you would create a property: <strong>public InArgument&lt;string&gt; Filename { get; set; }</strong> which will appear as a string property named Filename in the workflow designer.</p>
<p>Use the attribute <strong>[RequiredArgument]</strong> to specify that a value is required for a property.</p>
<p>Finally you need to override the Execute method, this is the method that will contain the execution code for your build activity. The code activity context will be passed into this method which will allow you to access your properties. Once you have dragged the activity onto your build workflow you simply need to set the Workspace property to Workspace and set the FilePath property to the server path for the file you want to check out.</p>
<pre class="brush: csharp">

public sealed class CheckOutFile : CodeActivity
{
  [RequiredArgument]
  public InArgument&lt;Workspace&gt; Workspace { get; set; }

  [RequiredArgument]
  public InArgument&lt;string&gt; FilePath { get; set; }

  protected override void Execute(CodeActivityContext context)
  {
    // Obtain the runtime values
    Workspace workspace = context.GetValue(Workspace);
    String filePath = context.GetValue(FilePath);

    // Get the pending changes to the filePath
    PendingChange[] pendingChanges =
    workspace.GetPendingChanges(filePath, RecursionType.Full);

    // If no pending change for the filePath was found
    // it means the file is can be checked out
    if (pendingChanges.Length == 0)
    {
      // Check out the file
      workspace.PendEdit(filePath, RecursionType.Full);
    }
  }
}

</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2012/04/creating-a-simple-custom-tfs-2010-build-activity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a custom crossdomain.xml policy file with Flex 3/4</title>
		<link>http://www.davidturvey.com/blog/index.php/2010/05/using-a-custom-crossdomain-xml-policy-file-with-flex-34/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2010/05/using-a-custom-crossdomain-xml-policy-file-with-flex-34/#comments</comments>
		<pubDate>Tue, 25 May 2010 13:40:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=160</guid>
		<description><![CDATA[Recently I needed to use ActionScript&#8217;s URLLoader class to retrieve XML from a .NET Web Service, I had no problems until I tried to access the Web Service on a remote machine (i.e. not localhost). When I tried to do &#8230; <a href="http://www.davidturvey.com/blog/index.php/2010/05/using-a-custom-crossdomain-xml-policy-file-with-flex-34/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently I needed to use ActionScript&#8217;s URLLoader class to retrieve XML from a .NET Web Service, I had no problems until I tried to access the Web Service on a remote machine (i.e. not localhost). When I tried to do this I got the error:</p>
<blockquote><p>Error #2048: Security sandbox violation: http://localhost/myapplication/main.swf cannot load data from http://remotemachine/webservice.</p></blockquote>
<p>Not the most useful error message. Searching the web for this error produced a lot of useless results, eventually I discovered that I needed a <strong>crossdomain.xml</strong> policy file on the remote machine (in the web server root, in this case c:\inetpub\wwwroot) that grants the calling machine access. Where the crossdomain.xml file is in the format shown below (the domain attribute would obviously be replaced with one of the items mentioned in quotes). </p>
<pre class="brush: xml">
&lt;cross-domain-policy&gt;
    &lt;allow-access-from domain=&quot;URL&quot; /&gt;
    &lt;allow-access-from domain=&quot;URL Wildcard&quot; /&gt;
    &lt;allow-access-from domain=&quot;Specific IP Address&quot; /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p>My web service doesn&#8217;t know the URL or IP address of the application that will be calling it so I need to use <strong>domain=&#8221;*&#8221;</strong> to allow anyone to connect but if I put this in the cross domain policy file that is in the root it applies that access to everything below it not just my web service which is sitting in /webservice. This is obviously undesirable, so the solution seems simple &#8211; place the crossdomain.xml file in the /webservice directory.</p>
<p>In the code you would make the following call before making the request with the URLLoader class:</p>
<pre class="brush: actionscript3">
Security.loadPolicyFile(&quot;http://remotemachine/webservice/crossdomain.xml&quot;);
</pre>
<p>This tells the Flash framework to load a custom cross-domain policy file, simple right? No.<br />
Unfortunately this did nothing, using <a href="http://www.fiddler2.com/" target="_blank">Fiddler2</a> I could see that the custom cross-domain policy file was being requested at downloaded successfully, but wasn&#8217;t working for some reason.</p>
<p>Again, after searching through many useless results on the web claiming to describe how to fix the problem I discovered what to do, and it&#8217;s pretty simple (the links that I found are at the end of this article).</p>
<p>You need to create a cross-domain policy file (i.e. crossdomain.xml) in the root of the web server that allows custom cross-domain policy files and then <strong>Security.loadPolicyFile()</strong> will actually use the custom cross-domain policy file specified in /webservice. </p>
<p>You have a number of options for restricting how custom cross-domain policy files are used, the easiest and least restrictive is to allow all custom cross-domain policy files, to do this you would used the following:</p>
<pre class="brush: xml">
&lt;cross-domain-policy&gt;
	&lt;site-control permitted-cross-domain-policies=&quot;all&quot; /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p>The option I went with is to only allow policy files with a specific content-type, the master policy file (in the root of your web server) would contain the following:</p>
<pre class="brush: xml">
&lt;cross-domain-policy&gt;
	&lt;site-control permitted-cross-domain-policies=&quot;by-content-type&quot; /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p>Then I set up (in IIS) the extension <strong>.policy</strong> to have a MIME type of <strong>text/x-cross-domain-policy</strong> in the directory /webservice on my remote web server and created a file in the /webservice directory called <strong>crossdomain.policy</strong> with the following XML:</p>
<pre class="brush: xml">
&lt;cross-domain-policy&gt;
    &lt;allow-access-from domain=&quot;*&quot; /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p>If this all seems confusing there is the summary of what you need to do:</p>
<ul>
<li>Create a master policy file in the root of the web server allowing custom policy files.</li>
<li>Create a custom policy file in the directory you want the policy to apply to.</li>
<li>Call Security.loadPolicyFile(YOUR CUSTOM POLICY FILE) before calling urlLoader.load()</li>
</ul>
<p>Why Adobe&#8217;s ActionScript Language Reference documentation for the Security.loadPolicyFile() method does not mention that you need to allow custom policy files in the master policy file is beyond me.</p>
<p><strong>Links:</strong><br />
<a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" target="_blank">Cross-domain policy file specification</a><br />
<a href="http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_05.html" target="_blank">Policy file changes in Flash Player 9 &#038; 10 &#8211; Workflows</a><br />
<a href="http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_03.html" target="_blank">Policy file changes in Flash Player 9 &#038; 10 &#8211; Meta-Policies</a><br />
<a href="http://www.actionscript.org/forums/showthread.php3?t=239474" target="_blank">A post on actionscript.org I created regarding my issue</a></p>
<p>Note: The solution should apply to Flash applications as well, not just Flex Applications, as all the classes mentioned above are actually Flash classes and not Flex classes. (I&#8217;m making an assumption here as I&#8217;ve never used Flash CSx, but I&#8217;m pretty certain it should <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2010/05/using-a-custom-crossdomain-xml-policy-file-with-flex-34/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding Intellisense comments to Flex functions</title>
		<link>http://www.davidturvey.com/blog/index.php/2010/02/adding-intellisense-comments-to-flex-functions/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2010/02/adding-intellisense-comments-to-flex-functions/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 04:24:13 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Code Comments]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Intellisense]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=145</guid>
		<description><![CDATA[Adding comments to your code in Flex that can be picked up by the IDE&#8217;s Intellisense is very easy, it&#8217;s not as elegant as .NET&#8217;s implementation in my opinion but it&#8217;s simple and it works (I haven&#8217;t had any issues &#8230; <a href="http://www.davidturvey.com/blog/index.php/2010/02/adding-intellisense-comments-to-flex-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Adding comments to your code in Flex that can be picked up by the IDE&#8217;s Intellisense is very easy, it&#8217;s not as elegant as .NET&#8217;s implementation in my opinion but it&#8217;s simple and it works (I haven&#8217;t had any issues yet <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>You just need to add a block comment before your function that starts with two stars, i.e. /** */. Inside this block you can enter your comments about the function, if the function has parameters just include @param then the name of parameter and then the comment about it, and for return values you insert @return and the comment about the return value. See the example below:</p>
<pre class="brush: actionscript3">
public final class Strings
{
    /**
    * Checks if two strings are equal 
    * @param value1 The first string
    * @param value2 The second string
    * @param caseSensitive Should a case sensitive comparision be done, default is &amp;amp;lt;b&amp;amp;gt;false&amp;amp;lt;/b&amp;amp;gt;
    * @return Returns true if the strings are equal otherwise returns false 
    */        
    public static function AreEqual(value1:String, value2:String, caseSensitive:Boolean=false):Boolean
    {
        // Function body here
    }
}
</pre>
<p>Doing this will display the following information when you navigate through the Intellisense list to the function you added the comment to:<br />
<img src="http://www.davidturvey.com/blog/wp-content/2010/02/FlexIntellisense.gif" alt="FlexIntellisense" title="FlexIntellisense" width="613" height="237" class="aligncenter size-full wp-image-149" /></p>
<p>Note you can include HTML tags in your intellisense comments, I&#8217;m not sure which tags are supported as I haven&#8217;t checked, I assume just the basic font formatting tags.</p>
<p>Also this works on fields, property getters/setters, etc.</p>
<p><em>Post based on Adobe Flash Builder 4 Beta 2 (I assume it is the same in Adobe Flex Builder 3)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2010/02/adding-intellisense-comments-to-flex-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing the Browser Query String to a Flex 4 Application</title>
		<link>http://www.davidturvey.com/blog/index.php/2010/01/query-string-to-flex4-app/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2010/01/query-string-to-flex4-app/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 07:26:31 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[query string]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=131</guid>
		<description><![CDATA[Passing parameters into a Flex 4 (Beta 2) application is slightly different to passing parameters into a Flex 3 application. Previously you would pass a string into the flashvars parameter with the key/value pairs, now you pass in an associative &#8230; <a href="http://www.davidturvey.com/blog/index.php/2010/01/query-string-to-flex4-app/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Passing parameters into a Flex 4 (Beta 2) application is slightly different to passing parameters into a Flex 3 application. Previously you would pass a string into the <strong>flashvars</strong> parameter with the key/value pairs, now you pass in an associative array with the key/value pairs.</p>
<p>In the launcher HTML template file you will see the following javascript:</p>
<pre class="brush: javascript">
var swfVersionStr = &quot;${version_major}.${version_minor}.${version_revision}&quot;;
var xiSwfUrlStr = &quot;${expressInstallSwf}&quot;;
var flashvars = {};
var params = {};
params.quality = &quot;high&quot;;
params.bgcolor = &quot;${bgcolor}&quot;;
params.allowscriptaccess = &quot;sameDomain&quot;;
params.allowfullscreen = &quot;true&quot;;
var attributes = {};
attributes.id = &quot;${application}&quot;;
attributes.name = &quot;${application}&quot;;
attributes.align = &quot;middle&quot;;
swfobject.embedSWF(
	&quot;${swf}.swf&quot;, &quot;flashContent&quot;, 
	&quot;${width}&quot;, &quot;${height}&quot;, 
	swfVersionStr, xiSwfUrlStr, 
	flashvars, params, attributes);
swfobject.createCSS(&quot;#flashContent&quot;, &quot;display:block;text-align:left;&quot;);
</pre>
<p>As you can see the <strong>flashvars</strong> and <strong>params</strong> are now passed into the Flash object as associative arrays, and the method that is called on the Flash object is no longer <strong>AC_FL_RunContent()</strong>.</p>
<p>To get the query string into the <strong>flashvars</strong> object is very easy, simply iterate through the query string and add each key/value to the <strong>flashvars</strong> object.</p>
<pre class="brush: javascript">
var swfVersionStr = &quot;${version_major}.${version_minor}.${version_revision}&quot;;
var xiSwfUrlStr = &quot;${expressInstallSwf}&quot;;
var flashvars = {};

var queryString = window.location.search.substring(1);
if (queryString != null &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; queryString.length &gt; 0)
{			
	var keyValuePairs = queryString.split(&quot;&amp;amp;amp;amp;amp;&quot;);
	for (var i = 0; i &lt; keyValuePairs.length; i++) 
	{
		var keyValuePair = keyValuePairs[i].split(&quot;=&quot;);
		
		if (keyValuePair.length == 2)
		{
			flashvars[keyValuePair[0]] = keyValuePair[1];
		}
	}
} 

var params = {};
params.quality = &quot;high&quot;;
params.bgcolor = &quot;${bgcolor}&quot;;
params.allowscriptaccess = &quot;sameDomain&quot;;
params.allowfullscreen = &quot;true&quot;;

var attributes = {};
attributes.id = &quot;${application}&quot;;
attributes.name = &quot;${application}&quot;;
attributes.align = &quot;middle&quot;;

swfobject.embedSWF(
	&quot;${swf}.swf&quot;, &quot;flashContent&quot;, 
	&quot;${width}&quot;, &quot;${height}&quot;, 
	swfVersionStr, xiSwfUrlStr, 
	flashvars, params, attributes);
swfobject.createCSS(&quot;#flashContent&quot;, &quot;display:block;text-align:left;&quot;);
</pre>
<p>Then to access the parameters inside your Flex application you just need to access the <strong>parameters</strong> property on the <strong>application</strong> object.</p>
<pre class="brush: actionscript3">
var someVariable:String = this.parameters[&quot;MyQueryStringKey&quot;];
// OR
var someOtherVariable:String = FlexGlobals.topLevelApplication.parameters[&quot;MyQueryStringKey&quot;];
</pre>
<p>That&#8217;s it, simple <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>Post based on Adobe Flash Builder 4 Beta 2</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2010/01/query-string-to-flex4-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 and Flex 4</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/12/actionscript-3-and-flex-4/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/12/actionscript-3-and-flex-4/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 15:18:18 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=128</guid>
		<description><![CDATA[I recently started working on a project using Flex 4, the project is basically a port of an existing application to Flash 10 (using Flex 4); so that we can have a version of the application that works in any &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/12/actionscript-3-and-flex-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I recently started working on a project using Flex 4, the project is basically a port of an existing application to Flash 10 (using Flex 4); so that we can have a version of the application that works in any browser. So over the next few months I&#8217;ll probably be posting more about Flex 4/ActionScript 3 than on .NET, I&#8217;ll still try find some time to do .NET posts though.</p>
<p>This post is basically just an introduction to what Flex and ActionScript are, and some random things I&#8217;ve learnt about them.</p>
<p>I have to admit when I was first told that I&#8217;d be working on a Flex application I wasn&#8217;t particularly happy, I&#8217;m not a big fan of Flash or scripting languages; but I have to say after working with it for a while I&#8217;m pleasantly surprised &#8211; it&#8217;s no .NET but for a scripting language it&#8217;s pretty good.</p>
<p><a href="http://en.wikipedia.org/wiki/Adobe_Flex">Flex</a> is basically a library that sits on top of Flash providing developers an easy way to create Flash applications. For developers like myself the idea of having to create a Flash application with Flash CS4 is absolute hell; frames, movies, timelines and all that nonsense. So Adobe created the Flex library and the Flex IDE for developers like me that want to code in the traditional sense <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I think Adobe have done a pretty good job given the constraints they were under building on top of the Flash framework; it&#8217;s not perfect by any means and it&#8217;s lacks a lot but much better than I was expecting.</p>
<p>Now I must make a clear distinction, <a href="http://en.wikipedia.org/wiki/ActionScript">ActionScript</a> is Adobe&#8217;s implementation of the <a href="http://en.wikipedia.org/wiki/ECMAScript">ECMAScript</a> specification, so any limitations I mention are limitations of ActionScript and the ECMAScript specification; I&#8217;m assuming of course that Adobe has implemented the specification fully <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Also, ActionScript is not a Flex thing, it is part of Flash.</p>
<p>Some random things about ActionScript 3.0:</p>
<ul>
<li>Requires Flash Player 9.0 or higher.</li>
<li>There are no abstract classes or abstract methods.</li>
<li>Does not have a concept similar to .NET generics or C++ templates</li>
<li>Classes and class members can be private, protected, internal, or public. </li>
<li>Has static class members but not static classes.</li>
<li>No enumerated types.</li>
<li>Properties are defined using get/set functions.</li>
<li>Has interfaces, yay!</li>
<li>Has exceptions and exception handling using try&#8230;catch&#8230;finally blocks.</li>
<li>Anonymous functions are allowed.</li>
<li>Has compile time type checking (it can be turned off if you really want it off )</li>
<li>If you name your function/field the name as a class (case sensitive) you will need to fully qualify the type declaration.</li>
</ul>
<p>Some random things about Flex:</p>
<ul>
<li>Collections/lists are weakly typed, i.e. Array and ArrayCollection hold the type Object.</li>
<li>Has packages; which are a similar idea to .NET namespaces</li>
<li>Internal does not have the same meaning as in .NET, internal in Flex means within the current package, not the current project.</li>
<li>All file loading is done asynchronously with callbacks.</li>
<li>The &#8220;event model&#8221; is weird (i.e. not true events), to &#8220;raise&#8221; events your class needs to inherit from EventDispatcher and classes hook into events on your class using the addEventListener method and specifying the string name of the event to hook into.</li>
<li>You cannot define a signature for event handlers.</li>
</ul>
<p>Just a quick disclaimer, I&#8217;m still new to Flex/ActionScript so hopefully everything I&#8217;ve mentioned here is correct <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you think I&#8217;m wrong about something, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/12/actionscript-3-and-flex-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google&#8217;s Go &#8211; Language Fail?</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/11/googles-go-language-fail/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/11/googles-go-language-fail/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 09:23:35 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[overloading]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=117</guid>
		<description><![CDATA[Google released a new programming language named Go recently, by the sounds of it they are hoping it will solve developer woes and make development easier. I don&#8217;t agree with their reason for creating it to start off with, from &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/11/googles-go-language-fail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Google released a new programming language named Go recently, by the sounds of it they are hoping it will solve developer woes and make development easier. I don&#8217;t agree with their reason for creating it to start off with, from the Go FAQ page: &#8220;Go was born out of frustration with existing languages and environments for systems programming.  Programming had become too difficult and the choice of languages was partly to blame.&#8221; Personally I don&#8217;t find programming difficult but maybe that&#8217;s just because I&#8217;m looking at a different set of problems than the guys behind Go.</p>
<p>Before I continue let me just make it clear that I&#8217;m a .NET developer (I was a Delphi developer many years ago) and a fan of the Microsoft development environment so what I have to say is influenced by my experiences with Microsoft tools and languages.</p>
<p>While I think it&#8217;s admirable that Google wants to simplify programming, I personally don&#8217;t see anything enticing about the language to make the move to it. These are my problems with the language in it&#8217;s current form, who knows maybe future versions will be better <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<ul>
<li>No generics &#8211; I understand that it must be difficult to include generics in a compiler but come on, generics are so useful! (<a href="http://golang.org/doc/go_lang_faq.html#generics" target="_blank">link</a>)</li>
<li>No exceptions &#8211; This I don&#8217;t understand! Come on, there are meant to be some sharp guys working on this project &#8211; how can they not include exceptions?! (<a href="http://golang.org/doc/go_lang_faq.html#exceptions" target="_blank">link</a>)</li>
<li>No type inheritance &#8211; Now this is the one point that makes me think this language isn&#8217;t much better than VBScript. (<a href="http://golang.org/doc/go_lang_faq.html#inheritance" target="_blank">link</a>)</li>
<li>No overloading of method or operators &#8211; This isn&#8217;t a big deal but it would be nice. (<a href="http://golang.org/doc/go_lang_faq.html#inheritance" target="_blank">link</a>)</li>
</ul>
<p>So those are my main dislikes about the language, but there are some other problems too. I thought I&#8217;d give it a try even though I wan&#8217;t keen on it so I went to the download page and you have to download the source and compile the compiler, that&#8217;s where I lost interest in Go! How hard is it to provide binaries for the most common platforms! I&#8217;m assuming that it is just a command line compiler and that there is no IDE, which is another negative.</p>
<p>There are two things that they have done that are cool; one is that they have build in some clever support for concurrency using <a href="http://en.wikipedia.org/wiki/Communicating_sequential_processes" target="_blank">CSP</a>, and the other is that Go will be <a href="http://news.cnet.com/8301-30685_3-10395355-264.html?part=rss&amp;subj=news&amp;tag=2547-1_3-0-20" target="_blank">available in Chrome</a> and as a plugin for other browsers. This could be where Go finds its niche, personally I&#8217;d like to see a language more powerful than JavaScript in the browser.</p>
<p>I must also mention that Go is an experimental programming language so I&#8217;m probably being a little harsh <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/11/googles-go-language-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding OnSaving an OnSaved Events to LINQ to SQL Entities</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/11/adding-onsaving-an-onsaved-events-to-linq-to-sql-entities/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/11/adding-onsaving-an-onsaved-events-to-linq-to-sql-entities/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 06:00:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[base class]]></category>
		<category><![CDATA[change tracking]]></category>
		<category><![CDATA[ChangeAction]]></category>
		<category><![CDATA[DataContext]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[partial class]]></category>
		<category><![CDATA[SubmitChanges]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=106</guid>
		<description><![CDATA[As you know LINQ to SQL entities have OnCreated, OnLoaded, and OnValidate &#8220;events&#8221;; which are actually just partial methods which you implement in your matching partial custom classes for your LINQ to SQL entities. Two &#8220;events&#8221; that are missing that &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/11/adding-onsaving-an-onsaved-events-to-linq-to-sql-entities/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As you know LINQ to SQL entities have OnCreated, OnLoaded, and OnValidate &#8220;events&#8221;; which are actually just partial methods which you implement in your matching partial custom classes for your LINQ to SQL entities. Two &#8220;events&#8221; that are missing that can be quite useful are OnSaving and OnSaved which would fire before writing to the database and after writing to the database.</p>
<p>Adding this functionality is fairly easy; first add a base class to your LINQ to SQL entities as described in my post <a href="http://www.davidturvey.com/blog/index.php/2009/linq-to-sql/adding-a-base-class-or-interface-to-all-linq-to-sql-entities/">Adding a Base Class (or Interface) to All LINQ to SQL Entities</a> and add the virtual methods OnSaving and OnSaved as below.</p>
<pre class="brush: c#">
public abstract class EntityBase
{
    internal virtual void OnSaving(ChangeAction changeAction) { }

    internal virtual void OnSaved() { }
}
</pre>
<p>Then for any LINQ to SQL entities that you wish to have hooked up to these &#8220;events&#8221; implement the partial class and override the methods, for example you could use the OnSaving &#8220;event&#8221; to set your audit data:</p>
<pre class="brush: c#">
public partial class Customer
{
    internal override void OnSaving(ChangeAction changeAction)
    {
        base.OnSaving(changeAction);

        switch (changeAction)
        {
            case ChangeAction.Insert:
                InsertedDate = DateTime.Now;
                break;
            case ChangeAction.Update:
                UpdatedDate = DateTime.Now;
                break;
            default:
                break;
        }
    }
}
</pre>
<p>Create a class called ChangeEntity and add the properties ChangeAction and Entity to the class, this class will be used later so that we know what action is happening to each entity.</p>
<pre class="brush: c#">
internal class ChangeEntity
{
    public ChangeAction ChangeAction { get; set; }

    public EntityBase Entity { get; set; }
}
</pre>
<p>Now what we need to do is override the SubmitChanges method on the data context, the parameterless SubmitChanges method cannot be overridden as it is not virtual so we override the method SubmitChanges(ConflictMode failureMode); which the parameterless method calls.</p>
<p>We will then create a list of all the entities that have been modified (i.e. inserted, updated, or deleted) using the ChangeSet object that is returned by the GetChangeSet() method &#8211; the returned object has a seperate list for Deletes, Inserts, and Updates which we will join together into a single list. </p>
<p>Then we build up a list of ChangeEntity objects which will contain a reference to each entity to be changed and an enum of type ChangeAction stating the action to take place for each entity; namely Insert, Update, or Delete.</p>
<p>Then we enumerate through the list of ChangeEntity and call the method OnSaving on each entity.</p>
<p>Then we call SubmitChanges on the base class, and finally we enumerate throught the list of ChangeEntity once again and call the method OnSaved on each entity.</p>
<p>Below is the required code, it is more verbose that I would usually write but the original code didn&#8217;t display nicely <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: c#">
public partial class DataClassesDataContext
{
    public override void SubmitChanges(ConflictMode failureMode)
    {
        // Get the entities that are to be inserted / updated / deleted
        ChangeSet changeSet = GetChangeSet();

        // Get a single list of all the entities in the change set
        IEnumerable&lt;object&gt; changeSetEntities = changeSet.Deletes;
        changeSetEntities = changeSetEntities.Union(changeSet.Inserts);
        changeSetEntities = changeSetEntities.Union(changeSet.Updates);

        // Get a single list of all the enitities that inherit from EntityBase
        IEnumerable&lt;ChangeEntity&gt; entities = 
             from entity in changeSetEntities.Cast&lt;EntityBase&gt;()
             select new ChangeEntity()
             {
                 ChangeAction = 
                      changeSet.Deletes.Contains(entity) ? ChangeAction.Delete
                    : changeSet.Inserts.Contains(entity) ? ChangeAction.Insert
                    : changeSet.Updates.Contains(entity) ? ChangeAction.Update
                    : ChangeAction.None,
                 Entity = entity as EntityBase
             };

        // &quot;Raise&quot; the OnSaving event for the entities 
        foreach (ChangeEntity entity in entities)
        {
            entity.Entity.OnSaving(entity.ChangeAction);
        }

        // Save the changes
        base.SubmitChanges(failureMode);

        // &quot;Raise&quot; the OnSaved event for the entities
        foreach (ChangeEntity entity in entities)
        {
            entity.Entity.OnSaved();
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/11/adding-onsaving-an-onsaved-events-to-linq-to-sql-entities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a Base Class (or Interface) to All LINQ to SQL Entities</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/11/adding-a-base-class-or-interface-to-all-linq-to-sql-entities/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/11/adding-a-base-class-or-interface-to-all-linq-to-sql-entities/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 18:09:13 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[base class]]></category>
		<category><![CDATA[DBML]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=103</guid>
		<description><![CDATA[If you need your all your LINQ to SQL entities to inherit from a base class or to implement an interface there is an easy way to do it. The first way that comes to mind for most people is &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/11/adding-a-base-class-or-interface-to-all-linq-to-sql-entities/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you need your all your LINQ to SQL entities to inherit from a base class or to implement an interface there is an easy way to do it. The first way that comes to mind for most people is to create a partial class for the entities and specify the inheritance (or interface implementation) in the partial class. While this will work it is a mission as it means you need a matching partial class for every LINQ to SQL entity in your DBML, and there is no guarantee that any new entities that are added by other team members will inherit from the base class or implement the interface.</p>
<p>There is a far simpler way to ensure that all LINQ to SQL entities inherit from a base class or implement an interface. Unfortunately there isn&#8217;t a way to do it from the LINQ to SQL designer, you need to open up the DBML file in a text editor. On the Database node simply add the attribute EntityBase along with the name of the base class or interface.</p>
<pre class="brush: xml">
&lt;Database Name=&quot;Northwind&quot; 
	Class=&quot;MyDataContext&quot; 
	xmlns=&quot;http://schemas.microsoft.com/linqtosql/dbml/2007&quot;
	EntityBase=&quot;MyEntityBase&quot;&gt;
&lt;/Database&gt;
</pre>
<p>If the base class or interface is not in the same namespace as your LINQ to SQL entities then you will need to specify the full qualified name of the base class or interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/11/adding-a-base-class-or-interface-to-all-linq-to-sql-entities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Street View Car Spotted in Midrand, Gauteng</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/10/google-street-view-car-spotted-in-midrang-gauteng/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/10/google-street-view-car-spotted-in-midrang-gauteng/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:15:25 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Google Street View]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=99</guid>
		<description><![CDATA[It looks like Google Street View is finally coming to South Africa, my dad spotted this Google car driving past his house in Midrand the other day &#8211; driving around a gated community I might add My dad managed to &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/10/google-street-view-car-spotted-in-midrang-gauteng/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>It looks like Google Street View is finally coming to South Africa, my dad spotted this Google car driving past his house in Midrand the other day &#8211; driving around a gated community I might add <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="attachment_98" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-98" title="Google Street View Car in Midrand, Gauteng, South Africa" src="http://www.davidturvey.com/blog/wp-content/2009/10/Google-Street-View-Car.jpg" alt="Google Street View Car in Midrand, Gauteng, South Africa" width="600" height="450" /><p class="wp-caption-text">Google Street View Car in Midrand, Gauteng, South Africa</p></div>
<p>My dad managed to stop the driver and have a chat with him, apparently Cape Town and Pretoria are done, and there are 4 teams working the Johannesburg area. No mention when it&#8217;s going live but I guess the driver wouldn&#8217;t know that.</p>
<p>Google Maps for South Africa has gone live though; check it out at <a href="http://maps.google.co.za/" target="_blank">http://maps.google.co.za/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/10/google-street-view-car-spotted-in-midrang-gauteng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Difference Between int.Parse() and System.Convert.ToInt32()</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/10/the-difference-between-int-parse-and-system-convert-toint32/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/10/the-difference-between-int-parse-and-system-convert-toint32/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 06:17:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[IFormatProvider]]></category>
		<category><![CDATA[int.parse]]></category>
		<category><![CDATA[NumberStyles]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[System.Convert.ToInt32]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=90</guid>
		<description><![CDATA[When you want to convert a string to an integer the two most popular approaches are to use int.Parse() or System.Convert.ToInt32(), both of which are static functions. (I’m not going to include int.TryParse(), System.Convert.ChangeType(), etc. in this discussion). Personally I &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/10/the-difference-between-int-parse-and-system-convert-toint32/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When you want to convert a string to an integer the two most popular approaches are to use <a href="http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx" target="_blank">int.Parse()</a> or <a href="http://msdn.microsoft.com/en-us/library/system.convert.toint32.aspx" target="_blank">System.Convert.ToInt32()</a>, both of which are static functions. (I’m not going to include int.TryParse(), System.Convert.ChangeType(), etc. in this discussion). Personally I always use int.Parse(), why? Well I don’t actually have a good reason; I’ve always just thought it looks cleaner.</p>
<p>So why would you choose to use one over the other? Well I guess it really depends on what you need; from my short investigation I was able to spot the following differences:</p>
<ul>
<li>Passing a null string into int.Parse() will throw an ArgumentNullException. Passing a null string into System.Convert.ToInt32() will return 0 (i.e. the default for int).</li>
<li>int.Parse() has an overload where you can pass in the NumberStyles flags enum to specify how the string should be handled. System.Convert.ToInt32() does not have this overload.</li>
<li>System.Convert.ToInt32() has an overload where you can specify the number base of the string, i.e. base 2, 8, 10, or 16.</li>
</ul>
<p>Available overloads on int:</p>
<pre class="brush: c#">
public static int Parse(string s)
public static int Parse(string s, NumberStyles style)
public static int Parse(string s, IFormatProvider provider)
public static int Parse(string s, NumberStyles style, IFormatProvider provider)
</pre>
<p>Available overloads on System.Convert (for the input type string):</p>
<pre class="brush: c#">
public static int ToInt32(string value)
public static int ToInt32(string value, IFormatProvider provider)
public static int ToInt32(string value, int fromBase)
</pre>
<p>Some other points for you:</p>
<ul>
<li>If you don’t provide the IFormatProvider both int.Parse() and Sytem.Convert.ToInt32() will retrieve the format off the CurrentCulture.</li>
<li>If you do not specify the NumberStyles for int.Parse() it will simply use NumberStyles.Integer.</li>
<li>System.Convert.ToInt32(string) and System.Convert.ToInt32(string, IFormatProvider) both call int.Parse() to do the conversion, where as System.Convert.ToInt32(string, int) calls ParseNumber.StringToInt(). This is a static internal class so you will need to use <a href='http://www.red-gate.com/products/reflector/' target='_blank'>Red Gate’s .NET Reflector</a> if you want to see it. Something interesting about this call is that it makes an internal call to a method in the CLR to do the conversion.</li>
</ul>
<p>Looking at the corresponding methods for conversion on the other types it appears they seem to work in a similar way, with the exception that System.Convert.ToDouble() and System.Convert.ToDecimal() do not provide an overload to specify the number base.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/10/the-difference-between-int-parse-and-system-convert-toint32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feeds I Follow</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/10/feeds-i-follow/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/10/feeds-i-follow/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 15:32:55 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=85</guid>
		<description><![CDATA[For those that are interested here are some of the RSS feeds for the blogs that I follow: Channel 9 Channel 9 is the MSDN video website for all things dev related. dotnet.org.za Not a create site and most of &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/10/feeds-i-follow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For those that are interested here are some of the RSS feeds for the blogs that I follow: </p>
<ul>
<li>
		<a href='http://channel9.msdn.com/Feeds/RSS/' target='_blank'>Channel 9</a><br />
		Channel 9 is the MSDN video website for all things dev related.
	</li>
<li>
		<a href='http://dotnet.org.za/MainFeed.aspx' target='_blank'>dotnet.org.za</a><br />
		Not a create site and most of the blog just rehash posts from other blogs but once in a while it has something useful.
	</li>
<li>
		<a href='http://blogs.msdn.com/ericlippert/rss.xml' target='_blank'>Eric Lippert&#8217;s Fabulous Adventures In Coding</a><br />
		This is a blog I love, this guy works on the .Net Framework and posts some awesome goodies. If you want to be a good dev you should understand the framework&#8217;s internals and this blog will help with that.
	</li>
<li>
		<a href='http://www.infoq.com/' target='_blank'>InfoQ</a> (go to the site to create a custom feed)<br />
		A lot of the stuff on here is high level, you won&#8217;t find many coding examples etc. But it has some great posts and the range of articles is very broad.
	</li>
<li>
		<a href='http://blogs.msdn.com/sourceanalysis/rss.xml' target='_blank'>Microsoft StyleCop</a><br />
		This is just so that I know when StyleCop is updated.
	</li>
<li>
		<a href='http://feeds.feedburner.com/mtaulty' target='_blank'>Mike Taulty&#8217;s Blog</a><br />
		This blog pretty much focuses on SilverLight and Mike Taulty has a number of webcasts on SilverLight if you need to get going with it.
	</li>
<li>
		<a href='http://services.social.microsoft.com/feeds/feed/ArchFeaturedContent' target='_blank'>Microsoft Architecture Center</a><br />
		Just as the name says, Architecture related articles, some interesting, some boring.
	</li>
<li>
		<a href='http://www.mythicalmanmoth.com/blog/syndication.axd' target='_blank'>Mythical Man Moth</a><br />
		A blog I discovered by another South African, I haven&#8217;t gone through all his posts yet but there are some interesting ones.
	</li>
<li>
		<a href='http://www.rohland.co.za/index.php/feed/' target='_blank'>rohland.co.za</a><br />
		Another South African blog I discovered just a few days ago, I&#8217;m still going through the posts.
	</li>
</ul>
<p>Then some blogs by various developers, I&#8217;m not going to comment on them, I&#8217;m sure you probably know most of these blogs already: </p>
<ul>
<li><a href='http://feedproxy.google.com/rickstrahl' target='_blank'>Rick Strahl&#8217;s Web Log</a></li>
<li><a href='http://weblogs.asp.net/scottgu/rss.aspx' target='_blank'>Scott Gu&#8217;s Blog</a></li>
<li><a href='http://feeds.feedburner.com/ScottHanselman' target='_blank'>Scott Hanselman&#8217;s Computer Zen</a></li>
<li><a href='http://feeds.codeville.net/SteveCodeville?format=xml' target='_blank'>Steve Sanderson&#8217;s Blog</a></li>
</ul>
<p>If you&#8217;re frustrated and need a good laugh plug into this feed <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<a href='http://feeds.feedburner.com/ICanHasCheezburger' target='_blank'>ICanHasCheezburger</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/10/feeds-i-follow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to split the web.config into mutliple files</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/10/how-to-split-the-web-config-into-mutliple-files/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/10/how-to-split-the-web-config-into-mutliple-files/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 14:54:23 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Connection Strings]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=44</guid>
		<description><![CDATA[If you&#8217;ve ever experienced any pain from having to merge your web.config changes with the web.config in the live environment, or accidentially overwritten the live web.config file this may be a solution for you. You can specify that certain sections &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/10/how-to-split-the-web-config-into-mutliple-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve ever experienced any pain from having to merge your web.config changes with the web.config in the live environment, or accidentially overwritten the live web.config file this may be a solution for you. You can specify that certain sections of your web.config reside in a seperate file. So you could have a ConnectionStrings.config file containing your connection strings (for the specific environment) and a web.config file that is common across all environments.</p>
<p>To do this you simply add the attribute configSource=&#8221;ConnectionStrings.config&#8221; to the XML node you want to replace with a file, and then in the file you&#8217;ve referenced you simply place the XML that would normally have been in your web.config file. This will allow you do deploy the web.config to different environments without overriding environment specific settings.</p>
<p>Example, in the web.config:</p>
<pre class="brush: xml">
&lt;connectionStrings configSource=&quot;ConnectionStrings.config&quot; /&gt;
</pre>
<p>Then in ConnectionStrings.config:</p>
<pre class="brush: xml">
&lt;connectionStrings&gt;
    &lt;add name=&quot;ConnectionString1&quot; connectionString=&quot;server=localhost; Integrated Security=True; Database=Database1;&quot; providerName=&quot;System.Data.SqlClient&quot; /&gt;
    &lt;add name=&quot;ConnectionString2&quot; connectionString=&quot;server=localhost; Integrated Security=True; Database=Database2;&quot; providerName=&quot;System.Data.SqlClient&quot; /&gt;
&lt;/connectionStrings&gt;
</pre>
<p>Easy as that <img src='http://www.davidturvey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/10/how-to-split-the-web-config-into-mutliple-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install CruiseControl.NET with Subversion</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/10/install-cruisecontrol-net-with-subversion/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/10/install-cruisecontrol-net-with-subversion/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 08:00:37 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[CruiseControl.NET]]></category>
		<category><![CDATA[Slik SVN]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=31</guid>
		<description><![CDATA[There are a number of blog posts online describing how to configure Cruise Control .NET with SubVersion, none of them worked for me when I followed them, I had to tweak the desribed steps a little. Below are the steps &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/10/install-cruisecontrol-net-with-subversion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>There are a number of blog posts online describing how to configure Cruise Control .NET with SubVersion, none of them worked for me when I followed them, I had to tweak the desribed steps a little. Below are the steps I followed to install Cruise Control .NET with Subversion. </p>
<p><b>Required Software</b></p>
<ul>
<li><a href='http://sourceforge.net/projects/ccnet/files/' target='_blank'>Cruise Control .NET</a></li>
<li><a href='http://www.sliksvn.com/en/download' target='_blank'>Subversion Console Client (e.g. Slik SVN)</a></li>
<li>Microsoft IIS</li>
<li>Microsoft Visual Studio 2008</li>
</ul>
<p><b>Setup</b></p>
<ul>
<li>Make sure all of the required software is installed.</li>
<li>Create the folder _Projects and bind it to the Subversion repository and perform an update.</li>
<li>Modify the PATH environment variable to include the path to the folder<br />
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE </p>
<ul>
<li>Control Panel</li>
<li>System</li>
<li>Advanced Tab</li>
<li>Environment Variables</li>
</ul>
</li>
<li>Check that the virtual directory http://localhost/ccnet exists, if not then create it and point it to the folder C:\Program Files\CruiseControl.NET\WebDashboard</li>
<li>Check that the service Cruise Control .NET Service is installed and running.</li>
</ul>
<p><b>Cruise Control .NET Configuration</b></p>
<ul>
<li>Open the file C:\Program Files\CruiseControl.NET\Server\ccnet.config in a text editor. This file contains the settings for the different projects that will be monitored, the basic structure is as follows:
<pre class="brush: xml">
&lt;project&gt;
    &lt;workingDirectory /&gt; 
    &lt;triggers /&gt;
    &lt;sourcecontrol /&gt; 
    &lt;tasks /&gt; 
&lt;/project&gt; 
</pre>
</li>
<li>Project Node: The project node just requires an attribute name with the name of the project.
<pre class="brush: xml">
&lt;project name=&quot;YourProject&quot;&gt;&lt;/project&gt; 
</pre>
</li>
<li>WorkingDirectory Node: The workingDirectory node is the path to the folder where the project resides.
<pre class="brush: xml">
&lt;workingDirectory&gt;
    D:\_Projects\trunk\YourProject
&lt;/workingDirectory&gt;
</pre>
</li>
<li>Triggers Node: The triggers node simply specifies the interval Cruise Control .NET will use to poll the Subversion repository for committed files.
<pre class="brush: xml">
&lt;triggers&gt; 
    &lt;intervalTrigger seconds=&quot;60&quot; /&gt;
&lt;/triggers&gt;
</pre>
</li>
<li>SourceControl Node: The sourceControl node has the settings related to getting the source from Subversion.
<ul>
<li>The executable node is the path to the Subversion Console Client. </li>
<li>The workingDirectory node is the path to the folder where code from Subversion will be saved. </li>
<li>The trunkUrl node is the path to the project source in Subversion. </li>
<li>The autoGetSource node can always be set to true. </li>
<li>The username and password nodes are the username and password to connect to Subversion with.</li>
</ul>
<pre class="brush: xml">
&lt;sourcecontrol type=&quot;svn&quot;&gt; 
    &lt;executable&gt; 
        C:\Program Files\SlikSvn\bin\svn.exe
    &lt;/executable&gt;
    &lt;workingDirectory&gt;
        D:\_Projects\trunk\YourProject
    &lt;/workingDirectory&gt;
    &lt;trunkUrl&gt;

http://localhost:8080/svn/Repository/trunk/YourProject

    &lt;/trunkUrl&gt;
    &lt;autoGetSource&gt;true&lt;/autoGetSource&gt;
    &lt;username&gt;david.turvey&lt;/username&gt;
    &lt;password&gt;&lt;/password&gt;
&lt;/sourcecontrol&gt; 
</pre>
</li>
<li>Tasks Node: The tasks node has a node msbuild that tells Cruise Control .NET to use msbuild.exe to build the project/solution along with all the settings needed.
<ul>
<li>The executable node is the path to MSBuild.exe </li>
<li>The workingDirectory node is the path to the folder containing the project/solution. </li>
<li>The projectFile node is the filename of the project/solution file. </li>
<li>The buildArgs node contains the arguments to pass to MSBuild. </li>
<li>The timeout node contains a value in seconds for the timeout of the build. </li>
<li>The logger node is the path to ThoughtWorks.CruiseControl.MsBuild.dll </li>
</ul>
<pre class="brush: xml">
&lt;tasks&gt;
  &lt;msbuild&gt;
    &lt;executable&gt;
        C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe
    &lt;/executable&gt; 
    &lt;workingDirectory&gt; 
        D:\_Projects\trunk\YourProject 
    &lt;/workingDirectory&gt; 
    &lt;projectFile&gt;YourProject.csproj&lt;/projectFile&gt;
    &lt;buildArgs&gt;
        /noconsolelogger /p:Configuration=Debug
    &lt;/buildArgs&gt;
    &lt;targets&gt;&lt;/targets&gt;
    &lt;timeout&gt;300&lt;/timeout&gt;
    &lt;logger&gt;
        C:\Program Files\CruiseControl.NET\webdashboard
        \bin\ThoughtWorks.CruiseControl.MsBuild.dll
    &lt;/logger&gt;
  &lt;/msbuild&gt;
&lt;/tasks&gt; 
</pre>
</li>
</ul>
<p>If you browse to the Cruise Control .NET dashboard (http://localhost/ccnet) your project should be in the list, probably with a state of unknown, simply click Force Build on the right to check whether your build succeeds or fails. When someone checks in code a triggered build will occur. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/10/install-cruisecontrol-net-with-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dropping database objects with a schema</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/09/dropping-database-objects-with-a-schema/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/09/dropping-database-objects-with-a-schema/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 08:00:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Best Practises]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Schema]]></category>
		<category><![CDATA[Stored Procedures]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=26</guid>
		<description><![CDATA[This is just an FYI, I&#8217;m sure most people know about this but I thought I&#8217;d blog about it because I&#8217;ve noticed a lot of stored procedures in the database at work that don&#8217;t take the schema into account when &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/09/dropping-database-objects-with-a-schema/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is just an FYI, I&#8217;m sure most people know about this but I thought I&#8217;d blog about it because I&#8217;ve noticed a lot of stored procedures in the database at work that don&#8217;t take the schema into account when they drop the stored procedure.</p>
<p>When dropping some object from the database, e.g. a table or stored procedure, the following statement is often used:</p>
<pre class="brush: sql">
IF EXISTS (
        SELECT * 
        FROM sysobjects 
        WHERE type = &#039;P&#039; AND name = &#039;GetAlertGeographies&#039; )
BEGIN
    DROP PROCEDURE [Members].[GetAlertGeographies]
END 
GO
</pre>
<p>Now this might appear ok but it is not; the select statement that is checking the sysobjects table is not taking the schema into account. So this statement could attempt to drop the stored procedure even though it doesn&#8217;t exist because a stored procedure with the same name exists in a different schema.</p>
<p>This is the correct statement to use to take schemas into account:</p>
<pre class="brush: sql">
IF EXISTS ( 
        SELECT TOP 1 NULL 
        FROM information_schema.routines 
        WHERE specific_name = &#039;GetAlertGeographies&#039; AND specific_schema = &#039;Members&#039; )
BEGIN
    DROP PROCEDURE [Members].[GetAlertGeographies]
END 
GO
</pre>
<p>If you want to check for a table just change &#8220;routines&#8221; to &#8220;tables&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/09/dropping-database-objects-with-a-schema/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily &amp; safely disposing of objects with the C# using statement</title>
		<link>http://www.davidturvey.com/blog/index.php/2009/09/easily-safely-disposing-of-objects-with-the-c-using-statement/</link>
		<comments>http://www.davidturvey.com/blog/index.php/2009/09/easily-safely-disposing-of-objects-with-the-c-using-statement/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 11:26:36 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Best Practises]]></category>
		<category><![CDATA[finally]]></category>
		<category><![CDATA[IDisposable]]></category>
		<category><![CDATA[try]]></category>
		<category><![CDATA[using]]></category>

		<guid isPermaLink="false">http://www.davidturvey.com/blog/?p=23</guid>
		<description><![CDATA[As I&#8217;m sure everyone knows, you should always dispose of an object that you&#8217;ve created once you&#8217;re done using it. The most common way of doing this is using a try&#8230; finally block, where the object is disposed of in &#8230; <a href="http://www.davidturvey.com/blog/index.php/2009/09/easily-safely-disposing-of-objects-with-the-c-using-statement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As I&#8217;m sure everyone knows, you should always dispose of an object that you&#8217;ve created once you&#8217;re done using it. The most common way of doing this is using a try&#8230; finally block, where the object is disposed of in the finally block.<br />
While there is absolutely nothing wrong with this, there is an easier way in C#; and that is to use a using block. Basically all the using block does is call Dispose on the IDisposable interface once the object referenced at the beginning of the using statement is out of scope.</p>
<p>So here&#8217;s how you would do it with a try&#8230; finally block:</p>
<pre class="brush: c#">
bool isUnique = false;
SqlParameter[] parameters = new SqlParameter[1];
Utilities.Database database = new Utilities.Database();
SqlDataReader dataReader = null;

try
{
    parameters[0] = database.MakeInParam(&quot;@FieldName&quot;, SqlDbType.VarChar, 50, _name);
    dataReader = database.GetDataReader(&quot;Accounts.ExtraDetailsFieldExists&quot;, parameters);
    if (!dataReader.HasRows)
    {
        isUnique = true;
    }
}
finally
{
    if (dataReader != null)
    {
        dataReader.Close();
    }
    if (database != null)
    {
        database.Dispose();
    }
}

return isUnique;
</pre>
<p>And to do the same thing using the C# using block:</p>
<pre class="brush: c#">
bool isUnique = false;

using (Utilities.Database database = new Utilities.Database())
{
    SqlParameter[] parameters = new SqlParameter[1];
    parameters[0] = database.MakeInParam(&quot;@FieldName&quot;, SqlDbType.VarChar, 50, _name);
	
    using (SqlDataReader dataReader = database.GetDataReader(&quot;Accounts.ExtraDetailsFieldExists&quot;, parameters))
    {
        if (!dataReader.HasRows)
        {
            isUnique = true;
        }
    }
}

return isUnique;
</pre>
<p>Isn&#8217;t that far more readable? Far less code and its very clear where the scope of each object ends. Now I hear you shouting what about closing the data reader! Luckily for us the base class of the SqlDataReader closes the data reader when Dispose is called, and the same applies to the SqlConnection class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidturvey.com/blog/index.php/2009/09/easily-safely-disposing-of-objects-with-the-c-using-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
