<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Kevin Pelgrims</title>
	<atom:link href="http://kevinpelgrims.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kevinpelgrims.wordpress.com</link>
	<description>on .NET, PowerShell and the Web</description>
	<lastBuildDate>Fri, 20 Jan 2012 15:52:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kevinpelgrims.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/3d3154080560eeeb97dc52c1ced795bc?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Kevin Pelgrims</title>
		<link>http://kevinpelgrims.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kevinpelgrims.wordpress.com/osd.xml" title="Kevin Pelgrims" />
	<atom:link rel='hub' href='http://kevinpelgrims.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Building CoffeeScript with Sublime on Windows</title>
		<link>http://kevinpelgrims.wordpress.com/2011/12/28/building-coffeescript-with-sublime-on-windows/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/12/28/building-coffeescript-with-sublime-on-windows/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 14:15:28 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sublime]]></category>

		<guid isPermaLink="false">https://kevinpelgrims.wordpress.com/?p=330</guid>
		<description><![CDATA[As I’m looking at CoffeeScript in my spare time, I wanted a fast way to build the scripts. Since I work with Sublime Text 2 for all my scripting, it seemed like the right tool for the job. Sublime is a text editor that has a lot in common with TextMate for OS X, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=330&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I’m looking at <a href="http://coffeescript.org/">CoffeeScript</a> in my spare time, I wanted a fast way to build the scripts. Since I work with <a href="http://www.sublimetext.com/">Sublime Text 2</a> for all my scripting, it seemed like the right tool for the job.</p>
<p>Sublime is a text editor that has a lot in common with <a href="http://macromates.com/">TextMate</a> for OS X, but it has the huge advantage of working cross-platform. Sublime can also be extended using plug-ins, like TextMate, and a lot of TextMate bundles are compatible with it.</p>
<h2>Node.js</h2>
<p>Now, there are several ways to compile CoffeeScript locally (e.g. <a href="http://stackoverflow.com/questions/2879401/how-can-i-compile-coffeescript-from-net">from .NET</a> or using <a href="http://jashkenas.github.com/coffee-script/#usage">the built-in watch option</a>). We are going to use <a href="http://nodejs.org/">Node.js</a> and <a href="http://npmjs.org/">npm</a> (the Node Package Manager). Node.js works on Windows these days and the .msi installer also makes sure npm is on your system. You will need to add the folder that contains (default is <span style="font-family:'Courier New';">C:\Program Files (x86)\nodejs</span>) node.exe and npm.cmd to your environment variables to make sure you can easily run them from anywhere. Here’s a nice guide to <a href="http://www.itechtalk.com/thread3595.html">adding, removing and editing environment variables in Windows 7</a>. The normal thing to do here, is to add it to the “path” variable, if it’s not there already, feel free to create it.</p>
<h2>CoffeeScript compiler</h2>
<p>Installing the CoffeeScript compiler and Node.js tools is pretty straight forward when we open up a command window and use npm:</p>
<p><pre class="brush: plain;">
npm install coffee-script
</pre></p>
<p><span style="font-size:smaller;"><strong>Warning</strong>: be sure to open the command window on the same folder as your Node.js installation, that means where node.exe lives (default is <span style="font-family:'Courier New';">C:\Program Files (x86)\nodejs</span>). You will need to open the command windows as administrator to do this. Because npm will not use an absolute path to create new folders, but will use <span style="font-family:Courier;">./node_modules</span>. So it will create a new folder in a location you don&#8217;t want it to be if you don&#8217;t pay attention.</span></p>
<p>This installs CoffeeScript stuff for Node.js and on Windows it has a .cmd to run coffee-related stuff through Node.js automatically. The default folder for these .cmd files is <span style="font-family:Courier;">C:\Program Files (x86)\nodejs\node_modules\.bin</span> and you should add this to your environment variables too (preferably the existing “path” variable). After doing all that, you should be able to run “<span style="font-family:Courier;">coffee</span>” in your command window.</p>
<h2>CoffeeScript in Sublime</h2>
<p>To get CoffeeScript support in Sublime, we’re going to download the CoffeeScript package. First off, it’ll be useful to install Sublime Package Control, to make it easier to install packages. Detailed instructions can be found here: <a href="http://wbond.net/sublime_packages/package_control/installation">http://wbond.net/sublime_packages/package_control/installation</a></p>
<p>Now, when we restart Sublime, we can access package control through the Command Palette using <span style="font-family:Courier;">Ctrl+Shift+P</span>. As you start typing commands, you get an overview of the available options. If you execute “<span style="font-family:'Courier New';">discover packages</span>” a browser pops up giving you a nice overview of all available packages and a search bar. To install a package, we need the command “<span style="font-family:Courier;">install package</span>”. After pressing enter we get a list of all available packages. We will install “<span style="font-family:Courier;">CoffeeScript</span>”.</p>
<h2>Building it</h2>
<p>After doing all that we already have some support for the language, i.e. syntax highlighting. But building the scripts will not yet work on Windows. To fix this, click <span style="font-family:Courier;">Preferences –&gt; Browse Packages&#8230;</span> in Sublime. This will open an explorer window where you can see all the packages. Navigate to <span style="font-family:Courier;">CoffeeScript\Commands</span> and open the file <span style="font-family:Courier;">CoffeeScript.sublime-build</span>. Remove the line that has the path variable and change the cmd line to have <span style="font-family:Courier;">coffee.cmd</span> instead of <span style="font-family:Courier;">coffee</span>.</p>
<p>Original version:</p>
<p><pre class="brush: plain;">
{
&quot;path&quot;: &quot;$HOME/bin:/usr/local/bin:$PATH&quot;,
&quot;cmd&quot;: [&quot;coffee&quot;,&quot;-c&quot;,&quot;$file&quot;],
&quot;file_regex&quot;: &quot;^(...*?):([0-9]*):?([0-9]*)&quot;,
&quot;selector&quot;: &quot;source.coffee&quot;
}
</pre></p>
<p>Edited version:</p>
<p><pre class="brush: plain;">
{
&quot;cmd&quot;: [&quot;coffee.cmd&quot;,&quot;-c&quot;,&quot;$file&quot;],
&quot;file_regex&quot;: &quot;^(...*?):([0-9]*):?([0-9]*)&quot;,
&quot;selector&quot;: &quot;source.coffee&quot;
}
</pre></p>
<p>Now create a file, save it as <span style="font-family:Courier;">test.coffee</span>, add some CoffeeScript, press <span style="font-family:Courier;">Ctrl+B</span> and Sublime creates a file called <span style="font-family:Courier;">test.js</span> in the same folder.</p>
<p>CoffeeScript file:</p>
<p><pre class="brush: jscript;">
console.log &quot;Hello world!&quot;
</pre></p>
<p>JavaScript file:</p>
<p><pre class="brush: jscript;">
(function() {

console.log(&quot;Hello world!&quot;);

}).call(this);
</pre></p>
<p>You can adjust the build settings to your own needs, e.g. change the output directory or include <a href="http://www.jslint.com/">JSLint</a>. But for getting to know CoffeeScript and playing with it locally, this will work. And it makes it a lot easier! We can also for example integrate building LESS files to CSS in the same way. That would provide a uniform way of building different scripts and styles in a project and prevents us from having to use the command line to do everything manually, which would slow us down.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/330/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=330&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/12/28/building-coffeescript-with-sublime-on-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>
	</item>
		<item>
		<title>Parallel programming in .NET &#8211; PLINQ</title>
		<link>http://kevinpelgrims.wordpress.com/2011/12/22/parallel-programming-in-net-plinq/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/12/22/parallel-programming-in-net-plinq/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 11:00:14 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">https://kevinpelgrims.wordpress.com/?p=288</guid>
		<description><![CDATA[No that we&#8217;ve covered the Task Parallel Library, it&#8217;s time to move on. What is PLINQ? PLINQ stands for Parallel LINQ and is simply the parallel version of LINQ to Objects. Just like LINQ you can use it on any IEnumerable and there’s also deferred execution. Using PLINQ is even easier than using the Task [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=288&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>No that we&#8217;ve covered the <a title="Parallel programming in .NET – Task Parallel Library" href="http://kevinpelgrims.wordpress.com/2011/12/16/parallel-programming-in-net-task-parallel-library/">Task Parallel Library</a>, it&#8217;s time to move on.</p>
<h2>What is PLINQ?</h2>
<p>PLINQ stands for Parallel LINQ and is simply the parallel version of LINQ to Objects. Just like LINQ you can use it on any IEnumerable and there’s also deferred execution. Using PLINQ is even easier than using the Task Parallel Library!</p>
<div id="attachment_305" class="wp-caption alignnone" style="width: 310px"><a href="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_plinq.png"><img class="size-medium wp-image-305 " title="PLINQ" src="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_plinq.png?w=300&#038;h=129" alt="" width="300" height="129" /></a><p class="wp-caption-text">Regular for loop and LINQ compared to PLINQ (with time in seconds)</p></div>
<h2>How do we use PLINQ?</h2>
<p>You can even make existing LINQ queries parallel simply by adding the <span style="font-family:'Courier New';">AsParallel()</span> method. That’s how easy it is! This makes it easy to use the power of parallelization, while enjoying the readability of LINQ. Isn’t that great?</p>
<p><pre class="brush: csharp;">
var employees = GetEmployees();

// Regular LINQ
var query = employees.Select(e =&gt; e.Skills.Contains(&quot;C#&quot;));

// Extension method style PLINQ
var queryParallel1 = employees.AsParallel()
                              .Select(e =&gt; e.Skills.Contains(&quot;C#&quot;));

// Query expression style PLINQ
var queryParallel2 = from e in employees.AsParallel()
                     where e.Skills.Contains(&quot;C#&quot;)
                     select e;
</pre></p>
<p>Important fact: PLINQ uses all the processors of your system by default, with a maximum of 64. In some cases you might want to limit this, to give a machine some more power to take care of other tasks. Everybody deserves some CPU time! So don’t be greedy and use <span style="font-family:'Courier New';">WithDegreeOfParallelism()</span> on heavy queries. Following example uses a maximum of 3 processors, even if there are 16 available.</p>
<p><pre class="brush: csharp;">
var queryDegree = employees.AsParallel()
                           .WithDegreeOfParallelism(3)
                           .Select(e =&gt; e.Skills.Contains(&quot;C#&quot;));
</pre></p>
<p>By default PLINQ doesn’t care about the order of your output, compared to the input. This is because order preservation costs more time. You can enable order preservation though, again in a very simple way, by using the <span style="font-family:'Courier New';">AsOrdered()</span> method. It’s good to know that <span style="font-family:'Courier New';">OrderBy()</span> will also take care of order preservation.</p>
<p><pre class="brush: csharp;">
var employees = GetEmployeesOrderedByName();

var queryOrdered = employees.AsParallel()
                            .Select(e =&gt; e.Skills.Contains(&quot;C#&quot;))
                            .AsOrdered();
</pre></p>
<h2>We want more!</h2>
<p>PLINQ has a lot more to offer than what we talked about here, so be sure to use Google and MSDN if you want to know more. Check out this &#8220;old&#8221; (2007) yet interesting <a title="Running Queries On Multi-Core Processors" href="http://msdn.microsoft.com/en-us/magazine/cc163329.aspx">article on PLINQ</a> from MSDN magazine. An important read is <a href="http://msdn.microsoft.com/en-us/library/dd997399.aspx">Understanding Speedup in PLINQ on MSDN</a>, which explains a bit more of how PLINQ works and why it sometimes defaults to sequential mode anyway.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/288/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=288&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/12/22/parallel-programming-in-net-plinq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_plinq.png?w=300" medium="image">
			<media:title type="html">PLINQ</media:title>
		</media:content>
	</item>
		<item>
		<title>Parallel programming in .NET &#8211; Task Parallel Library</title>
		<link>http://kevinpelgrims.wordpress.com/2011/12/16/parallel-programming-in-net-task-parallel-library/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/12/16/parallel-programming-in-net-task-parallel-library/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 18:05:50 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">https://kevinpelgrims.wordpress.com/?p=286</guid>
		<description><![CDATA[I have talked about parallel programming in .NET before, very briefly: Parallel programming in .NET &#8211; Introduction. This follow-up post is long overdue What is the TPL? The Task Parallel Library is a set of APIs present in the System.Threading and System.Threading.Tasks namespaces. The point of these APIs is to make parallel programming easier to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=286&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have talked about parallel programming in .NET before, very briefly: <a title="Parallel programming in .NET – Introduction" href="http://kevinpelgrims.wordpress.com/2010/08/30/parallel-programming-in-net-introduction/">Parallel programming in .NET &#8211; Introduction</a>. This follow-up post is long overdue <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>What is the TPL?</h2>
<p>The Task Parallel Library is a set of APIs present in the <span style="font-family:'Courier New';">System.Threading</span> and <span style="font-family:'Courier New';">System.Threading.Tasks</span> namespaces. The point of these APIs is to make parallel programming easier to read and code. The library exposes the <span style="font-family:'Courier New';">Parallel.For</span> and <span style="font-family:'Courier New';">Parallel.ForEach</span> methods to enable parallel execution of loops and takes care of spawning and terminating threads, as well as scaling to multiple processors.</p>
<h2>How do we use the TPL?</h2>
<p>Following code uses the sequential and the parallel approach to go over a for-loop with some heavy calculations. I use the <span style="font-family:'Courier New';">StopWatch</span> class to compare the results in a command window.</p>
<p><pre class="brush: csharp;">
//Sequential
watch = new Stopwatch();
watch.Start();
for (int i = 0; i &lt; 20000; i++)
{
    SomeHeavyCalculations(i);
}
watch.Stop();
Console.WriteLine(&quot;Sequential Time: &quot; + watch.Elapsed.Seconds.ToString());

//Parallel
watch = new Stopwatch();
watch.Start();
System.Threading.Tasks.Parallel.For(0, 20000, i =&gt;
{
    SomeHeavyCalculations(i);
}
);
watch.Stop();
Console.WriteLine(&quot;Parallel Time: &quot; + watch.Elapsed.Seconds.ToString());
</pre></p>
<p>The result of running this on my laptop (with multiple cores) looks like this:</p>
<div id="attachment_309" class="wp-caption alignnone" style="width: 310px"><a href="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_comparison.png"><img class="size-medium wp-image-309 " title="Sequential vs TPL - Comparison" src="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_comparison.png?w=300&#038;h=114" alt="" width="300" height="114" /></a><p class="wp-caption-text">Result of comparison sequential - parallel</p></div>
<p>As you can see, the parallel for-loop runs A LOT faster than the sequential version. By using all the available processing power, we can speed up loops significantly!</p>
<p>Below is a screenshot of the task manager keeping track of what&#8217;s happening  while executing the sequential and the parallel. What we can see here is that at first (where the red arrow is pointing at) we only use 1 core heavily. When the parallel code kicks in, all cores peak.</p>
<div id="attachment_299" class="wp-caption alignnone" style="width: 510px"><a href="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_taskman.png"><img class="size-full wp-image-299" title="Sequential vs TPL - Task Manager" src="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_taskman.png?w=500&#038;h=140" alt="" width="500" height="140" /></a><p class="wp-caption-text">Task manager during comparison sequential - parallel</p></div>
<p>So, looking at the above code, implementing all this parallelism doesn’t seem to be that hard. The TPL makes it pretty easy to make use of all the processors in a machine.</p>
<h2>Creating and running tasks</h2>
<p>It’s possible to run a task implicitly by using the <span style="font-family:'Courier New';">Parallel.Invoke</span> method.</p>
<p><pre class="brush: csharp;">
Parallel.Invoke(() =&gt; DoSomething())
Parallel.Invoke(() =&gt; DoSomething(), () =&gt; DoSomethingElse())
</pre></p>
<p>All you need to do is pass in a delegate, using lamba expressions makes this easy. You can call a named method or have some inline code. If you want to start more tasks concurrently, you can just insert more delegates to the same <span style="font-family:'Courier New';">Parallel.Invoke</span> method.</p>
<p>If you want more control over what’s happening, you’ll need to use a Task object, though. The task object has some interesting methods and properties that we can use to control the flow of our parallel code.</p>
<p>It is possible to use <span style="font-family:'Courier New';">new Task()</span> to create a new task object, but it’s a best practice to use the task factory. (Note that you can’t use the task factory if you want to separate the creation and the scheduling of the task.)</p>
<p><pre class="brush: csharp;">
// Create a task and start it
var task1 = new Task(() =&gt; Console.WriteLine(&quot;Task1 says hi!&quot;));
task1.Start();

// Create a task using the task factory
var task1 = Task.Factory.StartNew(() =&gt; Console.WriteLine(&quot;Task1 says hi!&quot;));
</pre></p>
<p>You can also get results from a task, by accessing the <span style="font-family:'Courier New';">Result</span> property. If you access it before the task is completed, the thread will be blocked until the result is available.</p>
<p><pre class="brush: csharp;">
Task&lt;int&gt; taskreturn = Task.Factory.StartNew(() =&gt;
  {
    int calc = 3 + 3;
    return calc;
  });
int result = taskreturn.Result;
</pre></p>
<h2>To be continued..</h2>
<p>You can chain tasks by using the <span style="font-family:'Courier New';">Task.ContinueWith</span> method. It’s also possible to access the result of the preceding task in the next one, using the <span style="font-family:'Courier New';">Result</span> property.</p>
<p><pre class="brush: csharp;">
// Regular continuation
Task&lt;int&gt; task1 = Task.Factory.StartNew(() =&gt; 5);
Task&lt;string&gt; task2 = task1.ContinueWith(x =&gt; PrintInt(x.Result));

// Chained continuation
Task&lt;string&gt; task1 = Task.Factory.StartNew(() =&gt; 5)
                     .ContinueWith(x =&gt; PrintInt(x.Result));
</pre></p>
<p>The methods <span style="font-family:'Courier New';">ContinueWhenAll()</span> and <span style="font-family:'Courier New';">ContinueWhenAny()</span> make it possible to continue from multiple tasks by taking in an array of tasks to wait on and the action to be undertaken when those have finished. More about those functions can be found <a title="TaskFactory Methods" href="http://msdn.microsoft.com/en-us/library/dd321479.aspx">on MSDN</a>.</p>
<h2>The force is strong with this one</h2>
<p>We only looked at a few functions of the TPL and I think it’s clear this is a very powerful library. When working on applications that need a lot of processing power, parallel programming in .NET can make it easier to improve performance, a lot.</p>
<h2>Resources</h2>
<p>Of course there is a lot more to TPL than covered in this small introduction, so go ahead and explore!</p>
<ul>
<li>MSDN chapter on Task Parallel Library &#8211; <a href="http://msdn.microsoft.com/en-us/library/dd460717.aspx">http://msdn.microsoft.com/en-us/library/dd460717.aspx</a></li>
<li>Blog of the Parallel Extensions team &#8211; <a href="http://blogs.msdn.com/b/pfxteam/">http://blogs.msdn.com/b/pfxteam/</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/286/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=286&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/12/16/parallel-programming-in-net-task-parallel-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_comparison.png?w=300" medium="image">
			<media:title type="html">Sequential vs TPL - Comparison</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/12/parallel_net_taskman.png" medium="image">
			<media:title type="html">Sequential vs TPL - Task Manager</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit Testing Best Practices and Test Reviews with Roy Osherove</title>
		<link>http://kevinpelgrims.wordpress.com/2011/10/28/unit-testing-best-practices-and-test-reviews-with-roy-osherove/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/10/28/unit-testing-best-practices-and-test-reviews-with-roy-osherove/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 08:58:02 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">https://kevinpelgrims.wordpress.com/?p=267</guid>
		<description><![CDATA[Yesterday I attended a session on unit testing by Roy Osherove in Copenhagen. As I am trying to learn more about unit testing and TDD by applying it in a pet project, it was very interesting to see what a veteran like Roy had to say about the subject of unit testing. Also very interesting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=267&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I attended a session on unit testing by <a href="http://osherove.com/">Roy Osherove</a> in Copenhagen. As I am trying to learn more about unit testing and TDD by applying it in a pet project, it was very interesting to see what a veteran like Roy had to say about the subject of unit testing. Also very interesting was his approach in this session, as he tried to teach us about good habits by showing us bad (real world) examples.</p>
<p>He also pointed out that anyone interested in writing unit tests and working test driven should do test reviews. It can be used as a learning tool, for example test review some open source projects. But it can also be used internally almost as a replacement of code reviews, because reviewing tests takes a lot less time and should give you a good idea of what the code is supposed to do (when working test driven).</p>
<p>I took some notes during the session that I would like to share &#8211; and keep here for my own reference <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I wrote down most of his tips, so to the unit testing experts out there some of it might seem really basic. But I thought it was interesting to have it all written down.</p>
<h2>Three important words</h2>
<p>The basic, yet very important requirements for tests:</p>
<ul>
<li><strong>Readable</strong></li>
<li><strong>Maintainable</strong></li>
<li><strong>Trustworthy</strong></li>
</ul>
<h2>Unit test VS integration test</h2>
<p>Unit tests are used for testing stuff in memory. The tests don’t change and they’re static. They don’t depend on other things.</p>
<p>Integration tests would be used when there is a dependency on the filesystem, a database, a Sharepoint server, etc.</p>
<p>Unit tests and integration tests have their own testproject!</p>
<h2>Basics</h2>
<ul>
<li>Avoid test logic: too complicated
<ul>
<li>Ifs, switches, for loops, ..</li>
</ul>
</li>
<li>No multiple asserts
<ul>
<li>This can be okay when you’re asserting using the same object</li>
</ul>
</li>
<li>Avoid “magic numbers”
<ul>
<li>Using the number 42 somewhere raises the question whether it is important that the number is equal to 42; a good idea would be to use a variable with a descriptive name</li>
</ul>
</li>
<li>Don’t assert on calculations or concatenations
<ul>
<li>Assert(“user,password”, Bleh()) is better than Assert(user + “,” + password, Bleh())</li>
</ul>
</li>
<li>Don’t change or remove tests!</li>
<li>DateTime.Now (or friends like Random) –&gt; NOT okay! These values change everytime</li>
<li>Test only publics</li>
</ul>
<h2>Reuse</h2>
<ul>
<li>Factory methods (usually in the same class as the tests using them)
<ul>
<li>make_xx</li>
</ul>
</li>
<li>Configure initial state
<ul>
<li>init_xx</li>
</ul>
</li>
<li>Common tests in common methods
<ul>
<li>verify_xx</li>
</ul>
</li>
</ul>
<h2>Tests are isolated</h2>
<ul>
<li>Don’t call other tests in a test</li>
<li>No shared state, have cleanup code for shared objects</li>
</ul>
<h2>Mock != Stub (in short)</h2>
<ul>
<li>Mock = used for asserts</li>
<li>Stub = used to help the test</li>
<li>Fake = can be both</li>
</ul>
<h2>Tip</h2>
<p>If you need to test things related to a database, that would be an integration test and it’s a good idea to use the TransactionScope class in .NET so you can rollback everything when the test is done.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=267&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/10/28/unit-testing-best-practices-and-test-reviews-with-roy-osherove/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>
	</item>
		<item>
		<title>Bing Maps &#8211; Geocoding in PowerShell</title>
		<link>http://kevinpelgrims.wordpress.com/2011/08/18/bing-maps-geocoding-in-powershell/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/08/18/bing-maps-geocoding-in-powershell/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 07:29:52 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[gis]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=218</guid>
		<description><![CDATA[Since I had fun using the Bing Maps API in C# (see Bing Maps &#8211; Geocoding and Imagery), I decided to try and do the same in PowerShell. This didn&#8217;t seem to be very hard either, as it&#8217;s possible to use the same objects as you would in a regular .NET application. Go PowerShell! The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=218&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since I had fun using the Bing Maps API in C# (see <a title="Bing Maps – Geocoding and Imagery" href="http://kevinpelgrims.wordpress.com/2011/08/16/bing-maps-geocoding-and-imagery/">Bing Maps &#8211; Geocoding and Imagery</a>), I decided to try and do the same in PowerShell. This didn&#8217;t seem to be very hard either, as it&#8217;s possible to use the same objects as you would in a regular .NET application. Go PowerShell!<br />
The only difference is the web service trick on the second line.</p>
<p><pre class="brush: powershell;">
$key = &quot;apikey&quot;;
$ws = New-WebServiceProxy -uri http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl;
$wsgr = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ervice_geocodeservice_svc_wsdl.GeocodeRequest;

$wsc = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ervice_geocodeservice_svc_wsdl.Credentials;
$wsc.ApplicationId = $key;
$wsgr.Credentials = $wsc;

$wsgr.Query = 'Brussels, Belgium';
$wsr = $ws.Geocode($wsgr);

$wsr.Results[0] | select {$_.Address.FormattedAddress}, {$_.Locations[0].Longitude}, {$_.Locations[0].Latitude};
</pre></p>
<p>When you execute this in PowerShell, it looks like this:</p>
<div id="attachment_244" class="wp-caption alignnone" style="width: 510px"><a href="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_powershell2.png"><img class="size-full wp-image-244" title="Bing Maps PowerShell" src="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_powershell2.png?w=500&#038;h=153" alt="" width="500" height="153" /></a><p class="wp-caption-text">Geocoding in PowerShell</p></div>
<p>Things like this make you think about the power of PowerShell. If you can do it in .NET, you can do it in PS!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=218&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/08/18/bing-maps-geocoding-in-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_powershell2.png" medium="image">
			<media:title type="html">Bing Maps PowerShell</media:title>
		</media:content>
	</item>
		<item>
		<title>Bing Maps &#8211; Geocoding and Imagery</title>
		<link>http://kevinpelgrims.wordpress.com/2011/08/16/bing-maps-geocoding-and-imagery/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/08/16/bing-maps-geocoding-and-imagery/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 07:01:58 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[gis]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=211</guid>
		<description><![CDATA[Since I did a lot of GIS related stuff recently for work, I decided I&#8217;d have some fun with the Bing Maps API. I&#8217;ve been using Bing to display maps as a base for multiple layers of data in combination with MapGuide OS and needed to convert addresses to geocodes (coordinates). Afterwards I decided to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=211&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since I did a lot of GIS related stuff recently for work, I decided I&#8217;d have some fun with the Bing Maps API. I&#8217;ve been using Bing to display maps as a base for multiple layers of data in combination with MapGuide OS and needed to convert addresses to geocodes (coordinates). Afterwards I decided to play with it some more and I created a little app in C# that makes more use of Bing Maps.</p>
<p>If you want to <strong>get started with the Bing API</strong>, you&#8217;ll first need to <strong>get a key</strong>. More info on that can be found <a title="Bing Maps Key" href="http://msdn.microsoft.com/en-us/library/ff428642.aspx">on MSDN</a>.</p>
<p>Alright, now you got your key, let&#8217;s get started!</p>
<p>First thing you need to do to use the Bing Maps service, is <strong>adding a service reference</strong>. We&#8217;ll start out with some geocoding, so we need the geocode service. The addresses of the available services can be found <a title="Bing Maps Services" href="http://msdn.microsoft.com/en-us/library/cc966738.aspx">here</a>.</p>
<div id="attachment_233" class="wp-caption alignnone" style="width: 510px"><a href="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_servicereference.png"><img class="size-full wp-image-233" title="Bing Maps Service" src="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_servicereference.png?w=500&#038;h=404" alt="" width="500" height="404" /></a><p class="wp-caption-text">Click &quot;Add Service Reference...&quot; to open the service reference dialog</p></div>
<p>The we can use the following code to &#8220;<strong>geocode</strong>&#8221; an address (get the coordinates):</p>
<p><pre class="brush: csharp;">
private String Geocode(string address)
{
    GeocodeRequest geocodeRequest = new GeocodeRequest();

    // Set credentials using a Bing Maps key
    geocodeRequest.Credentials = new GeocodeService.Credentials();
    geocodeRequest.Credentials.ApplicationId = key;

    // Set the address
    geocodeRequest.Query = address;

    // Make the geocode request
    GeocodeServiceClient geocodeService = new GeocodeServiceClient(&quot;BasicHttpBinding_IGeocodeService&quot;);
    GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);

    return GetGeocodeResults(geocodeResponse);
}
</pre></p>
<p>GetGeocodeResults is just a function that I made to print out the response on the screen. As seen here:</p>
<div id="attachment_212" class="wp-caption alignnone" style="width: 510px"><a href="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_geocode.png"><img class="size-full wp-image-212" title="Bing Maps Geocode" src="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_geocode.png?w=500&#038;h=333" alt="" width="500" height="333" /></a><p class="wp-caption-text">Get the coordinates for an address</p></div>
<p>(There are some extra options available. You could, for example, tell the service to only return &#8220;high confidence&#8221; results. But I&#8217;m not going to talk about that here.)</p>
<p>Because getting the coordinates was so easy, I decided to also implement <strong>reverse geocoding</strong>. Which is (as you would expect) converting coordinates to an address.</p>
<p><pre class="brush: csharp;">
private String ReverseGeocode(double latitude, double longitude)
{
    ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();

    // Set credentials using a Bing Maps key
    reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
    reverseGeocodeRequest.Credentials.ApplicationId = key;

    // Set the coordinates
    reverseGeocodeRequest.Location = new BingMapsSoap.GeocodeService.GeocodeLocation() { Latitude = latitude, Longitude = longitude };

    // Make the reverse geocode request
    GeocodeServiceClient geocodeService = new GeocodeServiceClient(&quot;BasicHttpBinding_IGeocodeService&quot;);
    GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);

    return GetGeocodeResults(geocodeResponse);
}
</pre></p>
<div id="attachment_213" class="wp-caption alignnone" style="width: 510px"><a href="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_reversegeocode.png"><img class="size-full wp-image-213" title="Bing Maps Reverse Geocode" src="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_reversegeocode.png?w=500&#038;h=333" alt="" width="500" height="333" /></a><p class="wp-caption-text">Converting coordinates to addresses is easy!</p></div>
<p>After getting this far in about 15 minutes of figuring it out and coding, I couldn&#8217;t stop there! I decided to add some <strong>basic imagery</strong> for the address/coordinates that are converted. For imagery you need to <strong>add a reference</strong> to <strong>the imagery service</strong> first. Writing code for this is also pretty easy, as there are plenty of examples on MSDN that can be useful. It seems Microsoft really put some effort into  documenting this right <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><pre class="brush: csharp;">
private void GetImagery(double latitude, double longitude)
{
    MapUriRequest mapUriRequest = new MapUriRequest();

    // Set credentials using Bing Maps key
    mapUriRequest.Credentials = new ImageryService.Credentials();
    mapUriRequest.Credentials.ApplicationId = key;

    // Set the location of the image
    mapUriRequest.Center = new ImageryService.Location();
    mapUriRequest.Center.Latitude = latitude;
    mapUriRequest.Center.Longitude = longitude;

    // Set map style and zoom level
    MapUriOptions mapUriOptions = new MapUriOptions();
    mapUriOptions.Style = MapStyle.AerialWithLabels;
    mapUriOptions.ZoomLevel = 17;

    // Set size of the image to match the size of the image control
    mapUriOptions.ImageSize = new ImageryService.SizeOfint();
    mapUriOptions.ImageSize.Height = 160;
    mapUriOptions.ImageSize.Width = 160;

    mapUriRequest.Options = mapUriOptions;

    ImageryServiceClient imageryService = new ImageryServiceClient(&quot;BasicHttpBinding_IImageryService&quot;);
    MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
    BitmapImage bmpImg = new BitmapImage(new Uri(mapUriResponse.Uri));
    bingImage.Source = bmpImg;
}
</pre></p>
<p>That code gives us this result:</p>
<p><a href="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_imagery.png"><img class="alignnone size-full wp-image-214" title="Bing Maps Imagery" src="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_imagery.png?w=500&#038;h=333" alt="" width="500" height="333" /></a></p>
<p>Looks pretty good for a small app that took almost no time to make. The Bing Maps API is pretty straight-forward to work with and MSDN has some good samples to get started. So if you&#8217;re interested in working with Bing Maps, be sure to check out <a title="Bing Maps on MSDN" href="http://msdn.microsoft.com/en-us/library/dd877180.aspx">the documentation</a>.</p>
<p>Now go and have fun with this!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=211&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/08/16/bing-maps-geocoding-and-imagery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_servicereference.png" medium="image">
			<media:title type="html">Bing Maps Service</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_geocode.png" medium="image">
			<media:title type="html">Bing Maps Geocode</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_reversegeocode.png" medium="image">
			<media:title type="html">Bing Maps Reverse Geocode</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/bingapi_imagery.png" medium="image">
			<media:title type="html">Bing Maps Imagery</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell Script Commander</title>
		<link>http://kevinpelgrims.wordpress.com/2011/08/12/powershell-script-commander/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/08/12/powershell-script-commander/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 11:22:36 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=123</guid>
		<description><![CDATA[I wrote this entry last year September, but for several reasons the post and the code never made it to the interwebs. After running into it again I decided to post it anyway and upload the code to Codeplex. So, here goes! A while back I created this PowerShell script to remotely manage services (see [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=123&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>I wrote this entry last year September, but for several reasons the post and the code never made it to the interwebs. After running into it again I decided to post it anyway and upload the code to <a title="PowerShell Script Commander on Codeplex" href="http://pscommander.codeplex.com/">Codeplex</a>. So, here goes!</em></p>
<p>A while back I created this PowerShell script to remotely manage services (see <a title="PowerShell – Remote Service Manager" href="http://kevinpelgrims.wordpress.com/2010/02/24/powershell-remote-service-manager/">Remote Service Manager</a>), a bit later I made the available help a bit more professional (see <a title="Add help to your own PowerShell scripts" href="http://kevinpelgrims.wordpress.com/2010/05/10/add-help-to-your-own-powershell-scripts/">Add help to your own PowerShell scripts</a>). Now I was thinking it would be cool to create an interface in .NET for this script. So I started developing a WinForm application around the script. Initially, it looked like this:</p>
<p><a href="http://kevinpelgrims.files.wordpress.com/2010/05/remoteservicemanager.png"><img class="alignnone size-full wp-image-124" title="remoteservicemanager" src="http://kevinpelgrims.files.wordpress.com/2010/05/remoteservicemanager.png?w=500" alt=""   /></a></p>
<p>This was the first (working) prototype of the RSM-GUI. But then I started thinking it would be much cooler to create an application that can run all scripts, even those with parameters. I started thinking about how to do this and actually it didn&#8217;t seem so hard. I started by creating a form that can execute simple PowerShell commands and show the output, then added support for running scripts stored on the hard drive. For the parameters I just made sure they are all displayed in a grid, where you can give them a value by simply typing something in. And that was it! I now have a Windows application that can run scripts on a more visual way. Now you can simply load the script with an OpenFileDialog and see what parameters are available. If you still don&#8217;t fully understand how the script works, you can press the Get-Help button to display the help information in the outputbox.</p>
<p>And now, it looks like this:</p>
<div id="attachment_127" class="wp-caption alignnone" style="width: 519px"><a href="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-help.png"><img class="size-full wp-image-127" title="scriptcommander-help" src="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-help.png?w=500" alt=""   /></a><p class="wp-caption-text">PowerShell Script Commander help function</p></div>
<div id="attachment_128" class="wp-caption alignnone" style="width: 520px"><a href="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-rsm.png"><img class="size-full wp-image-128" title="scriptcommander-rsm" src="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-rsm.png?w=500" alt=""   /></a><p class="wp-caption-text">PowerShell Script Commander running the RSM script, with parameters</p></div>
<p>A lot of work needs to be done to make this more reliable and to make it work with all scripts on the planet <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  But I think it&#8217;s already pretty cool.</p>
<p>The source code can be found here: <a href="http://pscommander.codeplex.com/">http://pscommander.codeplex.com/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=123&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/08/12/powershell-script-commander/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2010/05/remoteservicemanager.png" medium="image">
			<media:title type="html">remoteservicemanager</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-help.png" medium="image">
			<media:title type="html">scriptcommander-help</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2010/05/scriptcommander-rsm.png" medium="image">
			<media:title type="html">scriptcommander-rsm</media:title>
		</media:content>
	</item>
		<item>
		<title>MapGuide OS &#8211; Failed while processing WebVirtualDirs</title>
		<link>http://kevinpelgrims.wordpress.com/2011/08/11/mapguide-os-failed-while-processing-webvirtualdirs/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/08/11/mapguide-os-failed-while-processing-webvirtualdirs/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 12:01:12 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[gis]]></category>
		<category><![CDATA[mapguide]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=198</guid>
		<description><![CDATA[When you are installing MapGuide OS and you encounter following error: Failed while processing WebVirtualDirs Fear not, because here is the solution! The problem is with how MapGuide OS is trying to install its websites. This is not configurable during the installation and will by default be installed in a website called &#8221;Default Web Site&#8221; on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=198&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you are installing MapGuide OS and you encounter following error:</p>
<p><a href="http://kevinpelgrims.files.wordpress.com/2011/08/error.png"><img class="size-thumbnail wp-image-199 alignleft" style="border-color:initial;border-style:initial;" title="Error!" src="http://kevinpelgrims.files.wordpress.com/2011/08/error.png?w=120&#038;h=120" alt="" width="120" height="120" /></a></p>
<div>
<p><strong>Failed while processing WebVirtualDirs</strong></p>
<p>Fear not, because here is the solution!</p>
</div>
<div>The problem is with how MapGuide OS is trying to install its websites. This is not configurable during the installation and will by default be installed in a website called &#8221;Default Web Site&#8221; on port 80. This is the website that is created for you when IIS is installed. If you change the name of the website or the port number, the MapGuide OS installation freaks out!</div>
<div>So the simplest solution is to <strong>create a website</strong> called <strong>&#8220;Default Web Site&#8221;</strong> and have it run at <strong>port 80</strong>. You can then <strong>edit</strong> those settings <strong>after the installation</strong> is done without any problems, so you can still run the MapGuide OS websites on a different port.</div>
<div>If you need some more explanation, this is an interesting thread <a href="http://osgeo-org.1803224.n2.nabble.com/Installation-error-td3858392.html">http://osgeo-org.1803224.n2.nabble.com/Installation-error-td3858392.html</a> with a good answer by <a title="Jason Birch's blog" href="http://www.jasonbirch.com/nodes/">Jason Birch</a>.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/198/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=198&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/08/11/mapguide-os-failed-while-processing-webvirtualdirs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/08/error.png?w=150" medium="image">
			<media:title type="html">Error!</media:title>
		</media:content>
	</item>
		<item>
		<title>MapGuide – LayerDefinitionFactory in .NET</title>
		<link>http://kevinpelgrims.wordpress.com/2011/08/09/mapguide-layerdefinitionfactory-in-net/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/08/09/mapguide-layerdefinitionfactory-in-net/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 12:29:22 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[gis]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[mapguide]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=185</guid>
		<description><![CDATA[I encountered a problem today while working on a website that uses Autodesk Infrastructure Map Server 2012 (aka MapGuide) and it&#8217;s API. To programmatically create a new layer on a map it seems to be recommended to use the LayerDefinitionFactory that is provided with the installation of the server. Now the problem is that this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=185&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://kevinpelgrims.files.wordpress.com/2011/07/autodeskinfrastructuremapserver.png"><img class="alignleft size-thumbnail wp-image-172" style="margin-left:5px;margin-right:5px;" title="Autodesk Infrastructure Map Server" src="http://kevinpelgrims.files.wordpress.com/2011/07/autodeskinfrastructuremapserver.png?w=119&#038;h=150" alt="Autodesk Infrastructure Map Server logo" width="119" height="150" /></a>I encountered a problem today while working on a website that uses Autodesk Infrastructure Map Server 2012 (aka MapGuide) and it&#8217;s API. To programmatically create a new layer on a map it seems to be recommended to use the LayerDefinitionFactory that is provided with the installation of the server. Now the problem is that this factory is only provided in PHP and I am working in C#. I could install PHP on the server and try to get all freaky with .NET-PHP communication. But it seemed easier to just port the factory to C# (it&#8217;s not that big anyway).</p>
<p>I wrote some basic functions and then only converted the stuff I need for this particular project, but it should be very easy to convert the other functions when you need them. I did not rewrite the <span style="font-family:Courier New;">sprintf()</span> function that can be found in PHP, because it is a lot easier to use <span style="font-family:Courier New;">String.Format()</span> if you adjust the template files. So, this is what one of the templates now look like after changing all the occurrences of <span style="font-family:Courier New;">%s</span> to the C# version with <span style="font-family:Courier New;">{0}</span>, <span style="font-family:Courier New;">{1}</span>, etc.:</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;LayerDefinition xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;LayerDefinition-2.3.0.xsd&quot; version=&quot;2.3.0&quot;&gt;
  &lt;VectorLayerDefinition&gt;
    &lt;ResourceId&gt;{0}&lt;/ResourceId&gt;
    &lt;FeatureName&gt;{1}&lt;/FeatureName&gt;
    &lt;FeatureNameType&gt;FeatureClass&lt;/FeatureNameType&gt;
    &lt;Geometry&gt;{2}&lt;/Geometry&gt;
    {3}
  &lt;/VectorLayerDefinition&gt;
&lt;/LayerDefinition&gt;
</pre></p>
<p>And here is the code:</p>
<p><pre class="brush: csharp;">
using System;
using System.Text;
using System.IO;

/// &lt;summary&gt;
/// Factory for MapGuide layer definitions.
/// &lt;/summary&gt;
public class LayerDefinitionFactory
{
	string templatePath;

	public LayerDefinitionFactory(string path)
	{
		templatePath = String.Concat(path, &quot;{0}.templ&quot;);
	}

	/// &lt;summary&gt;
	/// Read the template required for the layer definition.
	/// &lt;/summary&gt;
	/// &lt;returns&gt;Returns (a part of) the layer definition in XML.&lt;/returns&gt;
	private string ReadTemplate(string filename)
	{
		StreamReader reader = new StreamReader(String.Format(templatePath, filename));
		string templateDefinition = reader.ReadToEnd();
		reader.Close();
		return templateDefinition;
	}

	/// &lt;summary&gt;
	/// Create a new layerdefinition.
	/// &lt;/summary&gt;
	public string CreateLayerDefinition(string resourceId, string featureClass, string geometry, string featureClassRange)
	{
		string[] values = new string[] { resourceId, featureClass, geometry, featureClassRange };
		return String.Format(ReadTemplate(&quot;layerdefinition&quot;), values);
	}

	/// &lt;summary&gt;
	/// Create a new line rule for the layer definition.
	/// &lt;/summary&gt;
	public string CreateLineRule(string lineStyle, string thickness, string color)
	{
		string[] values = new string[] { lineStyle, thickness, color };
		return String.Format(ReadTemplate(&quot;linerule&quot;), values);
	}

	/// &lt;summary&gt;
	/// Create the line type style with line rules for the layer definition.
	/// &lt;/summary&gt;
	public string CreateLineTypeStyle(string lineRules)
	{
		string[] values = new string[] { lineRules };
		return String.Format(ReadTemplate(&quot;linetypestyle&quot;), values);
	}

	/// &lt;summary&gt;
	/// Create the scale range for the layer definition.
	/// &lt;/summary&gt;
	public string CreateScaleRange(string minScale, string maxScale, string typeStyle)
	{
		string[] values = new string[] { minScale, maxScale, typeStyle };
		return String.Format(ReadTemplate(&quot;scalerange&quot;), values);
	}
}</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=185&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/08/09/mapguide-layerdefinitionfactory-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>

		<media:content url="http://kevinpelgrims.files.wordpress.com/2011/07/autodeskinfrastructuremapserver.png?w=119" medium="image">
			<media:title type="html">Autodesk Infrastructure Map Server</media:title>
		</media:content>
	</item>
		<item>
		<title>Cool tool &#8211; Neptune (SMTP Testing Server)</title>
		<link>http://kevinpelgrims.wordpress.com/2011/05/12/cool-tool-neptune-smtp-testing-server/</link>
		<comments>http://kevinpelgrims.wordpress.com/2011/05/12/cool-tool-neptune-smtp-testing-server/#comments</comments>
		<pubDate>Thu, 12 May 2011 21:28:09 +0000</pubDate>
		<dc:creator>kevinpelgrims</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://kevinpelgrims.wordpress.com/?p=145</guid>
		<description><![CDATA[Testing e-mails sent from .NET code It&#8217;s always a big hassle to test sending e-mails from websites or applications written in .NET (or any other platform/language). Your inbox gets flooded or even worse, customers&#8217; inboxes get flooded. Or you&#8217;ve set up a dummy account to test if e-mails get sent. But sometimes e-mail addresses need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=145&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Testing e-mails sent from .NET code</h2>
<p>It&#8217;s always a big hassle to test sending e-mails from websites or applications written in .NET (or any other platform/language). Your inbox gets flooded or even worse, customers&#8217; inboxes get flooded. Or you&#8217;ve set up a dummy account to test if e-mails get sent. But sometimes e-mail addresses need to be picked up dynamically depending on certain parameters, from a database, for example. Testing gets annoying here. You can debug and check if the address you want is the right one, you can bother people to check their inbox everytime you&#8217;re testing, ..</p>
<p>There has to be a better solution, right? Yes there is!</p>
<h2>Developers, let&#8217;s start testing!</h2>
<p>Thanks to this little tool I found last week, this has become a lot easier. It&#8217;s actually been around for about 2,5 years already. Too bad I never found out about it earlier <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>UPDATE</strong>:<em> Just found out about this thing, which is on CodePlex, so we can play with the code! It&#8217;s called smtp4dev and can be found here: <a href="http://smtp4dev.codeplex.com/">http://smtp4dev.codeplex.com/</a>.</em></p>
<p>Here are URLs to the 3 blogposts by Donovan Brown about the little server app:</p>
<ul>
<li><a title="Neptune" href="http://donovanbrown.com/post/Neptune.aspx">http://donovanbrown.com/post/Neptune.aspx</a></li>
<li><a title="Neptune (future features)" href="http://donovanbrown.com/post/Neptune-(future-features).aspx">http://donovanbrown.com/post/Neptune-(future-features).aspx</a></li>
<li><a title="Neptune with POP3" href="http://donovanbrown.com/post/Neptune-with-POP3.aspx">http://donovanbrown.com/post/Neptune-with-POP3.aspx</a></li>
</ul>
<p><span style="font-size:smaller;"><strong>Note: Don&#8217;t download the application from the first blogpost! The post about POP3 has the latest version.</strong></span></p>
<p>Be sure to read the documentation, it has everything you need to know about using this tool.</p>
<p>Too bad Donovan has never put this on Codeplex (or any other open source repository), because I think we can all imagine some nice features to add to this little useful thing..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kevinpelgrims.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kevinpelgrims.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kevinpelgrims.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kevinpelgrims.wordpress.com&amp;blog=10670028&amp;post=145&amp;subd=kevinpelgrims&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kevinpelgrims.wordpress.com/2011/05/12/cool-tool-neptune-smtp-testing-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/872f26792da7176d69d5add3cf0b7e25?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kevinpelgrims</media:title>
		</media:content>
	</item>
	</channel>
</rss>
