<?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>Veggerby : IBlog &#187; Code</title>
	<atom:link href="http://blog.veggerby.dk/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.veggerby.dk</link>
	<description>Low decoupling, highly incoherent</description>
	<lastBuildDate>Fri, 28 May 2010 19:47:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>OAuth for Dummies</title>
		<link>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/</link>
		<comments>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 20:40:00 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/29/oauth-for-dummies/</guid>
		<description><![CDATA[Having developed a little feature where I had to publish a Tweet to uh… Twitter, I did a checkup on how OAuth actually works. If you have the time you can go through Beginner’s Guide to OAuth, which is really excellent and was my source or introduction to OAuth. I’ll just condense it a little [...]]]></description>
			<content:encoded><![CDATA[<p>Having developed a little feature where I had to publish a Tweet to uh… <a href="http://twitter.com/">Twitter</a>, I did a checkup on how <a href="http://oauth.net/">OAuth</a> actually works. If you have the time you can go through <a href="http://hueniverse.com/oauth/">Beginner’s Guide to OAuth</a>, which is really excellent and was my source or introduction to OAuth. I’ll just condense it a little further, mostly because it is a good way to actually “get it”.</p>
<h2>What is OAuth?</h2>
<p><strong>OAUth makes it possible for providers to communicate in a secure and authenticated manor, without needing to share user secrets (username/password).</strong> For example it can allow the users of my web application to post Tweets to their Twitter account without needing to specify their username and password (except if the need to login to the Twitter site).</p>
<h2>Who is involved?</h2>
<p>Just to set the scene and get into the terms used, the actors involved are:</p>
<p>We want to get access to the <strong>Service Provider</strong>, e.g. Twitter.</p>
<p>The <strong>Consumer </strong>would like to access a resource on the Service Provider, e.g. my application.</p>
<p>The <strong>User</strong> want to access a resource on the Service Provider via the Consumer, e.g. post a Tweet using my application.</p>
<h2>How does it work?</h2>
<p>Seen from a larger perspective the idea is that the 3 actors (the Service Provider, the Consumer and the User) communicate with each other in such a way that all agree on who is who.</p>
<p>In more technical terms, all 3 actors generates and present various tokens (share secrets) to each other, which when combined establishes a trusted relationship between the Consumer and the Service Provider on behalf of the User.</p>
<h3>Step-by-Step</h3>
<p>A User want to perform an action on the Consumer which requires access to the/a protected resource on the Service Provider, e.g. create a Tweet.</p>
<ol>
<li>The Consumer contacts the Service Provider, requesting a <strong>Request Token</strong> and a <strong>Request Secret</strong>. </li>
<li>The User (e.g. his/her browser) is then redirected to the Service Provider presenting the <strong>Request Token</strong>. </li>
<li>The Service Provider validates the user and request approval from the User that the Consumer (found via the <strong>Request Token</strong>) can access the User’s protected resource. </li>
<li>The Service Provider generates an <strong>Access Token</strong> and an <strong>Access Secret</strong>. </li>
<li>The User (e.g. his/her browser) is then redirected to the Consumer, presenting the <strong>Access Token</strong> (the <strong>Access Secret</strong> is kept um… secret). </li>
<li>The Consumer now takes the <strong>Access Token</strong> and the <strong>Request Secret</strong> and asks the Service Provider for the <strong>Access Secret</strong>. </li>
<li>Once the Consumer has the <strong>Access Token</strong> and the <strong>Access Secret</strong>, it can access the protected resource. </li>
</ol>
<p>The point of presenting the <strong>Request Secret</strong> to the Service Provider in step 6 is so that replays cannot be performed using the <strong>Access Token</strong> alone.</p>
<p>The <strong>Tokens</strong> are used to communicate between the Consumer and the Service Provider <u>via</u> the User (his/her browser). The <strong>Secrets</strong> are kept between the Consumer and the Service Provider.</p>
<h2>Now what?</h2>
<p>Once the relationship is in place, the “real” communication can take place. This is where it gets hairy and where we’ll stop for this dummy introduction. </p>
<p>However during my implementation I found a little problem with the way .NET <a href="http://msdn.microsoft.com/en-us/library/zttxte6w.aspx">UrlEncode</a> works – it is simply not compatible with OAuth. I found an <a href="http://stackoverflow.com/questions/846487/how-to-get-uri-escapedatastring-to-comply-with-rfc-3986">implementation</a> by <a href="http://blog.nerdbank.net/">Andrew Arnott</a>, who is OAuth/OpenID aficionado and author of <a href="https://www.ohloh.net/p/dotnetopenauth/">DotNetOpenAuth</a> that does this and is <a href="http://www.faqs.org/rfcs/rfc3986.html">RFC 3986</a> compliant (it basically used the UrlEncode from .NET and then fixes what is broken):</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;summary&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// The set of characters that are unreserved in RFC 2396 but are NOT unreserved in RFC 3986.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;/summary&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> <span style="color: #0000ff">string</span>[] UriRfc3986CharsToEscape = <span style="color: #0000ff">new</span>[] { &quot;<span style="color: #8b0000">!</span>&quot;, &quot;<span style="color: #8b0000">*</span>&quot;, &quot;<span style="color: #8b0000">'</span>&quot;, &quot;<span style="color: #8b0000">(</span>&quot;, &quot;<span style="color: #8b0000">)</span>&quot; };
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;summary&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// Escapes a string according to the URI data string rules given in RFC 3986.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;/summary&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;param name=&quot;value&quot;&gt;The value to escape.&lt;/param&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;returns&gt;The escaped value.&lt;/returns&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;remarks&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// The &lt;see cref=&quot;Uri.EscapeDataString&quot;/&gt; method is &lt;i&gt;supposed&lt;/i&gt; to take on</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// RFC 3986 behavior if certain elements are present in a .config file.  Even if this</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// actually worked (which in my experiments it &lt;i&gt;doesn't&lt;/i&gt;), we can't rely on every</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// host actually having this configuration element present.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #808080">/// &lt;/remarks&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> UrlEncodeRfc3986(<span style="color: #0000ff">this</span> <span style="color: #0000ff">string</span> <span style="color: #0000ff">value</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// Start with RFC 2396 escaping by calling the .NET method to do the work.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// This MAY sometimes exhibit RFC 3986 behavior (according to the documentation).</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// If it does, the escaping we do that follows it will be a no-op since the</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// characters we search for to replace can't possibly exist in the string.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    var escaped = <span style="color: #0000ff">new</span> StringBuilder(Uri.EscapeDataString(<span style="color: #0000ff">value</span>));
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// Upgrade the escaping to RFC 3986, if necessary.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; UriRfc3986CharsToEscape.Length; i++)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        escaped.Replace(UriRfc3986CharsToEscape[i], Uri.HexEscape(UriRfc3986CharsToEscape[i][0]));
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// Return the fully-RFC3986-escaped string.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> escaped.ToString();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISO 8601/RFC 3339 Compatible Dates</title>
		<link>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/</link>
		<comments>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 15:09:00 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[ISO]]></category>
		<category><![CDATA[RFC]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/</guid>
		<description><![CDATA[There are not standard format specifiers for date that takes a date and converts it to an ISO 8601 or RFC 3339 compatible date. Here are two extension methods that does just that. public static string ToISO8601(this DateTime date) { return date.ToString(&#34;yyyy-MM-dd&#34;); } public static string ToRFC3339(this DateTime date) { return date.ToUniversalTime().ToString(&#34;yyyy-MM-ddThh:mm:ssZ&#34;); }]]></description>
			<content:encoded><![CDATA[<p>There are not standard format specifiers for date that takes a date and converts it to an <a href="http://en.wikipedia.org/wiki/ISO_8601#Dates">ISO 8601</a> or <a href="http://www.faqs.org/rfcs/rfc3339.html">RFC 3339</a> compatible date. Here are two extension methods that does just that.</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToISO8601(<span style="color: #0000ff">this</span> DateTime date)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> date.ToString(&quot;<span style="color: #8b0000">yyyy-MM-dd</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRFC3339(<span style="color: #0000ff">this</span> DateTime date)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> date.ToUniversalTime().ToString(&quot;<span style="color: #8b0000">yyyy-MM-ddThh:mm:ssZ</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating a Slug From a String</title>
		<link>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/</link>
		<comments>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 18:41:00 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Slug]]></category>
		<category><![CDATA[Unicode]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/</guid>
		<description><![CDATA[I can’t (and won’t) take full credit for this extension method. The hardcore Unicode stuff is from Michael Kaplan’s blog (jeez, he is hardcore). There is a little danish “stuff” included, for special characters æ, ø and å, which can also be written “ae”, “oe” an “aa”. public static string ToSlug(this string message) { // [...]]]></description>
			<content:encoded><![CDATA[<p>I can’t (and won’t) take full credit for this extension method. The hardcore Unicode stuff is from <a href="http://blogs.msdn.com/michkap/archive/2007/05/14/2629747.aspx">Michael Kaplan’s blog</a> (jeez, he is hardcore). There is a little danish “stuff” included, for special characters æ, ø and å, which can also be written “ae”, “oe” an “aa”.</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToSlug(<span style="color: #0000ff">this</span> <span style="color: #0000ff">string</span> message)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// replace space with -</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    message = Regex.Replace(message, @&quot;<span style="color: #8b0000">[\s/\\\.,+|_]+</span>&quot;, &quot;<span style="color: #8b0000">-</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// normalize the message </span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    message = message.Normalize(NormalizationForm.FormD);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    message = message.Replace(&quot;<span style="color: #8b0000">ø</span>&quot;, &quot;<span style="color: #8b0000">oe</span>&quot;).Replace(&quot;<span style="color: #8b0000">Ø</span>&quot;, &quot;<span style="color: #8b0000">Oe</span>&quot;).Replace(&quot;<span style="color: #8b0000">æ</span>&quot;, &quot;<span style="color: #8b0000">ae</span>&quot;).Replace(&quot;<span style="color: #8b0000">Æ</span>&quot;, &quot;<span style="color: #8b0000">Ae</span>&quot;).Replace(&quot;<span style="color: #8b0000">å</span>&quot;, &quot;<span style="color: #8b0000">aa</span>&quot;).Replace(&quot;<span style="color: #8b0000">Å</span>&quot;, &quot;<span style="color: #8b0000">Aa</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    StringBuilder result = <span style="color: #0000ff">new</span> StringBuilder();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; message.Length; i++)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(message[i]);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">if</span> (uc != UnicodeCategory.NonSpacingMark)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">            result.Append(message[i]);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> Regex.Replace(result.ToString().Normalize(NormalizationForm.FormC), @&quot;<span style="color: #8b0000">[^a-zA-Z0-9\-]</span>&quot;, &quot;<span style="color: #8b0000"></span>&quot;).ToLower();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Gravatar HtmlHelper</title>
		<link>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/</link>
		<comments>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 19:08:00 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Gravatar]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/</guid>
		<description><![CDATA[Here is a quick little URL Helper extension method to add Gravatar images/photos/avatars to your page: public static string GravatarUrl(this UrlHelper url, string email, int size) { string imageUrl = ConfigurationManager.AppSettings[&#34;DefaultGravatar&#34;]; if (imageUrl.StartsWith(&#34;~/&#34;)) { imageUrl = url.Absolute(imageUrl); } if (string.IsNullOrEmpty(email)) { return imageUrl; } string md5 = email.ToLowerInvariant().MD5(); return string.Format( &#34;http://www.gravatar.com/avatar/{0}.jpg?d={1}&#38;s={2}&#38;r=g&#34;, md5.ToLowerInvariant(), url.Encode(imageUrl), size); } [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick little <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx">URL Helper</a> extension method to add <a href="http://gravatar.com/">Gravatar</a> images/photos/avatars to your page:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> GravatarUrl(<span style="color: #0000ff">this</span> UrlHelper url, <span style="color: #0000ff">string</span> email, <span style="color: #0000ff">int</span> size)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">string</span> imageUrl = ConfigurationManager.AppSettings[&quot;<span style="color: #8b0000">DefaultGravatar</span>&quot;];
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (imageUrl.StartsWith(&quot;<span style="color: #8b0000">~/</span>&quot;))
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        imageUrl = url.Absolute(imageUrl);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (<span style="color: #0000ff">string</span>.IsNullOrEmpty(email))
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> imageUrl;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">string</span> md5 = email.ToLowerInvariant().MD5();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        &quot;<span style="color: #8b0000">http://www.gravatar.com/avatar/{0}.jpg?d={1}&amp;s={2}&amp;r=g</span>&quot;,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        md5.ToLowerInvariant(),
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        url.Encode(imageUrl),
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        size);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> GravatarUrl(<span style="color: #0000ff">this</span> UrlHelper url, <span style="color: #0000ff">string</span> email)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> url.GravatarUrl(email, 32);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
<p>It uses another custom URL Helper extension method Absolute to generate an absolute URL to a default image (based on an application relative url).</p>
<p>The Absolute extension method is similar to the ActionAbsolute method <a href="http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/">I posted earlier</a>:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 475px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> Absolute(<span style="color: #0000ff">this</span> UrlHelper url, <span style="color: #0000ff">string</span> contentUrl)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Uri(GetBaseUrl(url), url.Content(contentUrl))
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        .AbsoluteUri;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
<p>And it also used the MD5 extension method <a href="http://blog.veggerby.dk/2009/09/29/md5-extension-method/">from yesterdays post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MD5 Extension Method</title>
		<link>http://blog.veggerby.dk/2009/09/29/md5-extension-method/</link>
		<comments>http://blog.veggerby.dk/2009/09/29/md5-extension-method/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 12:38:00 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[Secure Hash]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/29/md5-extension-method/</guid>
		<description><![CDATA[A nifty little extension method that generated the MD5/SHA-1 hash of a string. These methods are a continuation of my previous post: public static string MD5(this string value) { System.Security.Cryptography.MD5 algorithm = System.Security.Cryptography.MD5.Create(); byte[] data = Encoding.ASCII.GetBytes(value); data = algorithm.ComputeHash(data); string md5 = &#34;&#34;; for (int i = 0; i &#60; data.Length; i++) { md5 [...]]]></description>
			<content:encoded><![CDATA[<p>A nifty little extension method that generated the MD5/SHA-1 hash of a string. These methods are a continuation of <a href="http://blog.veggerby.dk/2008/07/27/formsauthenticationhashpasswordforstoringinconfigfile-continued/">my previous post</a>:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> MD5(<span style="color: #0000ff">this</span> <span style="color: #0000ff">string</span> <span style="color: #0000ff">value</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    System.Security.Cryptography.MD5 algorithm =
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        System.Security.Cryptography.MD5.Create();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">byte</span>[] data = Encoding.ASCII.GetBytes(<span style="color: #0000ff">value</span>);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    data = algorithm.ComputeHash(data);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">string</span> md5 = &quot;<span style="color: #8b0000"></span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; data.Length; i++)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        md5 += data[i].ToString(&quot;<span style="color: #8b0000">x2</span>&quot;).ToLower();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> md5;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
<p>Just substitute <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx">MD5</a> for <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx">SHA1</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256.aspx">SHA256</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha384.aspx">SHA384</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha512.aspx">SHA512</a> or <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.ripemd160.aspx">RIPEMD160</a> which ever hash algorithm fits your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/29/md5-extension-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Relative Time Description</title>
		<link>http://blog.veggerby.dk/2009/09/28/relative-time-description/</link>
		<comments>http://blog.veggerby.dk/2009/09/28/relative-time-description/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 19:46:48 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Extension Methods]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/28/relative-time-description/</guid>
		<description><![CDATA[Showing an absolute date on a webpage, e.g. January 22, 2009 13:01, is of course a very normal way to do it, apart from various different date formats, it is easily read and consumed. However if the date is shown in a context where the absolute date is of little importance, but it is more [...]]]></description>
			<content:encoded><![CDATA[<p>Showing an absolute date on a webpage, e.g. January 22, 2009 13:01, is of course a very normal way to do it, apart from various different date formats, it is easily read and consumed. However if the date is shown in a context where the absolute date is of little importance, but it is more important to know if it was a long time ago, just now or maybe just in a couple of minutes, a relative and more descriptive method is better. </p>
<p>For example the date mentioned above might be described as “8 months ago”. Just by giving it a quick glance you get an idea about when this event occurred.</p>
<p>For this here are a couple of extension methods that generate this descriptive text based on a given time:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 100%; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRelativeTime(<span style="color: #0000ff">this</span> DateTime from)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    DateTime now = DateTime.Now;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> from.ToRelativeTime(now);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRelativeTime(<span style="color: #0000ff">this</span> DateTime from, <span style="color: #0000ff">bool</span> usePreAndSuffix)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    DateTime now = DateTime.Now;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> from.ToRelativeTime(now, usePreAndSuffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRelativeTime(<span style="color: #0000ff">this</span> DateTime from, DateTime to)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> from.ToRelativeTime(to, <span style="color: #0000ff">true</span>);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> ToRelativeTime(<span style="color: #0000ff">this</span> DateTime from, DateTime to, <span style="color: #0000ff">bool</span> usePreAndSuffix)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">string</span> prefix = usePreAndSuffix &amp;&amp; (from &gt; to) ? &quot;<span style="color: #8b0000">in </span>&quot; : <span style="color: #0000ff">string</span>.Empty;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">string</span> suffix = !usePreAndSuffix || (from &gt; to) ? <span style="color: #0000ff">string</span>.Empty : &quot;<span style="color: #8b0000"> ago</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// is more than 1 year?</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (from &gt; to)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        DateTime d = from;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        from = to;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        to = d;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">int</span> years = to.Year - from.Year;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> ((to.Month &lt; from.Month) || ((to.Month == from.Month) &amp;&amp; (to.Day &lt; from.Day)))
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        years--;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (years &gt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} years{2}</span>&quot;, prefix, years, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (years == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 year{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// less than 1 year, is more than 1 month?</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">int</span> months = to.Month - from.Month;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (months &lt; 0)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        months += 12;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> ((to.Day &lt; from.Day) || ((to.Day == from.Day) &amp;&amp; (to.TimeOfDay &lt; from.TimeOfDay)))
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        months--;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (months &gt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} months{2}</span>&quot;, prefix, months, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (months == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 month{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// less than 1 month, is more than 1 day/week?</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    TimeSpan diff = to - from;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (diff.Days &gt; 7)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} weeks{2}</span>&quot;, prefix, diff.Days / 7, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (diff.Days &gt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} days{2}</span>&quot;, prefix, diff.Days, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (diff.Days == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 day{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// less than 1 day, is more than 1 hour?</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (diff.Hours &gt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} hours{2}</span>&quot;, prefix, diff.Hours, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (diff.Hours == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 hour{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// less than 1 hour, is more than 1 minute?</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (diff.Minutes &gt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} minutes{2}</span>&quot;, prefix, diff.Minutes, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (diff.Minutes == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 minute{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #008000">// less than 1 minute</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">if</span> (diff.Seconds == 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}1 second{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (diff.Seconds &lt; 1)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}less than 1 second{1}</span>&quot;, prefix, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(&quot;<span style="color: #8b0000">{0}{1} seconds{2}</span>&quot;, prefix, diff.Seconds, suffix);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
<p>This can of course be optimized for localization etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/28/relative-time-description/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Temporary Stream</title>
		<link>http://blog.veggerby.dk/2008/07/28/temporary-stream/</link>
		<comments>http://blog.veggerby.dk/2008/07/28/temporary-stream/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 17:58:01 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[stream]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2008/07/28/temporary-stream/</guid>
		<description><![CDATA[Scenario: you need to store a large block of data, e.g. as the result of an XSL transformation on an XML document. Using a MemoryStream would simply kill your server/application since it would use too much memory. Using a FileStream can be a but tedious since it would require write permissions on a specific folder&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Scenario: you need to store a large block of data, e.g. as the result of an XSL transformation on an XML document. Using a <a title="MemoryStream Class" href="http://msdn2.microsoft.com/9a84386f.aspx">MemoryStream</a> would simply kill your server/application since it would use too much memory. Using a <a title="FileStream Class" href="http://msdn2.microsoft.com/y0bs3w9t.aspx">FileStream</a> can be a but tedious since it would require write permissions on a specific folder&#8230;</p>
<p>Wait, doesn&#8217;t this sound just like a temporary file, i.e. storing a file in the TEMP path. </p>
<p>Yes, it does &#8211; and a simple solution is actually just to use a FileStream with a twist:</p>
<div class="vscode"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">TempFileStream</span> : <span style="color: #2b91af">FileStream     <br /></span>{    </p>
<p>&#160;&#160;&#160; <span style="color: #0000ff">public</span> TempFileStream()    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <span style="color: #0000ff">base</span>(<span style="color: #2b91af">Path</span>.GetTempFileName(), <span style="color: #2b91af">FileMode</span>.OpenOrCreate, <span style="color: #2b91af">FileAccess</span>.ReadWrite)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160; }    </p>
<p>&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> Close()    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">base</span>.Close();    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">if</span> (<span style="color: #2b91af">File</span>.Exists(Name))    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">File</span>.Delete(Name);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160; }    </p>
<p>}</p></div>
<p>Here we simply create a new temporary file with R/W access. In the Close method of the FileStream we simply delete the file. Nice and simple and your temporary file only &quot;lives&quot; during your &quot;using&quot; statement&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2008/07/28/temporary-stream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Control Extenders</title>
		<link>http://blog.veggerby.dk/2008/01/16/drag-and-drop-control-extenders/</link>
		<comments>http://blog.veggerby.dk/2008/01/16/drag-and-drop-control-extenders/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 21:48:07 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[ASP.NET AJAX]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[control extender]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2008/01/16/drag-and-drop-control-extenders/</guid>
		<description><![CDATA[After reading Jeff Prosise&#8216;s MSDN magazine article (January 2008 edition) on Drag and Drop with ASP.NET AJAX (actually something he blogged about back in March 2007) I think the time has come to put my $0.02 on the issue. Actually it is not my $0.02 but merely a &#34;formalization&#34; of Jeff&#8217;s work. I took his [...]]]></description>
			<content:encoded><![CDATA[<p>After reading <a href="http://www.wintellect.com/cs/blogs/jprosise/">Jeff Prosise</a>&#8216;s MSDN magazine article (January 2008 edition) on <a href="http://msdn.microsoft.com/msdnmag/issues/08/01/WickedCode/default.aspx">Drag and Drop with ASP.NET AJAX</a> (actually something he <a href="http://www.wintellect.com/cs/blogs/jprosise/archive/2007/03/15/asp-net-ajax-d-d-source.aspx">blogged about</a> back in March 2007) I think the time has come to put my $0.02 on the issue. Actually it is not <u>my</u> $0.02 but merely a &quot;formalization&quot; of Jeff&#8217;s work.</p>
<p>I took his drag and drop implementation and created two <a href="http://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_ExtenderControl.aspx">control</a>&#160;<a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CreatingNewExtender.aspx">extenders</a>, namely a Drag Source extender and a Drop Target extender. I added functionality to allow specifying the key/value of a drag object (i.e. which object you are actually dragging) and a key/value on the drop target (i.e. knowing where you drop the object, e.g. if a drop target is inside a repeater).</p>
<p>Usage is extremely simple. As always simply point the DragSourceExtender and/or DropTargetExtender to an ASP.NET Server Control (this is the &quot;limitation&quot;, it must be a server side control), set the DragType, DropType, DragValue and DropValue as required and create a callback method in the OnClientDrop &quot;event handler&quot;/callback on the drop target.</p>
<p>The callback signature is:</p>
<div class="vscode"><span style="color: #008000">/// &lt;summary&gt;     <br />/// Client-side drop event handler/callback method signature      <br />/// &lt;/summary&gt;      <br />/// &lt;param name=&quot;sender&quot; type=&quot;Veggerby.DropTargetBehavior&quot; domElement=&quot;false&quot;&gt;      <br />/// The DOM element the drop is associated with      <br />/// &lt;/param&gt;      <br />/// &lt;param name=&quot;e&quot; type=&quot;Veggerby.DropEventArgs&quot; domElement=&quot;false&quot;&gt;      <br />/// EventArgs for the drop operation, includes references to DragSource and DropTarget      <br />/// &lt;/param&gt;      <br /><span style="color: #0000ff">function</span> OnClientDrop(sender, e)       <br />{      <br />}</span></div>
<p>Future enhancements could/would include allowing a service call on a successful drop, however currently this can be (easily) achieved manually in an OnClientDrop callback.</p>
<p><a href="http://blog.veggerby.dk/wp-content/uploads/2008/01/veggerbywebcontrols.zip">Download the source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2008/01/16/drag-and-drop-control-extenders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sign-up and Login in One Step Membership Provider</title>
		<link>http://blog.veggerby.dk/2007/10/15/sign-up-and-login-in-one-step-membership-provider/</link>
		<comments>http://blog.veggerby.dk/2007/10/15/sign-up-and-login-in-one-step-membership-provider/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 18:14:45 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[membership]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2007/10/15/sign-up-and-login-in-one-step-membership-provider/</guid>
		<description><![CDATA[Why has it got to be so hard? Why do you always have to go through a user creation wizard to create an account? Why just not create it as you login like they do on LibraryThing for example? Well, there is of course always two sides to a coin. The obvious reason is: spam. [...]]]></description>
			<content:encoded><![CDATA[<p>Why has it got to be so hard? Why do you always have to go through a user creation wizard to create an account? Why just not create it as you login like they do on <a href="http://www.librarything.com/">LibraryThing</a> for example?</p>
<p>Well, there is of course always two sides to a coin. The obvious reason is: spam. However all that is needed is an username to &quot;aggregate&quot; your info, then this does not really matter.</p>
<p>So here is a very simple solution to this:</p>
<p>Create a custom <a title="MembershipProvider Class" href="http://msdn2.microsoft.com/sfka4yf8.aspx">MembershipProvider</a> and in the <a title="ValidateUser Method" href="http://msdn2.microsoft.com/05d03b82.aspx">ValidateUser()</a> method first check if the user exists. If not then create the user and then validate him/her. There is of course the requirement that <a title="RequiresQuestionAndAnswer Property" href="http://msdn2.microsoft.com/yda8bsea.aspx">RequiresQuestionAndAnswer</a> and <a title="RequiresUniqueEmail Property" href="http://msdn2.microsoft.com/ms152055.aspx">RequiresUniqueEmail</a> must be false.</p>
<p>One way of doing this is to refer a standard membership provider and add some logic to the ValidateUser():</p>
<div class="vscode"><span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">bool</span> ValidateUser(<span style="color: #0000ff">string</span> username, <span style="color: #0000ff">string</span> password)     <br />{     <br />&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">if</span> (GetUser(username, <span style="color: #0000ff">false</span>) == <span style="color: #0000ff">null</span>)     <br />&#xA0;&#xA0;&#xA0; {     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #2b91af">MembershipCreateStatus</span> status = <span style="color: #2b91af">MembershipCreateStatus</span>.Success;     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #2b91af">MembershipUser</span> user = CreateUser(username, password, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">true</span>, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">out</span> status);     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">if</span> (status != <span style="color: #2b91af">MembershipCreateStatus</span>.Success)     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; {     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> <span style="color: #2b91af">ProviderException</span>(<span style="color: #0000ff">string</span>.Format(<span style="color: #a31515">&quot;Could not automatically create user: {0}&quot;</span>, status));     <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; }     <br />&#xA0;&#xA0;&#xA0; }     <br />&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">return</span> MembershipProvider.ValidateUser(username, password);     <br />}</div>
<p>Download the <a title="Membership Provider for one step sign up/login" href="http://blog.veggerby.dk/wp-content/uploads/2007/10/easysignupmembershipprovider.cs">EasyRegisterMembershipProvider here</a>.</p>
<p>To use this, download, compile and use it in Web.config:</p>
<div class="vscode"><span style="color: #0000ff">&lt;<span style="color: #a31515">membership<span style="color: #0000ff"> <span style="color: #ff0000">defaultProvider<span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">SignUpProvider</span>&quot;<span style="color: #0000ff">&gt;              <br />&lt;<span style="color: #a31515">providers<span style="color: #0000ff">&gt;                  <br />&#xA0; &lt;<span style="color: #a31515">clear<span style="color: #0000ff">/&gt;                      <br />&#xA0; &lt;<span style="color: #a31515">add<span style="color: #0000ff"> <span style="color: #ff0000">name<span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">SignUpMembershipProvider</span>&quot;<span style="color: #0000ff"> <span style="color: #ff0000">type<span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">Veggerby.Utility.EasySignUpMembershipProvider, Veggerby.Utility</span>&quot;<span style="color: #0000ff"> <span style="color: #ff0000">providerName<span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">SqlMembershipProvider</span>&quot;<span style="color: #0000ff">/&gt;                                      <br />&#xA0; &lt;<span style="color: #a31515">add<span style="color: #0000ff"> <span style="color: #ff0000">name<span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">SqlMembershipProvider</span>&quot; &#8230;<span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff"><span style="color: #ff0000"><span style="color: #0000ff">/&gt;                                                                                      <br />&lt;/<span style="color: #a31515">providers<span style="color: #0000ff">&gt;                                                                                          <br />&lt;/<span style="color: #a31515">membership<span style="color: #0000ff">&gt;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
<p> <a href="http://11011.net/software/vspaste"></a>
<p></p>
<p> <a href="http://11011.net/software/vspaste"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2007/10/15/sign-up-and-login-in-one-step-membership-provider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Live Writer Plugin for Pasting Source Code from Visual Studio</title>
		<link>http://blog.veggerby.dk/2007/09/25/windows-live-writer-plugin-for-pasting-source-code-from-visual-studio/</link>
		<comments>http://blog.veggerby.dk/2007/09/25/windows-live-writer-plugin-for-pasting-source-code-from-visual-studio/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 21:45:45 +0000</pubDate>
		<dc:creator>nosey</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[live writer]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2007/09/25/windows-live-writer-plugin-for-pasting-source-code-from-visual-studio/</guid>
		<description><![CDATA[Having been through all the plugins available on Windows Live&#x2122; Gallery for showing syntax highlighted code snippets with Windows Live Writer, I gave up: there simply did/does not exist a plugin that 1) fulfills my needs and 2) displays properly on my blog. I have tried Insert Code for Windows Live Writer, Paste from Visual [...]]]></description>
			<content:encoded><![CDATA[<p>Having been through all the plugins available on <a href="http://gallery.live.com/results.aspx?c=0&amp;bt=9&amp;pl=8&amp;st=5">Windows Live&#x2122; Gallery</a> for showing syntax highlighted code snippets with <a href="http://gallery.live.com/default.aspx?pl=8">Windows Live Writer</a>, I gave up: there simply did/does not exist a plugin that 1) fulfills my needs and 2) displays properly on my blog.</p>
<p>I have tried <a href="http://gallery.live.com/liveItemDetail.aspx?li=1f57bd9b-a692-4593-9e9e-e2962d9c0eee&amp;bt=9&amp;pl=8">Insert Code for Windows Live Writer</a>, <a href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&amp;bt=9&amp;pl=8">Paste from Visual Studio</a>, <a href="http://gallery.live.com/liveItemDetail.aspx?li=d4409446-af7f-42ec-aa20-78aa5bac4748&amp;bt=9&amp;pl=8">Code Snippet plugin for Windows Live Writer</a> and <a href="http://gallery.live.com/liveItemDetail.aspx?li=b516cc7b-cea9-497a-9d6e-f6fed9f72d29&amp;bt=9&amp;pl=8">Insert Source Code Snippet</a>. My favorite amongst those is definitely the <a href="http://gallery.live.com/liveItemDetail.aspx?li=d4409446-af7f-42ec-aa20-78aa5bac4748&amp;bt=9&amp;pl=8">Code Snippet plugin for Windows Live Writer</a>. Many of them succeeds in meeting point #1, but they <u>all</u> without exception fail point #2.</p>
<p>What goes wrong for me is that I use the &quot;Normal&quot; in Live Writer for semi-WYSIWYG-ish interface. This however makes WLW reformat code, and <u>all</u> plugins does syntax highlighting using (amongst others) a &lt;pre&gt;&lt;/pre&gt; tag. This means that all white-space is significant. However WLW does not care about this, even though, it is within a &lt;pre&gt;&lt;/pre&gt; tag, so all line breaks and space for indentation is lost.</p>
<p>What to do???</p>
<p>Being the code geek I am, why not write my own WLW plugin that fulfills my needs/requirements:</p>
<p>Allow me to copy code from Visual Studio into WLW and keep formatting</p>
<p>And so be it, behold my first WLW plugin, it is sooooooo easy.</p>
<ol>
<li>Install the <a href="http://download.microsoft.com/download/f/9/a/f9a19f2d-cec4-4a25-9b0b-eb9655ea7561/Windows%20Live%20Writer%20SDK%20(Beta).msi">Windows Live Writer SDK (beta)</a></li>
<li>Create a new class library in VS</li>
<li>Add a reference to WindowsLive.Writer.Api.dll (default is C:\Program Files\Windows Live\Writer\)</li>
<li>Create a class similar to the one below</li>
<li>Build and copy .DLL to Windows Live Writer plugin folder (default is c:\Program Files\Windows Live Writer\Plugins\)</li>
</ol>
<div class="vscode"><span style="color: #0000ff">using</span> System;    <br /><span style="color: #0000ff">using</span> System.Collections.Generic;    <br /><span style="color: #0000ff">using</span> System.Text;    <br /><span style="color: #0000ff">using</span> WindowsLive.Writer.Api;    <br /><span style="color: #0000ff">using</span> System.Windows.Forms;    </p>
<p><span style="color: #0000ff">namespace</span> Veggerby.LiveWriter.CodeSnippetPlugin    <br />{    <br />&#xA0;&#xA0;&#xA0; [<span style="color: #2b91af">WriterPlugin</span>(<span style="color: #a31515">&quot;a202a095-7d8b-4e10-8cb6-4fd51035d354&quot;</span>, <span style="color: #a31515">&quot;Paste Code from Visual Studio&quot;</span>,    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; Description = <span style="color: #a31515">&quot;Paste Code from Visual Studio&quot;</span>,    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; HasEditableOptions = <span style="color: #0000ff">false</span>,    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; Name = <span style="color: #a31515">&quot;Paste Code from Visual Studio&quot;</span>,    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; PublisherUrl = <span style="color: #a31515">&quot;http://veggerby.com/livewriter/&quot;</span>)]    <br />&#xA0;&#xA0;&#xA0; [<span style="color: #2b91af">InsertableContentSource</span>(<span style="color: #a31515">&quot;Paste Code from Visual Studio&quot;</span>)]    <br />&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">PasteCodePlugin</span> : <span style="color: #2b91af">ContentSource     <br /></span>&#xA0;&#xA0;&#xA0; {    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #2b91af">DialogResult</span> CreateContent(<span style="color: #2b91af">IWin32Window</span> dialogOwner, <span style="color: #0000ff">ref</span> <span style="color: #0000ff">string</span> newContent)    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; {    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">if</span> (<span style="color: #2b91af">Clipboard</span>.ContainsData(<span style="color: #2b91af">DataFormats</span>.Rtf))    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; {    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #2b91af">RtfToHtml</span> converter = <span style="color: #0000ff">new</span> <span style="color: #2b91af">RtfToHtml</span>();    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; converter.RtfDocument = <span style="color: #2b91af">Clipboard</span>.GetData(<span style="color: #2b91af">DataFormats</span>.Rtf) <span style="color: #0000ff">as</span> <span style="color: #0000ff">string</span>;    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; newContent = <span style="color: #0000ff">string</span>.Format(<span style="color: #a31515">&quot;&lt;div class=\&quot;vscode\&quot;&gt;{0}&lt;/div&gt;&quot;</span>, converter.ConvertToHtml());    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">return</span> <span style="color: #2b91af">DialogResult</span>.OK;    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; }    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span style="color: #0000ff">return</span> <span style="color: #2b91af">DialogResult</span>.Cancel;    <br />&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; }    </p>
<p>&#xA0;&#xA0;&#xA0; }    <br />}</div>
<p>Where the tricky part lies in taking the code from the clipboard/Visual Studio, which is formatted in RTF and transform to HTML, i.e. the RtfToHtml class.</p>
<p>Syntax highlighting is achieved using &lt;span&gt;&lt;/span&gt; tags and the style=&quot;color: #ffffff&quot; attribute, other formatting (font, etc) is done using CSS on the div.vscode class.</p>
<p>One problem remains still:</p>
<p>WLW will replace &lt;br /&gt;&lt;br /&gt; (i.e. two consecutive &lt;br /&gt; tags) with a &lt;p&gt;&lt;/p&gt; tag. This is not as such a problem, but might require a little more CSS.</p>
<p>If you are interested in the complete source code, drop me a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2007/09/25/windows-live-writer-plugin-for-pasting-source-code-from-visual-studio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
