<?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>Mattias Fagerlund&#039;s Coding Blog</title>
	<atom:link href="http://lotsacode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lotsacode.wordpress.com</link>
	<description>Stuff that I&#039;ve tried and failed at. Then tried again - and then, possibly, succeeded. And other stuff.</description>
	<lastBuildDate>Thu, 22 Dec 2011 10:41:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lotsacode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mattias Fagerlund&#039;s Coding Blog</title>
		<link>http://lotsacode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lotsacode.wordpress.com/osd.xml" title="Mattias Fagerlund&#039;s Coding Blog" />
	<atom:link rel='hub' href='http://lotsacode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Render timing-data for MVC requests</title>
		<link>http://lotsacode.wordpress.com/2011/12/22/render-timing-data-for-mvc-requests/</link>
		<comments>http://lotsacode.wordpress.com/2011/12/22/render-timing-data-for-mvc-requests/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 10:41:32 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=440</guid>
		<description><![CDATA[If you want the simplest way to compute how long your page render times are &#8211; and display them on each ASP-MVC page you render, then look no further! Place this i Global.asax.cs (this is really weird, but apparantly the mere fact that the method exists makes MVC call it &#8211; you don&#8217;t need to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=440&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>If you want the simplest way to compute how long your page render times are &#8211; and display them on each ASP-MVC page you render, then look no further!</em></p>
<p>Place this i Global.asax.cs (this is really weird, but apparantly the mere fact that the method exists makes MVC call it &#8211; you don&#8217;t need to register it or override anything. Bad form, I say)</p>
<p><pre class="brush: csharp;">
protected void Application_BeginRequest()
{
HttpContext.Current.Items[&quot;stopwatch&quot;] = Stopwatch.StartNew();
}
</pre></p>
<p>And then add this to your view (_Footer.cshml, if you&#8217;ve got it)<br />
<pre class="brush: csharp;">
@(string.Format(&quot;{0:0.000} s&quot;,((System.Diagnostics.Stopwatch)HttpContext.Current.Items[&quot;stopwatch&quot;]).ElapsedMilliseconds/1000.0))
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/440/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=440&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/12/22/render-timing-data-for-mvc-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>Why I really hate my Windows 7 Phone</title>
		<link>http://lotsacode.wordpress.com/2011/10/01/why-i-really-hate-my-windows-7-phone/</link>
		<comments>http://lotsacode.wordpress.com/2011/10/01/why-i-really-hate-my-windows-7-phone/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 15:16:08 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=431</guid>
		<description><![CDATA[A while back I replaced my ageing iPhone 3 with a Windows Phone 7, the main reason being that I wanted to develop and test Silverlight apps for it. Specifically, I wanted to deploy my flow game on the Windows Phone. Below I&#8217;ll outline why I hate my Windows 7 Phone and why I will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=431&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>A while back I replaced my ageing iPhone 3 with a Windows Phone 7, the main reason being that I wanted to develop and test Silverlight apps for it. <em>Specifically, I wanted to deploy <a title="Flow Game" href="http://www.carretera.se/flow/">my flow game</a> on the Windows Phone.</em></em></p>
<p><em><em></em>Below I&#8217;ll outline why I hate my Windows 7 Phone and why I will never recommend anyone buying one, now or in the future. </em></p>
<ul>
<li>My first major concern was that I couldn&#8217;t develop and test software on my phone &#8211; because my Windows Live account was registered in Sweden. <strong>Only developers with accounts registered in the US, Great Britain, Germany, Spain or France were actually allowed to deploy software to their phones</strong>. I have no idea why. It&#8217;s just stupid. It&#8217;s my damn phone!<br />
Eventually I was told by multiple Microsoft fanbois that this wasn&#8217;t actually a problem, all I had to do was register a fake account with a fake name and a fake american address and I&#8217;d be good to go. That&#8217;s <strong>not</strong> an acceptable solution. Only the duped would think that that is good enough.</li>
<li>The volume control for the ring-tone and the music player is the same control, raise one and you raise the other. Lower one and you lower the other. I miss <strong>all</strong> my phonecalls because I listen with the volume set to the first bar &#8211; and I never remember to turn the volume up after I&#8217;ve stopped listening to music. So the ring volume is really really really low.</li>
<li>For the longest time, map search didn&#8217;t work &#8211; when I&#8217;d search for a location that I wanted to show on the phones map, it would take me to the regular Bing search. No map.<br />
Again, I was told by Microsoft fanbois (the same ones, actually) that this wasn&#8217;t a problem, all I had to do was change my &#8220;Search Language&#8221; to English would allow me to search for locations &#8211; even in Sweden with Swedish location names. Now, why was that so completely impossible to do with swedish as the search language?</li>
<li>Microsoft charges 30% of the sale price for apps sold through their market. The only reason is that that&#8217;s how much Apple charges, and why would Microsoft charge less? I&#8217;ll tell you why;</li>
</ul>
<blockquote><p>Imagine you walk into the skaniest bar you ever saw, on the seedy edge of town where only the nightcrawlers frequent the streets. You sit down and order a beer. The bartender goes &#8220;Sure, that&#8217;ll be $20&#8243;. You go, &#8220;<strong>What? No, 20 bucks for a beer? The place is EMTPY, smelly and everyone hates you. And your beer sucks. How can the beer be $20?</strong>&#8221; The bartender replies &#8220;Well, you know that wonderfull place down the center of town that&#8217;s always packed and has a queue around the block? Where all the models hang out and love is in the air?&#8221;. You go &#8220;Sure&#8221;. The bartender goes &#8220;Well, they charge 20 bucks a beer, that&#8217;s why we charge 20 bucks a beer!&#8221;</p></blockquote>
<ul>
<li>In case my analogy above doesn&#8217;t clear, I&#8217;ll outline my arguments against microsoft charging 30% of their applications</li>
<ul>
<li>- Apple has millions of users, if I develop a product for the Apple app-store, there are millions and millions of potential customers.</li>
<li>- Microsoft Phone 7 has eight users.</li>
<li>- Microsoft is not selling the same product that apple is selling, theire marketplace is a sad joke in comparison &#8211; they should PAY developers a percentage to develop software for their phone, until the market is actually there!</li>
</ul>
<li>For the longest time, I couldn&#8217;t download software from the app-store. I could surf the web, I could download email and everything was fine and dandy, but the app store would give me no love. And the error code was a very unhelpful &#8220;The Live ID service is currently unavailable, please try again later&#8221;. I was able to track down an error code after a while, don&#8217;t ask me why, and after some googling on the error code (an 8 digit number &#8211; they&#8217;re planning for a lot of errors!) it turned out that I had to have my MMS settings correctly configured. Yeah, that makes sense. What&#8217;s MMS got to do with downloading software from the app-store?</li>
<li>And the latest insult; I want to upgrade my phone to Windows Phone 7.5, to see if I&#8217;ll hate it less, but I can&#8217;t. Remember on point one where I had to change my account to fake an american account to be able to upload software to my phone? Well, turns out I can&#8217;t use the phone on my computer anymore, becase the computer is set to swedish but my Live ID account is set to american. And we can&#8217;t have that, can we? Why not? Why can&#8217;t I access an american Live ID account from a swedish computer? What would happen if I did.</li>
</ul>
<p>I miss my days with my iPhone &#8211; I had issues with it also, but no-where near as bad as the Windows Phone 7.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/431/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=431&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/10/01/why-i-really-hate-my-windows-7-phone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Generic Type and Aliased Type to string</title>
		<link>http://lotsacode.wordpress.com/2011/09/06/c-generic-type-and-aliased-type-to-string/</link>
		<comments>http://lotsacode.wordpress.com/2011/09/06/c-generic-type-and-aliased-type-to-string/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 13:02:54 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=413</guid>
		<description><![CDATA[C# code, that uses reflection, for translating a type to a pretty class name. Solving the problem that Type.Name returns a really ugly string: typeof(int?).ToString() = System.Nullable`1[System.Int32] typeof(List&#60;string&#62;).ToString() = System.Collections.Generic.List`1[System.String]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=413&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>C# code, that uses reflection, for translating a type to a pretty class name. Solving the problem that Type.Name returns a really ugly string:</p>
<ul>
<li>typeof(int?).ToString() = System.Nullable`1[System.Int32]</li>
<li>typeof(List&lt;string&gt;).ToString() = System.Collections.Generic.List`1[System.String]</li>
</ul>
<div id="scid:9EDA38F6-AE13-4003-B74A-83E8474F528D:47a86dd0-c002-45f2-ac0e-bba625fc4d7e" class="wlWriterEditableSmartContent" style="padding:0;"><pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IdentityAudit.Utilities
{
    public static class TypePrettyName
    {
        public static bool IsSubclassOfRawGeneric(Type generic, Type toCheck)
        {
            while (toCheck != typeof(object) &amp;&amp; toCheck != null)
            {
                var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck;
                if (generic == cur)
                {
                    return true;
                }
                toCheck = toCheck.BaseType;
            }
            return false;
        }

        public static string GetTypePrettyName(Type type)
        {
            if (type.IsGenericType)
            {
                if (IsSubclassOfRawGeneric(typeof(Nullable&lt;&gt;), type))
                {
                    return GetTypePrettyName(type.GetGenericArguments()[0]) + &quot;?&quot;;
                }

                string typeName = type.Name.Remove(type.Name.IndexOf('`'));
                string args =
                    string.Join(
                        &quot;,&quot;,
                        type.GetGenericArguments().Select(arg =&gt; GetTypePrettyName(arg)));
                return typeName + &quot;            }
            else
            {
                return SimpleTypeNameUseAlias(type);
            }
        }

        public static string SimpleTypeNameUseAlias(Type type)
        {
            switch (type.Name)
            {
                case &quot;String&quot;: return &quot;string&quot;;
                case &quot;Object&quot;: return &quot;object&quot;;
                case &quot;Boolean&quot;: return &quot;bool&quot;;
                case &quot;Byte&quot;: return &quot;bool&quot;;
                case &quot;SByte&quot;: return &quot;sbyte&quot;;
                case &quot;Int16&quot;: return &quot;short&quot;;
                case &quot;UInt16&quot;: return &quot;ushort&quot;;
                case &quot;Int32&quot;: return &quot;int&quot;;
                case &quot;UInt32&quot;: return &quot;uint&quot;;
                case &quot;Int64&quot;: return &quot;long&quot;;
                case &quot;UInt64&quot;: return &quot;ulong&quot;;
                case &quot;Single&quot;: return &quot;float&quot;;
                case &quot;Double&quot;: return &quot;double&quot;;
                case &quot;Decimal&quot;: return &quot;decimal&quot;;
                case &quot;Char&quot;: return &quot;char&quot;;
                default:
                    return type.Name;
            }
        }
    }
}
</pre></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/413/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=413&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/09/06/c-generic-type-and-aliased-type-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>How to publish a Microsoft MVC app in a WordPress blog (in IIS7)</title>
		<link>http://lotsacode.wordpress.com/2011/08/28/how-to-publish-a-microsoft-mvc-app-in-a-wordpress-blog-in-iis7/</link>
		<comments>http://lotsacode.wordpress.com/2011/08/28/how-to-publish-a-microsoft-mvc-app-in-a-wordpress-blog-in-iis7/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 19:34:00 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[MVC;Wordpress;asp]]></category>

		<guid isPermaLink="false">https://lotsacode.wordpress.com/2011/08/28/how-to-publish-a-microsoft-mvc-app-in-a-wordpress-blog-in-iis7/</guid>
		<description><![CDATA[If you have a wordpress blog and you wish to publish an MVC application (or probably any other kind of asp application) as a sub-directory of the blog, this post will describe how to do it. This post assumes that You have a WordPress site hosted on a computer you control The WordPress site is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=407&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have a wordpress blog and you wish to publish an MVC application (or probably any other kind of asp application) as a sub-directory of the blog, this post will describe how to do it.</p>
<p>This post assumes that</p>
<ul>
<li>You have a WordPress site hosted on a computer you control</li>
<li>The WordPress site is hosted on a iis7</li>
<li>You wish to add the MVC app as a subdirectory to the blog</li>
</ul>
<ul>If you wish to host the blog inside the app instead of the other way around – then this post isn’t for you.</ul>
<h2>Set your application to appear in a virtual directory</h2>
<p>First, make sure that your MVC expects to be placed in a virtual directory. This doesn’t make the application deploy into a virtual directory (that’s the next step), but it makes your application use “/Verktyg” in all it’s urls.</p>
<ul>
<ul>
<li>Select the project</li>
<li>Select properties</li>
<li>Select the “Web” tab</li>
<li>Enter the name of the virtual path in the appropriate box – in this case it’s called “/Verktyg” (which means “Tools” in swedish)</li>
<li>Test your application, make sure all your links still work.</li>
</ul>
</ul>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb.png?w=717&#038;h=200" alt="image" width="717" height="200" border="0" /></a></p>
<h2>Make your application deploy to a virtual path</h2>
<p>Now you tell your application where on the IIS to deploy – both the web site and the virtual directory.</p>
<ul>
<li>Select the project</li>
<li>Select properties</li>
<li>Select the “Package/Publish Web” tab</li>
<li>Enter the name of the site and the virtual path<br />
<a href="http://lotsacode.files.wordpress.com/2011/08/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb1.png?w=544&#038;h=448" alt="image" width="544" height="448" border="0" /></a></li>
<li>Hit save</li>
</ul>
<h2>Build a deployment package</h2>
<ul>
<li>Select the project</li>
<li>Right-click on the project</li>
<li>Select the menu option “Build deployment package”</li>
<li>Copy the deployment package to the server hosting the IIS 7 server</li>
</ul>
<h2>Configure Web.config on the WordPress site</h2>
<p>You must configure the Web.config file of the blog to ignore anything that’s intended for the MVC application.</p>
<ul>
<ul>By default, the Web.config file of the wordpress site is inherited by the MVC application – that’s something that we don’t want – and that’s fixed by adding a</ul>
</ul>
<p><strong>location</strong></p>
<ul>
<ul>tag inside the configuration tag. The location tag must have the attribute “</ul>
</ul>
<p><strong>inheritInChildApplications</strong></p>
<ul>
<ul>” to false.</ul>
</ul>
<div id="scid:9EDA38F6-AE13-4003-B74A-83E8474F528D:f48b866c-d834-45c1-b0e4-e7bc943de1fb" class="wlWriterEditableSmartContent" style="padding:0;"><pre class="brush: xml;">&lt;configuration&gt;
	&lt;location inheritInChildApplications=&quot;false&quot;&gt;
		&lt;system.webServer&gt;
			&lt;rewrite&gt;
				&lt;rules&gt;
					&lt;rule name=&quot;wordpress&quot; patternSyntax=&quot;Wildcard&quot;&gt;
						&lt;match url=&quot;*&quot; negate=&quot;false&quot; /&gt;
							&lt;conditions&gt;
							&lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;true&quot; /&gt;
							&lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsDirectory&quot; negate=&quot;true&quot; /&gt;
							&lt;/conditions&gt;
						&lt;action type=&quot;Rewrite&quot; url=&quot;index.php&quot; /&gt;
					&lt;/rule&gt;
				&lt;/rules&gt;
			&lt;/rewrite&gt;
		&lt;/system.webServer&gt;
	&lt;/location&gt;
&lt;/configuration&gt;</pre></p>
</div>
<p>So locate your Web.config file &#8211; it’s stored in the same directory as the site;</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb2.png?w=161&#038;h=244" alt="image" width="161" height="244" border="0" /></a></p>
<p>And add the location tag. Remember to include the closing tag.</p>
<h2>Create and configure Virtual path on WordPress site</h2>
<p>Before we can install the app, we must make sure that IIS7 has the appropriate Virtual Path (called Verktyg in our example) and that the correct application pool is serving the requests.</p>
<ul>
<li>Create a directory for the virtual path</li>
<li>Open “Internet Information Services (IIS) Manager”</li>
<li>Select the site;<a href="http://lotsacode.files.wordpress.com/2011/08/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb3.png?w=229&#038;h=305" alt="image" width="229" height="305" border="0" /></a></li>
<li>Right-click on the site and select “Add application”<a href="http://lotsacode.files.wordpress.com/2011/08/image4.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb4.png?w=419&#038;h=230" alt="image" width="419" height="230" border="0" /></a></li>
<li>Make sure that the application pool you select  uses .NET framework 4.</li>
<li>Press ok</li>
</ul>
<h2>Install the application</h2>
<p>Now it’s time to install the application. As you copied the installation package in one of the previous steps, you should have a directory on the IIS machine that looks something like this;</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image5.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb5.png?w=187&#038;h=223" alt="image" width="187" height="223" border="0" /></a></p>
<p>Running “Seo.deploy.cmd” will install the application – I usually use the /y flag to skip the questions. Actually, for deployment convenience, I typically create two .bat files, one for copying the deployment package from the development machine and one for deploying the new code. That way I can quickly update the application.</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb6.png?w=110&#038;h=77" alt="image" width="110" height="77" border="0" /></a></p>
<p>1.copy.bat (relies on the fact that I&#8217;m using Remote Desktop to access the web server and that I&#8217;m sharing my local drives with the web server):</p>
<blockquote><p>xcopy \\tsclient\C\Dev\Seo\Seo.Web\obj\Debug\Package\*.* package /D /Y</p></blockquote>
<p>2.install.bat</p>
<blockquote><p>package\Seo.Web.deploy.cmd /y</p></blockquote>
<p>Start cmd as Administrator by right-clicking (in the start menu) and selecting “Run as administrator”</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb7.png?w=244&#038;h=66" alt="image" width="244" height="66" border="0" /></a></p>
<p>Go to the directory where you’ve stored the batch files described above and press “1” and tab – the shell will automatically suggest the 1.copy.bat file;</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image8.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb8.png?w=694&#038;h=238" alt="image" width="694" height="238" border="0" /></a></p>
<p>Press 2 and tab – the shell will automatically suggest the “2.install.bat” – it should look something like this;</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image9.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb9.png?w=597&#038;h=312" alt="image" width="597" height="312" border="0" /></a></p>
<p>If installation fails with the message below <strong>“Site ‘Default Web Site’ does not exist”</strong> then you’ve failed with the step called “Make your application deploy to a virtual path”. Make sure to build and copy a new deployment package.</p>
<p><a href="http://lotsacode.files.wordpress.com/2011/08/image10.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://lotsacode.files.wordpress.com/2011/08/image_thumb10.png?w=575&#038;h=216" alt="image" width="575" height="216" border="0" /></a></p>
<h2>Visit the site</h2>
<p>You should now be able to visit the site; like this <a title="Tools for SEO optimizing – in Swedish" href="http://seo-sokmotor-optimering.se/Verktyg/" target="_blank">Tools for SEO optimizing – in Swedish</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=407&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/08/28/how-to-publish-a-microsoft-mvc-app-in-a-wordpress-blog-in-iis7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2011/08/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Seo Tips, a re-release for Redust</title>
		<link>http://lotsacode.wordpress.com/2011/06/07/seo-tips-a-re-release-for-redust/</link>
		<comments>http://lotsacode.wordpress.com/2011/06/07/seo-tips-a-re-release-for-redust/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 08:03:24 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[seo]]></category>
		<category><![CDATA[seo tips]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=373</guid>
		<description><![CDATA[My current work is automating Seo (Search Engine Optimization) rules checking. Check out Seo-Tips &#8211; free Seo tips for your website!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=373&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My current work is automating Seo (Search Engine Optimization) rules checking. Check out <a href="http://redust.com/seo-tips">Seo-Tips &#8211; free Seo tips for your website</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/373/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=373&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/06/07/seo-tips-a-re-release-for-redust/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Reflection AttributeHelper</title>
		<link>http://lotsacode.wordpress.com/2011/04/27/c-reflectionhelper/</link>
		<comments>http://lotsacode.wordpress.com/2011/04/27/c-reflectionhelper/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 20:23:31 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">https://lotsacode.wordpress.com/2011/04/27/c-reflectionhelper/</guid>
		<description><![CDATA[AttributeHelper is a collection of methods I’ve developed to help me retrieve Attribute information for Types and methods in C# (through Reflection). I’m publishing it on my blog because it’s too small to create a CodePlex project for and it’s something I want access to from wherever I am. If you find use for it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=374&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>AttributeHelper is a collection of methods I’ve developed to help me retrieve Attribute information for Types and methods in C# (through Reflection). I’m publishing it on my blog because it’s too small to create a CodePlex project for and it’s something I want access to from wherever I am. If you find use for it too, then thats great.</p>
<p>It uses caching of attributes to speed up access, because retrieving type information is typically quite time consuming. For caching it uses a trivial Dictionary.</p>
<p>Here&#8217;s the code;</p>
<div id="scid:9EDA38F6-AE13-4003-B74A-83E8474F528D:47a86dd0-c002-45f2-ac0e-bba625fc4d7e" class="wlWriterEditableSmartContent" style="padding:0;"><pre class="brush: csharp;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Reflection;

namespace IdentityAudit.Utilities
{
    public static class AttributeHelper
    {
        private static Dictionary&lt;object, List&lt;Attribute&gt;&gt; _attributeCache = new Dictionary&lt;object, List&lt;Attribute&gt;&gt;();

        public static Dictionary&lt;object, List&lt;Attribute&gt;&gt; AttributeCache { get { return _attributeCache; } }

        // Types
        public static List&lt;Attribute&gt; GetTypeAttributes&lt;TType&gt;()
        {
            return GetTypeAttributes(typeof(TType));
        }

        public static List&lt;Attribute&gt; GetTypeAttributes(Type type)
        {
            return LockAndGetAttributes(type, tp =&gt; ((Type)tp).GetCustomAttributes(true));
        }

        public static List&lt;TAttributeType&gt; GetTypeAttributes&lt;TAttributeType&gt;(Type type, Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return
                GetTypeAttributes(type)
                    .Where&lt;Attribute, TAttributeType&gt;()
                    .Where(attr =&gt; predicate == null || predicate(attr))
                    .ToList();
        }

        public static List&lt;TAttributeType&gt; GetTypeAttributes&lt;TType, TAttributeType&gt;(Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return GetTypeAttributes(typeof(TType), predicate);
        }

        public static TAttributeType GetTypeAttribute&lt;TType, TAttributeType&gt;(Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return
                GetTypeAttribute(typeof(TType), predicate);
        }

        public static TAttributeType GetTypeAttribute&lt;TAttributeType&gt;(Type type, Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return
                GetTypeAttributes&lt;TAttributeType&gt;(type, predicate)
                    .FirstOrDefault();
        }

        public static bool HasTypeAttribute&lt;TType, TAttributeType&gt;(Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return HasTypeAttribute&lt;TAttributeType&gt;(typeof(TType), predicate);
        }

        public static bool HasTypeAttribute&lt;TAttributeType&gt;(Type type, Func&lt;TAttributeType, bool&gt; predicate = null)
        {
            return GetTypeAttribute&lt;TAttributeType&gt;(type, predicate) != null;
        }

        // Members and properties
        public static List&lt;Attribute&gt; GetMemberAttributes&lt;TType&gt;(Expression&lt;Func&lt;TType, object&gt;&gt; action)
        {
            return GetMemberAttributes(GetMember(action));
        }

        public static List&lt;TAttributeType&gt; GetMemberAttributes&lt;TType, TAttributeType&gt;(
            Expression&lt;Func&lt;TType, object&gt;&gt; action,
            Func&lt;TAttributeType, bool&gt; predicate = null)
            where TAttributeType : Attribute
        {
            return GetMemberAttributes&lt;TAttributeType&gt;(GetMember(action), predicate);
        }

        public static TAttributeType GetMemberAttribute&lt;TType, TAttributeType&gt;(
            Expression&lt;Func&lt;TType, object&gt;&gt; action,
            Func&lt;TAttributeType, bool&gt; predicate = null)
            where TAttributeType : Attribute
        {
            return GetMemberAttribute&lt;TAttributeType&gt;(GetMember(action), predicate);
        }

        public static bool HasMemberAttribute&lt;TType, TAttributeType&gt;(Expression&lt;Func&lt;TType, object&gt;&gt; action, Func&lt;TAttributeType, bool&gt; predicate = null) where TAttributeType : Attribute
        {
            return GetMemberAttribute(GetMember(action), predicate) != null;
        }

        // MemberInfo (and PropertyInfo since PropertyInfo inherits from MemberInfo)
        public static List&lt;Attribute&gt; GetMemberAttributes(this MemberInfo memberInfo)
        {
            return
                LockAndGetAttributes(memberInfo, mi =&gt; ((MemberInfo)mi).GetCustomAttributes(true));
        }

        public static List&lt;TAttributeType&gt; GetMemberAttributes&lt;TAttributeType&gt;(this MemberInfo memberInfo, Func&lt;TAttributeType, bool&gt; predicate = null) where TAttributeType : Attribute
        {
            return
                GetMemberAttributes(memberInfo)
                    .Where&lt;Attribute, TAttributeType&gt;()
                    .Where(attr =&gt; predicate == null || predicate(attr))
                    .ToList();
        }

        public static TAttributeType GetMemberAttribute&lt;TAttributeType&gt;(this MemberInfo memberInfo, Func&lt;TAttributeType, bool&gt; predicate = null) where TAttributeType : Attribute
        {
            return
                GetMemberAttributes&lt;TAttributeType&gt;(memberInfo, predicate)
                    .FirstOrDefault();
        }

        public static bool HasMemberAttribute&lt;TAttributeType&gt;(this MemberInfo memberInfo, Func&lt;TAttributeType, bool&gt; predicate = null) where TAttributeType : Attribute
        {
            return
                memberInfo.GetMemberAttribute&lt;TAttributeType&gt;(predicate) != null;
        }

        // Internal stuff
        private static IEnumerable&lt;TType&gt; Where&lt;X, TType&gt;(this IEnumerable&lt;X&gt; list)
        {
            return
                list
                    .Where(item =&gt; item is TType)
                    .Cast&lt;TType&gt;();
        }

        private static TType FirstOrDefault&lt;X, TType&gt;(this IEnumerable&lt;X&gt; list)
        {
            return
                list
                    .Where&lt;X, TType&gt;()
                    .FirstOrDefault();
        }

        private static List&lt;Attribute&gt; LockAndGetAttributes(object key, Func&lt;object, object[]&gt; retrieveValue)
        {
            return
                LockAndGet&lt;object, List&lt;Attribute&gt;&gt;(_attributeCache, key, mi =&gt; retrieveValue(mi).Cast&lt;Attribute&gt;().ToList());
        }

        // Method for thread safely executing slow method and storing the result in a dictionary
        private static TValue LockAndGet&lt;TKey, TValue&gt;(Dictionary&lt;TKey, TValue&gt; dictionary, TKey key, Func&lt;TKey, TValue&gt; retrieveValue)
        {
            TValue value = default(TValue);
            lock (dictionary)
            {
                if (dictionary.TryGetValue(key, out value))
                {
                    return value;
                }
            }

            value = retrieveValue(key);

            lock (dictionary)
            {
                if (dictionary.ContainsKey(key) == false)
                {
                    dictionary.Add(key, value);
                }

                return value;
            }
        }

        private static MemberInfo GetMember&lt;T&gt;(Expression&lt;Func&lt;T, object&gt;&gt; expression)
        {
            MemberExpression memberExpression = expression.Body as MemberExpression;

            if (memberExpression != null)
            {
                return memberExpression.Member;
            }

            UnaryExpression unaryExpression = expression.Body as UnaryExpression;

            if (unaryExpression != null)
            {
                memberExpression = unaryExpression.Operand as MemberExpression;

                if (memberExpression != null)
                {
                    return memberExpression.Member;
                }

                MethodCallExpression methodCall = unaryExpression.Operand as MethodCallExpression;
                if (methodCall != null)
                {
                    return methodCall.Method;
                }
            }

            return null;
        }
    }
}
</pre></p>
<p>And here&#8217;s a number of nunit tests;</p>
<p><pre class="brush: csharp;">
[TestFixture]
class AttributeHelperTests
{
[MyAttribute(Name = &quot;Steve&quot;)]
internal class Attributed
{
[MyAttribute(Name = &quot;Bob&quot;)]
public bool HasAttributeProperty { get; set; }
public bool HasNoAttributeProperty { get; set; }

[MyAttribute(Name = &quot;Stevie&quot;)]
public bool HasAttributeMember(int x)
{
return true;
}

public bool HasNoAttributeMember(int x)
{
return true;
}
}

internal class MyAttribute : Attribute
{
public string Name { get; set; }
}

[Test]
public void GetTypeAttributes_works()
{
Assert.That(AttributeHelper.GetTypeAttributes&lt;Attributed&gt;().Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetTypeAttributes&lt;Attributed, MyAttribute&gt;().Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetTypeAttributes&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Jane&quot;).Count, Is.EqualTo(0));
Assert.That(AttributeHelper.GetTypeAttributes&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Steve&quot;).Count, Is.EqualTo(1));
}

[Test]
public void GetTypeAttribute_works()
{
Assert.That(AttributeHelper.GetTypeAttribute&lt;Attributed, MyAttribute&gt;(), Is.Not.Null);
Assert.That(AttributeHelper.GetTypeAttribute&lt;Attributed, SequentialAttribute&gt;(), Is.Null);

Assert.That(AttributeHelper.GetTypeAttribute&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Jane&quot;), Is.Null);
Assert.That(AttributeHelper.GetTypeAttribute&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Steve&quot;), Is.Not.Null);
}

[Test]
public void HasTypeAttribute_works()
{
Assert.That(AttributeHelper.HasTypeAttribute&lt;Attributed, MyAttribute&gt;(), Is.True);
Assert.That(AttributeHelper.HasTypeAttribute&lt;Attributed, SequentialAttribute&gt;(), Is.False);

Assert.That(AttributeHelper.HasTypeAttribute&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Jane&quot;), Is.False);
Assert.That(AttributeHelper.HasTypeAttribute&lt;Attributed, MyAttribute&gt;(attr =&gt; attr.Name == &quot;Steve&quot;), Is.True);
}

[Test]
public void GetMemberAttributes_works()
{
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed&gt;(x =&gt; x.HasAttributeMember(0)).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0)).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed&gt;(x =&gt; x.HasNoAttributeMember(0)).Count, Is.EqualTo(0));

Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed&gt;(x =&gt; x.HasAttributeProperty).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeProperty).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed&gt;(x =&gt; x.HasNoAttributeProperty).Count, Is.EqualTo(0));

Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;Stevie&quot;).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;X&quot;).Count, Is.EqualTo(0));

Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeProperty, attr =&gt; attr.Name == &quot;Bob&quot;).Count, Is.EqualTo(1));
Assert.That(AttributeHelper.GetMemberAttributes&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeProperty, attr =&gt; attr.Name == &quot;X&quot;).Count, Is.EqualTo(0));
}

[Test]
public void GetMemberAttribute_works()
{
Assert.That(AttributeHelper.GetMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0)), Is.Not.Null);
Assert.That(AttributeHelper.GetMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasNoAttributeMember(0)), Is.Null);

Assert.That(AttributeHelper.GetMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;Stevie&quot;), Is.Not.Null);
Assert.That(AttributeHelper.GetMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;X&quot;), Is.Null);
}

[Test]
public void HasMemberAttribute_works()
{
Assert.That(AttributeHelper.HasMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0)), Is.True);
Assert.That(AttributeHelper.HasMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasNoAttributeMember(0)), Is.False);

Assert.That(AttributeHelper.HasMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;Stevie&quot;), Is.True);
Assert.That(AttributeHelper.HasMemberAttribute&lt;Attributed, MyAttribute&gt;(x =&gt; x.HasAttributeMember(0), attr =&gt; attr.Name == &quot;X&quot;), Is.False);
}
}
</pre></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/374/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=374&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/04/27/c-reflectionhelper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>Extract only viewable text from HTML with C#</title>
		<link>http://lotsacode.wordpress.com/2011/02/11/extract-only-viewable-text-from-html-with-c/</link>
		<comments>http://lotsacode.wordpress.com/2011/02/11/extract-only-viewable-text-from-html-with-c/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 13:08:41 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=357</guid>
		<description><![CDATA[If you need to extract the viewable text from an HTML page, you can use the code below. It uses HtmlAgilityPack. Online I&#8217;ve found other methods to extract the text, but they would delete scripts and styles from the nodes in the HtmlNode, wich is&#8217;t acceptable to me (I need them). The code also uses [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=357&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you need to extract the viewable text from an HTML page, you can use the code below. It uses <a href="http://htmlagilitypack.codeplex.com/">HtmlAgilityPack</a>.</p>
<p>Online I&#8217;ve found other methods to extract the text, but they would delete scripts and styles from the nodes in the HtmlNode, wich is&#8217;t acceptable to me (I need them).</p>
<p>The code also uses a regex to remove the repeated white-spaces that invariably when the HTML is cleand up.<br />
<pre class="brush: csharp;">
private static Regex _removeRepeatedWhitespaceRegex = new Regex(@&quot;(\s|\n|\r){2,}&quot;, RegexOptions.Singleline | RegexOptions.IgnoreCase);

[Test]
public void Extract_all_text_from_webpage()
{
 HtmlDocument document = new HtmlDocument();
 document.Load(new MemoryStream(File.ReadAllBytes(@&quot;c:\slask\bob.html&quot;)));
 Console.WriteLine(ExtractViewableTextCleaned(document.DocumentNode));
}

public static string ExtractViewableTextCleaned(HtmlNode node)
{
 string textWithLotsOfWhiteSpaces = ExtractViewableText(node);
 return _removeRepeatedWhitespaceRegex.Replace(textWithLotsOfWhiteSpaces, &quot; &quot;);
}

public static string ExtractViewableText(HtmlNode node)
{
 StringBuilder sb = new StringBuilder();
 ExtractViewableTextHelper(sb, node);
 return sb.ToString();
}

private static void ExtractViewableTextHelper(StringBuilder sb, HtmlNode node)
{
 if (node.Name != &quot;script&quot; &amp;&amp; node.Name != &quot;style&quot;)
 {
 if (node.NodeType == HtmlNodeType.Text)
 {
 AppendNodeText(sb, node);
 }

 foreach (HtmlNode child in node.ChildNodes)
 {
 ExtractViewableTextHelper(sb, child);
 }
 }
}

private static void AppendNodeText(StringBuilder sb, HtmlNode node)
{
 string text = ((HtmlTextNode)node).Text;
 if (string.IsNullOrWhiteSpace(text) == false)
 {
 sb.Append(text);

 // If the last char isn't a white-space, add a white space
 // otherwise words will be added ontop of each other when they're only separated by
 // tags
 if (text.EndsWith(&quot;\t&quot;) || text.EndsWith(&quot;\n&quot;) || text.EndsWith(&quot; &quot;) || text.EndsWith(&quot;\r&quot;))
 {
 // We're good!
 }
 else
 {
 sb.Append(&quot; &quot;);
 }
 }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/357/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=357&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/02/11/extract-only-viewable-text-from-html-with-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>Redust Site-Audit</title>
		<link>http://lotsacode.wordpress.com/2011/02/09/redust-site-audit/</link>
		<comments>http://lotsacode.wordpress.com/2011/02/09/redust-site-audit/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 18:39:00 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[search engine optimization]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[seo;search engine optimization]]></category>

		<guid isPermaLink="false">https://lotsacode.wordpress.com/2011/02/09/redust-site-audit/</guid>
		<description><![CDATA[I’m proud to announce that we’ve added a new tool to Redust called Redust Site-Audit. Redust Site-Audit is a tool that automates the process of repeatedly checking that your page is looking as good as possible to search engines. Site-Audit will help you Discover all pages on your site Scan those pages for things that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=355&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’m proud to announce that we’ve added a new tool to <a href="http://redust.com/" target="_blank">Redust</a> called <a href="http://redust.com/site-audit" target="_blank">Redust Site-Audit</a>. Redust Site-Audit is a tool that automates the process of repeatedly checking that your page is looking as good as possible to search engines. </p>
<h2>Site-Audit will help you</h2>
<ul>
<li>Discover all pages on your site </li>
<li>Scan those pages for things that will lower your SERP (Search Engine Rank Page)</li>
<li>Generate a comprehensive report of what was found on your pages </li>
<li>Sort the pages from worst to best, so you’ll know what pages to start working on.</li>
</ul>
<p><a href="http://redust.com/new-service-redust-site-audit" target="_blank">Read more about Site-Audit in this blog post</a>.</p>
<h2>Based on Redust <a href="http://redust.com/seo-rules" target="_blank">SEO-Rules</a></h2>
<p>Redust Site-Audit is based on <a href="http://redust.com/seo-rules" target="_blank">Redust SEO-Rules</a>, a tool that scans individual pages for SEO rule violations, but Site-Audit is intended for entire sites with tens of pages to thousands of pages.</p>
<p>Most importantly, Site-Audit will help you quickly and easily find violations that may harm your entire site;</p>
<ul>
<li>Verify that the page hasn’t been flagged as malware by Google
<ul>
<li>This can happen if someone hacks your site or uploads bad code in an open forum) </li>
<li>Google will drop your page from it’s search result if this happens! </li>
<li>Google may punish your entire domain if this happens </li>
<li>Google may even drop your entire domain and all pages on your site </li>
<li>Firefox will refuse to open your page </li>
</ul>
</li>
<li>Verify that the page hasn’t been flagged as phishing by Google </li>
<li>Verify that the page doesn’t link to any pages that have been flagged as malware or phishing by Google
<ul>
<li>Even if your page is clean, you’ll be guilty by association for linking </li>
<li>Google may punish the SERP for your entire domain if you link to bad pages </li>
<li>The linked page might have been safe when you added the link, but what if it’s been taken over by bad guys? How would you notice? </li>
</ul>
</li>
<li>Verify that the page doesn’t contain offensive or derogatory language – even in the source code </li>
<li>Verify that the page doesn’t contain dead links to images/pages that have been removed </li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=355&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/02/09/redust-site-audit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>Download Stock Quotes, Free, Easy and with Source Code</title>
		<link>http://lotsacode.wordpress.com/2011/02/01/download-stock-quotes-free-easy-and-with-source-code/</link>
		<comments>http://lotsacode.wordpress.com/2011/02/01/download-stock-quotes-free-easy-and-with-source-code/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 19:00:01 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[stock data]]></category>
		<category><![CDATA[c#;stock data;quotes]]></category>

		<guid isPermaLink="false">https://lotsacode.wordpress.com/?p=353</guid>
		<description><![CDATA[Every once in a while, I need stock quotes for some idea I need to try out. There are several methods for downloading quotes that cost money &#8211; but the data is freely available from&#160; Yahoo so I figured I’d use that. Turns out that 93 rows of code is enough – and that includes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=353&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Every once in a while, I need stock quotes for some idea I need to try out. There are several methods for downloading quotes that cost money &#8211; but the data is freely available from&#160; Yahoo so I figured I’d use that.</p>
<p>Turns out that 93 rows of code is enough – and that includes downloading a list of Nasdaq stock symbols.</p>
<div style="padding:0;" id="scid:9EDA38F6-AE13-4003-B74A-83E8474F528D:c1790006-5c4c-4209-b1ea-8ea0549178ae" class="wlWriterEditableSmartContent">
<pre><pre class="brush: csharp;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Cluster.ConsoleApp
{
    public static class MinimalStockDownloader
    {
        public static void DownloadStocks(string path)
        {
            // Allows you to download more items in parallel
            ServicePointManager.DefaultConnectionLimit = 10;
            List&lt;string&gt; symbols = GetStockSymbols();

            // Run in parallel - speeds things up considerably...
            Parallel.ForEach(
                symbols,
                symbol =&gt;
                {
                    Console.WriteLine(&quot;Downloading {0}: Working...&quot;, symbol);
                    string suri = string.Format(
                        &quot;http://ichart.finance.yahoo.com/table.csv?s={0}&amp;g=d&amp;ignore=.csv&quot;, 
                        symbol);                    
                    try
                    {
                        string quotes = Get(new Uri(suri));
                        File.WriteAllText(path + @&quot;\&quot; + symbol + &quot;.csv&quot;, quotes);                    
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(
                            &quot;  Failed to download {0} with exception: \n{1}&quot;, 
                            symbol, 
                            e);
                    }
                    
                    Console.WriteLine(
                        &quot;Downloading {0}: Done!&quot;, 
                        symbol);
                });
        }

        public static List&lt;string&gt; GetStockSymbols()
        {
            // You'll find a complete list of stocks at
            // http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&amp;render=download
            // referrred to by http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ
            string stocksCsv = Get(new Uri(&quot;http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&amp;render=download&quot;));

            List&lt;string&gt; symbols = new List&lt;string&gt;();
            Regex regexObj = new Regex(&quot;^\&quot;(.*?)\&quot;&quot;, RegexOptions.Singleline | RegexOptions.Multiline);
            Match matchResult = regexObj.Match(stocksCsv);
            while (matchResult.Success)
            {
                symbols.Add(matchResult.Groups[1].Value);
                matchResult = matchResult.NextMatch();
            }

            // First item is the text &quot;Symbol&quot;.
            symbols = symbols.Skip(1).ToList();
            Console.WriteLine(&quot;Found {0} symbols&quot;, symbols.Count);
            return symbols;
        }

        public static string Get(Uri address)
        {
            Console.WriteLine(&quot;  Get {0}...&quot;, address);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
            request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.CacheIfAvailable);

            try
            {
                using (WebResponse response = request.GetResponse())
                using (var stream = response.GetResponseStream())
                using (var reader = new StreamReader(stream, Encoding.Default))
                {
                    return reader.ReadToEnd();
                }
            }
            catch
            {
                request.Abort();
                throw;
            }
        }
    }
}
</pre></pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/353/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=353&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/02/01/download-stock-quotes-free-easy-and-with-source-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://lotsacode.wordpress.com/2011/01/02/2010-in-review/</link>
		<comments>http://lotsacode.wordpress.com/2011/01/02/2010-in-review/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 15:53:03 +0000</pubDate>
		<dc:creator>mfagerlund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lotsacode.wordpress.com/?p=348</guid>
		<description><![CDATA[The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health: The Blog-Health-o-Meter™ reads Fresher than ever. Crunchy numbers A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 9,400 times in 2010. That&#8217;s about 23 full [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=348&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" alt="Healthy blog!" width="250" height="183" /></p>
<p>The <em>Blog-Health-o-Meter™</em> reads Fresher than ever.</p>
<h2>Crunchy numbers</h2>
<p><a href="http://lotsacode.files.wordpress.com/2010/03/northwind_thumb.jpg"><img style="max-height:230px;float:right;border:1px solid #ddd;background:#fff;margin:0 0 1em 1em;padding:6px;" src="http://lotsacode.files.wordpress.com/2010/03/northwind_thumb.jpg?w=288" alt="Featured image" /></a></p>
<p>A Boeing 747-400 passenger jet can hold 416 passengers.  This blog was viewed about <strong>9,400</strong> times in 2010.  That&#8217;s about 23 full 747s.</p>
<p>&nbsp;</p>
<p>In 2010, there were <strong>50</strong> new posts, not bad for the first year! There were <strong>92</strong> pictures uploaded, taking up a total of 7mb. That&#8217;s about 2 pictures per week.</p>
<p>The busiest day of the year was December 20th with <strong>95</strong> views. The most popular post that day was <a style="color:#08c;" href="http://lotsacode.wordpress.com/2010/03/22/linq-to-sql-performance-optimizing/">LINQ to SQL Performance Optimizing</a>.</p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>google.com</strong>, <strong>forums.silverlight.net</strong>, <strong>creekr.com</strong>, <strong>google.co.in</strong>, and <strong>programmerpayback.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>silverlight webcontext</strong>, <strong>noob</strong>, <strong>the ntext data type cannot be selected as distinct because it is not comparable.</strong>, <strong>wpf image manipulation</strong>, and <strong>perlin noise c#</strong>.</p>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p><a style="margin-right:10px;" href="http://lotsacode.wordpress.com/2010/03/22/linq-to-sql-performance-optimizing/">LINQ to SQL Performance Optimizing</a> <span style="color:#999;font-size:8pt;">March 2010</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p><a style="margin-right:10px;" href="http://lotsacode.wordpress.com/2010/03/07/image-manipulation-in-c-wpfsilverlight/">Image manipulation in C# WPF/Silverlight</a> <span style="color:#999;font-size:8pt;">March 2010</span></p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p><a style="margin-right:10px;" href="http://lotsacode.wordpress.com/2010/02/24/perlin-noise-in-c/">Perlin Noise in C#</a> <span style="color:#999;font-size:8pt;">February 2010</span><br />
1 comment</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p><a style="margin-right:10px;" href="http://lotsacode.wordpress.com/2010/03/17/asp-net-and-silverlight-authentication-woes/">ASP.NET (and Silverlight) authentication woes</a> <span style="color:#999;font-size:8pt;">March 2010</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p><a style="margin-right:10px;" href="http://lotsacode.wordpress.com/2010/03/17/silverlight-and-entity-type-is-exposed-error/">Silverlight and “entity type … is exposed…” Error</a> <span style="color:#999;font-size:8pt;">March 2010</span><br />
3 comments</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lotsacode.wordpress.com/348/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lotsacode.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lotsacode.wordpress.com/348/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lotsacode.wordpress.com&amp;blog=12156922&amp;post=348&amp;subd=lotsacode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lotsacode.wordpress.com/2011/01/02/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08a29cda626eda788fa0c1b7b23bc8ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mfagerlund</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>

		<media:content url="http://lotsacode.files.wordpress.com/2010/03/northwind_thumb.jpg?w=288" medium="image">
			<media:title type="html">Featured image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
