<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Johnny Code</title>
	
	<link>http://www.johnnycode.com/blog</link>
	<description>Fear no code</description>
	<lastBuildDate>Wed, 02 May 2012 13:00:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JohnnyCode" /><feedburner:info uri="johnnycode" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Why I bought a Crucial M4 SSD</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/UhAifWLhpZg/</link>
		<comments>http://www.johnnycode.com/blog/2012/05/02/why-i-bought-a-crucial-m4-ssd/#comments</comments>
		<pubDate>Wed, 02 May 2012 13:00:26 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Crucial M4]]></category>
		<category><![CDATA[Hard Drives]]></category>
		<category><![CDATA[Laptops]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SSD]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1353</guid>
		<description><![CDATA[(Disclaimer: This is not a completely scientific analysis. My conclusions are based solely on the user reviews on various retail sites. Do not blame me if you Crucial M4 dies. Yes, that is still a possibility just as it is with any SSD, Hard Drive, or any other piece of hardware.) So far I&#8217;ve owned [...]]]></description>
			<content:encoded><![CDATA[<p>(Disclaimer: This is not a completely scientific analysis.  My conclusions are based solely on the user reviews on various retail sites.  Do not blame me if you Crucial M4 dies.  Yes, that is still a possibility just as it is with any SSD, Hard Drive, or any other piece of hardware.)</p>
<p>So far I&#8217;ve owned an 80 GB Intel X25-M and I currently own an 115 GB OCZ Vertex 2.  Both drives treated me well, but I was looking for more.  More space, that is.</p>
<div id="attachment_1370" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/Intel-X25-M-SATA-Solid-State-Drive-SSD.png"><img src="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/Intel-X25-M-SATA-Solid-State-Drive-SSD.png" alt="" title="Intel X25-M SATA Solid State Drive (SSD)" width="400" height="256" class="size-full wp-image-1370" /></a><p class="wp-caption-text">Intel X25-M SATA Solid State Drive (SSD)</p></div>
<div id="attachment_1371" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/vertex2_new_angle_1.png"><img src="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/vertex2_new_angle_1.png" alt="" title="OCZ Vertex 2" width="400" height="307" class="size-full wp-image-1371" /></a><p class="wp-caption-text">OCZ Vertex 2</p></div>
<h2>Why do I need an SSD?</h2>
<p>I wont go into the nitty-gritty detail, but here&#8217;s my take:</p>
<p>My sole machine is a laptop, so I don&#8217;t have the luxury of multiple drives and <a href="http://www.codinghorror.com/blog/2011/01/24-gigabytes-of-memory-ought-to-be-enough-for-anybody.html" title="Coding Horror: 24 Gigabytes of Memory Ought to be Enough for Anybody" target="_blank">virtually unlimited RAM</a>.  I&#8217;m limited to one storage drive, and 8 GB of RAM.  You may be lucky and have a laptop that has an extra drive bay instead of a CD drive, or one that supports more RAM, but that&#8217;s not me, and that&#8217;s definitely not everyone.  Take a look at the excerpt from the <a href="http://store.steampowered.com/hwsurvey" title="Steam Hardware &#038; Software Survey: March 2012" target="_blank">Steam Hardware &amp; Software Survey</a> below (from March 2012).  It&#8217;s specific to gamers, but even gamers don&#8217;t have the best machines!  In my situation, I don&#8217;t feel that 8 GB is enough, and an SSD can help relieve the pain.</p>
<div id="attachment_1363" class="wp-caption aligncenter" style="width: 385px"><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/Steam-Hardware-Software-Survey-Google-Chrome_2012-04-25_13-05-02.png"><img src="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/Steam-Hardware-Software-Survey-Google-Chrome_2012-04-25_13-05-02.png" alt="" title="Steam Hardware &amp; Software Survey - RAM stats" width="375" height="169" class="size-full wp-image-1363" /></a><p class="wp-caption-text">Steam Hardware &#038; Software Survey - RAM stats</p></div>
<p>Another bonus for laptop users is durability.  Apparently these drives can withstand up to 1500 G&#8217;s worth of shock.  I&#8217;m not sure if that is specific to the memory in the drive, or the electronics as well.  Either way, the lack of moving parts should make SSD&#8217;s significantly more reliable than a spinning disks in the event of a bump, drop, or mischievous 2-year-old.  <a href="http://www.hanselman.com/babysmash/" title="Baby Smash by Scott Hanselman" target="_blank">Baby Smash anyone</a>?</p>
<p>What about desktop users who <em>can</em> jam 24 GB of RAM into their machine?  Good for you!!!  You probably don&#8217;t <em>need</em> an SSD with all that RAM.  Once you&#8217;re machine is up and running and everything is loaded into RAM, you should be good to go.  But what about that first load?  An SSD would probably help with that, but the cost/benefit ratio is probably not as good.</p>
<p>But don&#8217;t take my word (opinion) for it, take a look at the articles below.  Note that they&#8217;re not super recent, but most of the reasoning for buying an SSD should still be relevant:</p>
<p>Coding Horror (Jeff Atwood):</p>
<ul>
<li><a href="http://www.codinghorror.com/blog/2009/10/the-state-of-solid-state-hard-drives.html" target="_blank">The State of Solid State Hard Drives</a></li>
<li><a href="http://www.codinghorror.com/blog/2010/09/revisiting-solid-state-hard-drives.html" target="_blank">Revisiting Solid State Hard Drives</a></li>
<li><a href="http://www.codinghorror.com/blog/2011/05/the-hot-crazy-solid-state-drive-scale.html" target="_blank">The Hot/Crazy Solid State Drive Scale</a></li>
</ul>
<p>Hanselminutes (Scott Hanselman):</p>
<ul>
<li><a href="http://www.hanselman.com/blog/YourNewYearsResolutionPutAnEndToSpinningRustAndBuyYourselfASSD.aspx" target="_blank">Your New Year&#8217;s Resolution &#8211; Put an end to spinning rust and buy yourself a SSD</a></li>
<li><a href="http://www.hanselman.com/blog/UpgradingMyLenovoW500ToAOCZVertex250GBSATAIISolidStateDiskSSD.aspx" target="_blank">Upgrading my Lenovo W500 to a OCZ Vertex 250GB SATA II Solid State Disk (SSD)</a></li>
</ul>
<p>More:</p>
<ul>
<li><a href="http://www.joelonsoftware.com/items/2009/03/27.html" target="_blank">Joel Spolsky &#8211; Solid State Disks</a></li>
<li><a href="http://forums.anandtech.com/showthread.php?p=29731857&#038;postcount=2">Anandtech Forums &#8211; Why buy/use an SSD?</a></li>
</ul>
<h2>So why a Crucial M4 and not a [Insert Model] [Insert Brand]?</h2>
<p>There are many other SSD manufacturer&#8217;s out there.  Some of the most well-known include:</p>
<ul>
<li>OCZ</li>
<li>Intel</li>
<li>Samsung</li>
<li>Kingston</li>
<li>Corsair</li>
</ul>
<p>Here are the factors that landed the Crucial M4 in my shopping cart, and subsequently, my laptop:</p>
<ul>
<li>Reliability</li>
<li>Reliability</li>
<li>Reliability</li>
</ul>
<p>The perceived reliability of the Crucial M4 blows away any other brand/series on the market today, at least from my perspective.  Here are the customer rating stats from my 2 favorite online stores:</p>
<p><a href="http://www.amazon.com/Crucial-2-5-Inch-Solid-State-CT256M4SSD2/dp/B004W2JL2A/ref=sr_1_3?ie=UTF8&#038;qid=1335543334&#038;sr=8-3" target="_blank">Amazon</a> &#8211; 4.5/5 average rating from 448 reviews<br />
<a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820148443" target="_blank">NewEgg</a> &#8211; 5/5 average rating from 145 reviews.</p>
<p>None of the other drives on the market today come close to having the same number of reviews and average rating.  Here are some similar 256 Gb drives I looked at:</p>
<p>(Reviews are from Newegg.com at the time of writing.  Note that some drives are listed multiple times, probably for different firmware revisions.  I only grabbed the ones that had at least 14 reviews.)<br />
Name/Average Rating/Votes</p>
<ul>
<li>5/5, 71 reviews, Samsung 830 Series</li>
<li>5/5, 45 reviews, Corsair Force Series GT</li>
<li>5/5, 31 reviews, Samsung 830 Series</li>
<li>5/5, 30 reviews, Plextor M3 Series</li>
<li>5/5, 20 reviews, Corsair Performance Pro Series</li>
<li>5/5, 15 reviews, Kingston HyperX</li>
<li>4/5, 115 reviews, OCZ Agility 3</li>
<li>4/5, 54 reviews, Mushkin Enhanced Chronos</li>
<li>4/5, 47 reviews, Mushkin Enhanced Chronos Deluxe</li>
<li>4/5, 42 reviews, Intel 510 Series Elm Crest</li>
<li>4/5, 39 Reviews, OCZ RevoDrive 3 X2 Series</li>
<li>4/5, 38 reviews, Mushkin Enhanced Callisto Deluxe</li>
<li>4/5, 27 reviews, OCZ Vertex 3</li>
<li>4/5, 21 reviews, Kingston HyperX</li>
<li>4/5, 19 reviews, Intel 520 Series Cherryville</li>
<li>3/5, 92 reviews, OCZ Vertex 3</li>
<li>3/5, 32 reviews, Corsair Force Series 3</li>
<li>3/5, 23 reviews, Patriot Wildfire</li>
<li>3/5, 23 reviews, OCZ RevoDrive 3 Series</li>
<li>3/5, 14 reviews, OCZ Vertex 2</li>
</ul>
<h2>What about performance?</h2>
<p>According to online benchmarks the Crucial M4 isn&#8217;t the fastest kid on the block, <em>but it&#8217;s fast enough</em>.  It&#8217;s much faster than any other spinning disk drive out there, and if you compare it to other SSD&#8217;s the difference probably wont be noticeable in real-world scenarios.  Check out the reviews if you want to see an in-depth anlysis:</p>
<ul>
<li><a href="http://www.anandtech.com/show/4253/the-crucial-m4-micron-c400-ssd-review" target="_blank" title="The Crucial m4 (Micron C400) SSD Review">AnandTech Review</a></li>
<li><a href="http://www.tomshardware.com/reviews/m4-ssd-capacity-comparison,2957.html" title="Crucial's m4 SSD Tested At 64, 128, 256, And 512 GB" target="_blank">Toms Hardware Review</a></li>
</ul>
<h2>What about price?</h2>
<blockquote><p>
Money is money, but time is money too!</p>
<p>- me
</p></blockquote>
<p>How much is your time worth?  Sure, you can save as much as $100, but the cost of owning an SSD isn&#8217;t limited to it&#8217;s purchase price. Below I&#8217;ve listed some factors that can increase the cost of ownership of your SSD.  YMMV (Your mileage may vary), but if your drive dies, any or all of them can come into play:</p>
<h3>Shipping time</h3>
<p>Best case you&#8217;re probably looking at 2 day shipping both ways.  That&#8217;s 4 days that you&#8217;re working with your old slow hard drive, or someone else&#8217;s old busted computer.  Or worse yet, you&#8217;re not working at all.  Not to mention the&#8230;</p>
<h3>Shipping costs</h3>
<p>It depends on what brand you buy, where you buy it, and when the drive dies, but those are 3 different factors that can result in shipping charges.</p>
<h3>Customer support headaches (figuratively and literally)</h3>
<p>I wont name names, but take a look at some of the reviews for other SSD&#8217;s.  A lot of customers complain about drives dying, but some are <em>more</em> frustrated by poor customer service. <a href="http://en.wikipedia.org/wiki/Stress_(psychological)#Stress_responses" target="_blank">Stress is a killer</a>.</p>
<h3>(Re-)Setup time</h3>
<p>It takes time to install your OS, apps, and games, and then restore your data and configuration.  Each one of these things can be quick on their own.  Windows 7 has a snappy install process, I mostly use free apps, all my games are on Steam, and my data is mostly in the cloud (along with various config files).  So what&#8217;s the big deal?  If you have a good <a href="http://www.johnnycode.com/blog/2012/04/25/my-cloud-backup-strategy/" title="My Cloud Backup Strategy" target="_blank">cloud backup strategy</a> you&#8217;re probably fine.  But what if you don&#8217;t?  Hunting for your OS and game disks, downloading apps, and rummaging through external hard drives isn&#8217;t my idea of fun.  God forbid you don&#8217;t have a good backup strategy which results in&#8230;</p>
<h3>Lost data</h3>
<p>Even if you saved/pushed your documents and code an hour ago, that&#8217;s still an hour&#8217;s worth of work that&#8217;s now gone.  Worst case is that you didn&#8217;t push it today, or this week.  If you don&#8217;t backup at all you may as well throw your computer out the window and save yourself from all the waiting.</p>
<h3>Multiple failures</h3>
<p>OK, so you RMA&#8217;d your broken drive for another&#8230; unreliable drive!  Sweet!  Now you get to go back to the top of the list and re-read this entire section!</p>
<h2>So the Crucial M4&#8242;s are perfect?</h2>
<p>I can&#8217;t tell you that your drive wont fail.  I just bought my Crucial M4, so only time will tell how mine fairs.  But as I said in my disclaimer at the top of this post, nothing is immune to failure, SSD&#8217;s included.  However, <strong>I firmly believe the benefits outweigh the risks</strong>.  If you do choose to go with a historically less reliable series/brand you&#8217;re taking your time and money into your own hands.</p>
<h2>Other Links</h2>
<ul>
<li><a href="http://forums.anandtech.com" target="_blank">Anandtech</a> &#8211; My defacto standard for SSD information, guides, and reviews.</li>
<li><a href="http://forums.anandtech.com/showthread.php?t=2069761" target="_blank">Anandtech Forum Post on all things SSD</a> &#8211; A great post that can probably answer 99% of the questions you have about SSD&#8217;s.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/UhAifWLhpZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/05/02/why-i-bought-a-crucial-m4-ssd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/05/02/why-i-bought-a-crucial-m4-ssd/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=why-i-bought-a-crucial-m4-ssd</feedburner:origLink></item>
		<item>
		<title>Product Review of AutoCode: Visual Studio Code Snippets on Steroids</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/0u69V75ztbs/</link>
		<comments>http://www.johnnycode.com/blog/2012/05/02/product-review-of-autocode-visual-studio-code-snippets-on-steroids/#comments</comments>
		<pubDate>Wed, 02 May 2012 13:00:25 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1406</guid>
		<description><![CDATA[Disclaimer: I did pay $19.95 for this product, but I may receive a complimentary license in return for writing this review (Scroll to the end of the article for more info). Background Code snippets in Visual Studio are great. I Code Snippets all the time! My favorite is probably one of the simpler ones: prop. [...]]]></description>
			<content:encoded><![CDATA[<p>Disclaimer: I did pay $19.95 for this product, but I may receive a complimentary license in return for writing this review (Scroll to the end of the article for more info).</p>
<h2>Background</h2>
<p>Code snippets in Visual Studio are great.  I Code Snippets all the time!  My favorite is probably one of the simpler ones: prop.  prop will generate the code for an auto-implemented property, and allow you to easily replace the type and property name.  The initial generated code looks like this:</p>
<pre class="prettyprint ">
public int MyProperty { get; set; }
</pre>
<p>which you (easily) modify to this:</p>
<pre class="prettyprint ">
public string FirstName { get; set; }
</pre>
<p>(If you don&#8217;t know what I&#8217;m talking about go try it out now!  RIGHT NOW!  In Visual Studio, in a class block type: &#8220;prop &lt;Tab&gt; &lt;Tab&gt;&#8221;)</p>
<p>Yeah&#8230; they&#8217;re great.  <a href="http://www.johnnycode.com/blog/2010/10/18/some-useful-visual-studio-code-snippets/" title="Some useful Visual Studio code snippets" target="_blank">I&#8217;ve even made a bunch of custom Code Snippets</a>.  Generally I have ones for:</p>
<ul>
<li>Inserting tasks comments like &#8220;// TODO: &#8220;.</li>
<li>A jQuery protection function.</li>
<li>SqlConnection and SqlCommand boilerplate using statements and setup.</li>
<li>Dapper boilerplate code.</li>
<li>Prototyping and stubbing out methods.</li>
<li>Other common ASP.NET markup tags.</li>
</ul>
<p>(<em>I want to throw my generic code snippets in a Github repo, but I haven&#8217;t gotten around to it yet. I <strong>do</strong> have my <a href="https://github.com/jbubriski/Dapper-Code-Snippets" target="_blank">Dapper snippets on Github</a>.</em>)</p>
<p>But what if you want to do more fancy things?  One thing I&#8217;ve always dreamed of having was a code snippet that would take a type name and generate this:</p>
<pre class="prettyprint ">
var myClass = new MyClass();
</pre>
<p>I cringe everytime I write that code because <em>I shouldn&#8217;t have to</em>.  I tried every which way to support this in a code snippet, but they are simply not powerful enough.  This is where AutoCode from <a href="http://www.devprojects.net/" target="_blank">DevProjects.net</a> comes into play.</p>
<h2>How does AutoCode work?</h2>
<blockquote><p>AutoCode is Visual Studio Code Snippets on Steroids</p>
<p>- me</p></blockquote>
<p>Like regular code snippets, AutoCode snippets allow for templates and replacements, but they also allow <em>code</em> to be run.  Much like a T4 template, they take a template, combine it with some potential input, and generate code from it.  T4 templates are usually added directly to a project or triggered by Visual Studio for the creation of files.  <a href="http://blogs.msdn.com/b/webdevtools/archive/2009/01/29/t4-templates-a-quick-start-guide-for-asp-net-mvc-developers.aspx" target="_blank">ASP.NET MVC makes extensive use of T4 Templates</a>.  AutoCode brings the power of T4 to your fingertips.  When you press Ctrl+Enter it brings up an intellisense-like dialog:</p>
<div id="attachment_1422" class="wp-caption aligncenter" style="width: 482px"><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/AutoCode-Intellisense-Dialog.png"><img src="http://www.johnnycode.com/blog/wp-content/uploads/2012/04/AutoCode-Intellisense-Dialog.png" alt="AutoCode Intellisense Dialog" title="AutoCode Intellisense Dialog" width="472" height="296" class="size-full wp-image-1422" /></a><p class="wp-caption-text">AutoCode Intellisense Dialog</p></div>
<p>From there, the dialog will guide you with the available snippet shortcuts and their usage.  The built in snippets cover most general needs like:</p>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<h2>Let&#8217;s kick it up a notch!</h2>
<p>But why limit yourself to individual properties and methods?  The &#8220;classa&#8221; shortcut will create an entire class from a single command:</p>
<pre class="prettyprint ">
int userId string firstName string lastName person classa
</pre>
<p>results in&#8230;</p>
<pre class="prettyprint ">
public class Person
{
    public Person()
    {
    }

    public int UserId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
</pre>
<p>And for those with a careful eye, you did notice my &#8220;incorrect&#8221; casing in the command, right?  The command contained (lower) <a href="http://en.wikipedia.org/wiki/CamelCase" target="_blank">Camel Cased</a> names, but AutoCode is smart enough to translate it into <a href="http://c2.com/cgi/wiki?PascalCase" target="_blank">Pascal Casing</a>!</p>
<h2>But wait, there&#8217;s more!</h2>
<p>AutoCode doesn&#8217;t stop at templates and replacements.  It also contains additional commands for things like:</p>
<ul>
<li><a href="http://www.devprojects.net/gallery/catalog/refactor" target="_blank">Method Refactoring</a></li>
<li><a href="http://www.devprojects.net/gallery/catalog/clipboard" target="_blank">Clipboard Assistance</a></li>
<li><a href="http://www.devprojects.net/gallery/catalog/tools" target="_blank">Code Evaluation</a></li>
<li><a href="http://www.devprojects.net/gallery/catalog/autocode" target="_blank">Creation of custom AutoCode snippets</a></li>
<li><a href="http://www.devprojects.net/gallery/catalog/exec" target="_blank">Commenting/Uncommenting</a></li>
<li><a href="http://www.devprojects.net/gallery/catalog/exec" target="_blank">Closing documents</a></li>
</ul>
<p>Some of these, like method refactoring commands, simply execute IDE commands, but if you&#8217;re not familiar with the Visual Studio shortcuts, this can still be helpful.</p>
<h2>Editions</h2>
<p>AutoCode comes in 2 versions, Standard and Professional, and this is where we come to my 2 criticisms.  The first problem is that the Standard Edition is free but it&#8217;s practically unsuable.  Every time a command is executed a little &#8220;nagger&#8221; popup will appear.  This really hampers a dev&#8217;s ability to gain any benefit from the Standard Edition, and more importantly, evaluate the product for purchase of the Professional Edition.  Which brings me to my next criticism&#8230;</p>
<p>The &#8220;trial&#8221; version is annoying but I decided to take my chances and purchase the Professional Edition immediately.  But instead of purchasing it for $19.95, I was required to <em>donate</em> $19.95 to get my activation code.  I guess this is sort of splitting hairs, but it feels weird that someone accepting donations is forcing me to donate a certain amount of money.  Why not simply put a normal price tag on it?  I&#8217;m not sure if this was done to appear humble, for fee/tax reasons, or for some other reason.  Again, I&#8217;m probably splitting hairs.</p>
<h2>Conclusions</h2>
<p>Buy it.  It&#8217;s only $19.95.</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/0u69V75ztbs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/05/02/product-review-of-autocode-visual-studio-code-snippets-on-steroids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/05/02/product-review-of-autocode-visual-studio-code-snippets-on-steroids/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=product-review-of-autocode-visual-studio-code-snippets-on-steroids</feedburner:origLink></item>
		<item>
		<title>My Cloud Backup Strategy</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/5gSjzP2ACbU/</link>
		<comments>http://www.johnnycode.com/blog/2012/04/25/my-cloud-backup-strategy/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 13:00:26 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1359</guid>
		<description><![CDATA[Not going to go into why you should backup, but here is how I handle the things that matter to me: Code, Documents, PC Games, and Photo and Video. Code This one is pretty much a no-brainer for me. Use Bitbucket to host your private repositories for free, and use GitHub to host your public [...]]]></description>
			<content:encoded><![CDATA[<p>Not going to go into <em>why</em> you should backup, but here is how I handle the things that matter to me: Code, Documents, PC Games, and Photo and Video.</p>
<h2>Code</h2>
<p>This one is pretty much a no-brainer for me.  Use <a href="https://bitbucket.org/" title="Bitbucket - Free source code hosting" target="_blank">Bitbucket</a> to host your private repositories for free, and use <a href="https://github.com/" title="GitHub - the gold standard for open source code hosting (my words, not theirs)" target="_blank">GitHub</a> to host your public ones.</p>
<h2>Documents and other miscellaneous files</h2>
<p>Some prefer Microsoft, Google, or another company.  Take your pick (numbers from time of writing):</p>
<ul>
<li><a href="https://skydrive.live.com" target="_blank">Microsoft SkyDrive</a> &#8211; 7 Gb free</li>
<li><a href="https://drive.google.com/" target="_blank">Google Drive</a> &#8211; 5 Gb free</li>
<li><a href="http://db.tt/Cr4Jtd0" target="_blank">Dropbox</a> &#8211; 2 GB free (plus referral bonuses)</li>
</ul>
<h2>PC Games</h2>
<p>Just use <a href="http://store.steampowered.com/" target="_blank">Steam</a>.</p>
<h2>Photo and Video</h2>
<p>I have a <a href="http://www.flickr.com" target="_blank">Flickr</a> <a href="http://www.flickr.com/account/order" target="_blank">Pro Account</a>.  For $25/year you get:</p>
<ul>
<li>Unlimited uploads and storage</li>
<li>Unlimited sets and collections</li>
<li>Access to your original files</li>
<li>Stats on your account</li>
<li>Ad-free browsing and sharing</li>
<li>HD video uploads &#038; playback</li>
</ul>
<p>Their upload download procedures aren&#8217;t super smooth, but I mostly do uploads and the <a href="http://www.flickr.com/tools/uploadr/" target="_blank">Flickr Uploadr</a> makes that pretty easy.  I tried out <a href="https://picasaweb.google.com" target="_blank">Google&#8217;s Picasa</a> a while back, but with my massive collection of family photos it was getting very expensive very fast.</p>
<p>I also have a <a href="http://www.synology.com/us/products/DS211j/index.php" target="_blank">Synology DS211J NAS</a> that I use to store all my photos and videos in house.  If you edit/view/print your photos a lot, having this local network copy/cache will help out a lot.</p>
<p>Bonus: I have 2 projects on <a href="https://github.com/jbubriski" target="_blank">Github</a> relating to photo management.</p>
<p><a href="https://github.com/jbubriski/Organize-My-Photos" target="_blank">&#8220;Organize My Photos&#8221;</a> aims to organize all of your local photos into folders by date.  It&#8217;s a really basic/ugly implementation in Winforms, but it works for my purposes.</p>
<p><a href="https://github.com/jbubriski/Organize-My-Flickr-Photos" target="_blank">&#8220;Organize My Flickr Photos&#8221;</a> aims to keep your photos &#8220;backed up&#8221; to Flickr, avoiding duplication.  I don&#8217;t think this code  is fully functional right now.  Last I checked I was fighting with the limitations of the Flickr API.  Once over those hurdles it shouldn&#8217;t be too much work to get some nice sync action going on.</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/5gSjzP2ACbU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/04/25/my-cloud-backup-strategy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/04/25/my-cloud-backup-strategy/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=my-cloud-backup-strategy</feedburner:origLink></item>
		<item>
		<title>Serializing Circular References with JSON.Net and Entity Framework</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/yoe3RPu2nkQ/</link>
		<comments>http://www.johnnycode.com/blog/2012/04/10/serializing-circular-references-with-json-net-and-entity-framework/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 17:58:25 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Circular References]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JSON.Net]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Serialization]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1326</guid>
		<description><![CDATA[The Setup You&#8217;re building a RESTful web service, and your technology stack looks something like this: ASP.NET MVC 4 w/ Web API Entity Framework Code First (I&#8217;m on 4.3.1, available via Nuget) Newtonsoft JSON.Net (I&#8217;m on 4.5.1, available via Nuget) We&#8217;ll pull the data out of the database using EF and setup the ASP.NET Web [...]]]></description>
			<content:encoded><![CDATA[<h2>The Setup</h2>
<p>You&#8217;re building a <a href="http://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank">RESTful</a> web service, and your technology stack looks something like this:</p>
<ul>
<li>ASP.NET MVC 4 w/ Web API</li>
<li>Entity Framework Code First (I&#8217;m on 4.3.1, available via Nuget)</li>
<li><a href="http://james.newtonking.com/pages/json-net.aspx" target="_blank">Newtonsoft JSON.Net</a> (I&#8217;m on 4.5.1, available via Nuget)</li>
</ul>
<p>We&#8217;ll pull the data out of the database using EF and <a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx" target="_blank">setup the ASP.NET Web API to use the JSON.Net library to handle serialization/deserialization</a>.  To make your life easier you could <a href="http://jbubriski.github.com/ST4bby/" target="_blank">use ST4bby to do the heavy lifting and generate your POCO&#8217;s</a>.</p>
<p>Piece of cake, right?</p>
<pre>A circular reference was detected while serializing an object of type ...</pre>
<p>False.</p>
<h2>The Problem</h2>
<p>Circular reference exception???  Oh dear God, haven&#8217;t we figured this out yet???</p>
<p>Let&#8217;s start from the beginning.</p>
<p>You&#8217;ve setup JSON.Net as your default formatter, right?  In case you haven&#8217;t done that <a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx" target="_blank">grab the JsonNetFormatter from Henrik&#8217;s blog</a> and enable it in the Application_Start method in the Global.asax:</p>
<pre class="prettyprint ">
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new JsonNetFormatter(new JsonSerializerSettings()));
</pre>
<p>That&#8217;s right, we blew away all the formatters, including the XML one and we&#8217;re not looking back.</p>
<p>Now let&#8217;s look at a simple example of serialization of relational collections, without EF.  Below is a simple class which can hold references to other instances of the same class:</p>
<pre class="prettyprint ">
public class Bro
{
    public int BroId { get; set; }
    public string Name { get; set; }

    public List&lt;Bro&gt; Bros { get; set; }

    public Bro()
    {
        Bros = new List&lt;Bro&gt;();
    }
}
</pre>
<p>Not rocket science.  A Bro can have many Bros, right?  A more common example would involve Parent/Child relationships, but this is simpler and demonstrates the same issue.  Now let&#8217;s expose our Bros to the world via an ASP.NET Web API Controller:</p>
<pre class="prettyprint ">
public class BrosController : ApiController
{
    public IEnumerable&lt;Bro&gt; Get()
    {
        var john = new Bro { Name = &quot;John&quot; };
        var jared = new Bro { Name = &quot;Jared&quot; };

        john.Bros.Add(jared);
        jared.Bros.Add(john);

        return new List&lt;Bro&gt; { john, jared };
    }
}
</pre>
<p>Again, not rocket science.  If you&#8217;re unfamiliar with ASP.NET Web API, this is just like an ASP.NET MVC controller, except that it will handle all of the HTTP/REST stuff for you.  The JSON.Net formatter will kick in and serialize our collection of Bros to JSON.  Right?  Almost.</p>
<p>If you&#8217;ve corretly setup our custom JsonNetFormatter, you&#8217;re going to get an exception about a circular reference:</p>
<pre>Self referencing loop detected for type 'EntityFrameworkCodeFirstWithJsonSerialization.Bro'.</pre>
<p>If you didn&#8217;t setup the JsonNetFormatter, I think that your page is gonna spin until the call stack fills up and you get a <a href="http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx" target="_blank">StackOverflowExpception</a>.</p>
<p>So what gives?  Isn&#8217;t it the year 2012?  Shouldn&#8217;t we have figured out a way to serialize this data?  Yes we should have, and yes we have.</p>
<h2>The Solution</h2>
<p>After a lot of searching, I finally found this page in the docs:</p>
<p><a href="http://james.newtonking.com/projects/json/help/" target="_blank">http://james.newtonking.com/projects/json/help/</a> under Serializing and Deserializing JSON -> Serialization and Preserving Object References (or <a href="http://james.newtonking.com/projects/json/help/PreserveObjectReferences.html" target="_blank">Direct link with no navigation</a>)</p>
<p>Which explains to set this setting:</p>
<pre class="prettyprint ">PreserveReferencesHandling = PreserveReferencesHandling.Objects</pre>
<p>&#8230; in order to&#8230; you guessed it, preserve references!  JSON.Net <em>is</em> smart enough to detect the circular references, but since the default functionality is to serialize by value, it gives up so you don&#8217;t get StackOverflowExceptions!</p>
<p>So now your Application_Start method in the global.asax looks more like this:</p>
<pre class="prettyprint ">
var jsonSerializerSettings = new JsonSerializerSettings
{
    PreserveReferencesHandling = PreserveReferencesHandling.Objects
};

GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new JsonNetFormatter(jsonSerializerSettings));
</pre>
<p>And your Web API Controller works, spitting out JSON like this:</p>
<pre class="prettyprint ">
[
    {
        &quot;$id&quot;: &quot;1&quot;,
        &quot;BroId&quot;: 0,
        &quot;Name&quot;: &quot;John&quot;,
        &quot;Bros&quot;: [
            {
                &quot;$id&quot;: &quot;2&quot;,
                &quot;BroId&quot;: 0,
                &quot;Name&quot;: &quot;Jared&quot;,
                &quot;Bros&quot;: [
                    {
                        &quot;$ref&quot;: &quot;1&quot;
                    }
                ]
            }
        ]
    },
    {
        &quot;$ref&quot;: &quot;2&quot;
    }
]
</pre>
<p>Isn&#8217;t that awesome!  To be honest, I never knew JSON was so smart!  In case you don&#8217;t understand what&#8217;s happening, JSON.Net is taking the extra step to setup each reference with an additional meta-property called &#8220;$id&#8221;.  When JSON.Net encounters the same instance in another place in the object graph, it simply drops a reference to the original instance, instead of duplicating the data, and causing circular reference issues!</p>
<h2>What about Entity Framework</h2>
<p>You said you were going to help me with my Entity Framework Code First problem!</p>
<p>Funny story: regular EF doesn&#8217;t have a problem with this!  In fact, it handles it beautifully!  All your references to parent and child objects are preserved and your JSON will look like what we saw above!</p>
<p>To &#8220;Fix&#8221; Code First we need to understand what it is abstracting away for us, and do a little bit more work (nothing you can&#8217;t handle dear reader!).  If you already tried the above setting on your project you&#8217;ll notice that you now get a different Exception that looks something like this:</p>
<pre>The RelationshipManager object could not be serialized. This type of object cannot be serialized when the RelationshipManager belongs to an entity object that does not implement IEntityWithRelationships.</pre>
<p>OK, so we traded one issue for another&#8230; or did we?</p>
<p>If we step back for a minute, we&#8217;ll remember that when we read <a href="http://www.amazon.com/gp/product/1449312942/ref=as_li_ss_tl?ie=UTF8&#038;tag=johcod-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1449312942" target="_blank">Julia Lerman&#8217;s book on Programming Entity Framework: Code First</a><img src="http://www.assoc-amazon.com/e/ir?t=johcod-20&#038;l=as2&#038;o=1&#038;a=1449312942" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> it said that Code First generates proxy classes for us, even though we have our POCO&#8217;s (actually I don&#8217;t think she references the proxy objects in that book, but you should buy it anyway because she&#8217;s awesome and that&#8217;s a referral link)!  So JSON.Net sees these weird proxy classes instead of our actual POCO&#8217;s.  When it tries to serialize those proxy classes, all Hell breaks lose because the proxy classes are <em>dynamic</em> proxy classes, as in <a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx">the dynamic keyword</a>.</p>
<p>So what&#8217;s a Dev to do?  Disable Proxy Generation!</p>
<pre class="prettyprint ">
using(var yourDbContext = new YourDbContext())
{
    yourDbContext.Configuration.ProxyCreationEnabled = false;

    return ...
}
</pre>
<p>Now our EF Code First setup works!</p>
<p>But what did I just enable/disable/break?</p>
<blockquote><p>When proxy object creation is enabled for POCO entities, changes that are made to the graph and the property values of objects are tracked automatically by the Entity Framework as they occur. For information about change tracking options with and without proxies, see Tracking Changes in POCO Entities.</p></blockquote>
<p>Therefore, when proxy object creation is <em>disabled</em>, changes are not tracked automatically.  If you can live with that, then you&#8217;re all set!</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/yoe3RPu2nkQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/04/10/serializing-circular-references-with-json-net-and-entity-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/04/10/serializing-circular-references-with-json-net-and-entity-framework/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=serializing-circular-references-with-json-net-and-entity-framework</feedburner:origLink></item>
		<item>
		<title>How to Scrape Amazon Wishlists in 1 Line of C#</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/tLrY37PVsmA/</link>
		<comments>http://www.johnnycode.com/blog/2012/03/19/how-to-scrape-amazon-wishlists-in-1-line-of-c/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 12:00:02 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[WebClient]]></category>
		<category><![CDATA[Wishlist]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1300</guid>
		<description><![CDATA[So I started a new open source project called Shing. It&#8217;s goal is simple: Scrape an Amazon Wishlist, get all the Product ID&#8217;s and generate the Amazon short links to the products. I was showing the code to my colleagues when Joey, a friend and former coworker, offered some suggestions to improve the code.  This [...]]]></description>
			<content:encoded><![CDATA[<p>So I started a new open source project called <a title="Shing, An Open Source Amazon Wishlist Scraper for .NET" href="https://github.com/jbubriski/Shing" target="_blank">Shing</a>. It&#8217;s goal is simple: Scrape an Amazon Wishlist, get all the Product ID&#8217;s and generate the Amazon short links to the products.</p>
<p>I was showing the code to my colleagues when Joey, a friend and former coworker, offered some suggestions to improve the code.  This is the original working prototype, thrown together in about 5 minutes:</p>
<p><em>Note: the code below isn&#8217;t quite complete.  It&#8217;s just a simple Regex that finds product links on the wishlist page.  There can be other product links on the wishlist page like related products.  Just a heads up.</em></p>
<pre class="prettyprint ">
string _regex = &quot;/dp/(.*?)/&quot;;

/// &lt;summary&gt;
/// Returns a list of product ID's
/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
public List&lt;string&gt; Scrape(string urlToScrape)
{
    var webClient = new WebClient();

    var content = webClient.DownloadString(urlToScrape);

    var matches = Regex.Matches(content, _regex);

    var productIds = new List&lt;string&gt;();

    foreach (Match match in matches)
    {
        productIds.Add(match.Groups[1].Value);
    }

    return productIds;
}
</pre>
<p>And here was his suggested version:</p>
<pre class="prettyprint ">
private const string WishListRegex = &quot;/dp/(.*?)/&quot;;

/// &lt;summary&gt;
/// Returns a list of product ID's
/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
public IEnumerable&lt;string&gt; Scrape(string urlToScrape)
{
    var content = new WebClient().DownloadString(urlToScrape);

    var matches = Regex.Matches(content, WishListRegex);

    foreach (Match match in matches)
    {
        yield return match.Groups[1].Value;
    }
}
</pre>
<p>His code returns the exact same results but a few minor differences make it worthwhile.</p>
<ul>
<li><strong>The regex is a constant</strong> &#8211; This should make the code a little more efficient by not creating a string every time the Scrape() method is called.</li>
<li><strong>Scrape() returns an IEnumerable&lt;string&gt;</strong> &#8211; This allows for the next one which is&#8230;</li>
<li><strong>Scrape() incorporates the <em>yield</em> keyword</strong> &#8211; This should make the code much more efficient in certain scenarios.  Instead of creating a List<string> in memory and then returning the entire thing at the end, the method will simply return results as you ask for them.  This should reduce memory consumption and speed things up as well, again, if used correctly.</li>
</ul>
<p>But why stop there?  Just make it a one-liner</p>
<pre class="prettyprint ">
return Regex.Matches(new WebClient().DownloadString(urlToScrape), &quot;/dp/(.*?)/&quot;).Cast&lt;Match&gt;().ToList().Select(m =&gt; m.Groups[1].Value);
</pre>
<p><strong>This is purely for fun. I would never do this except as a joke.</strong></p>
<p>The code should produce the same results, except that the regex isn&#8217;t a constant, and yield isn&#8217;t incorporated.  Fun though.</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/tLrY37PVsmA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/03/19/how-to-scrape-amazon-wishlists-in-1-line-of-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/03/19/how-to-scrape-amazon-wishlists-in-1-line-of-c/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-scrape-amazon-wishlists-in-1-line-of-c</feedburner:origLink></item>
		<item>
		<title>Getting a List of Alternative Forms</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/Cee9b-cYi_s/</link>
		<comments>http://www.johnnycode.com/blog/2012/02/28/getting-a-list-of-alternative-forms/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 13:00:01 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Kentico]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Kentico Alternative Forms]]></category>
		<category><![CDATA[Kentico BizForms]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1047</guid>
		<description><![CDATA[I forget why I needed to do this, but I was doing some heavy development around Kentico&#8216;s BizForm&#8216;s at the time and needed to pull back a list of alternative forms for a given BizForm. It&#8217;s not very complex, but it might not be obvious if you&#8217;re not familiar with Kentico&#8217;s database structure and their [...]]]></description>
			<content:encoded><![CDATA[<p>I forget why I needed to do this, but I was doing some heavy development around <a title="Kentico CMS" href="http://www.kentico.com/" target="_blank">Kentico</a>&#8216;s <a title="My posts on Kentico BizForms" href="http://www.johnnycode.com/blog/tag/kentico-bizforms/" target="_blank">BizForm</a>&#8216;s at the time and needed to pull back a list of alternative forms for a given BizForm. It&#8217;s not very complex, but it might not be obvious if you&#8217;re not familiar with Kentico&#8217;s database structure and their use of classes.</p>
<p>Anyway, here is the code:</p>
<pre class="prettyprint ">SELECT ca.FormID, ca.FormDisplayName
FROM CMS_Class cc
JOIN CMS_AlternativeForm ca ON ca.FormClassID = cc.ClassID
WHERE cc.ClassName = 'BizForm.ContactUs'</pre>
<p>Let me know if this helped you!</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/Cee9b-cYi_s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/02/28/getting-a-list-of-alternative-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/02/28/getting-a-list-of-alternative-forms/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-a-list-of-alternative-forms</feedburner:origLink></item>
		<item>
		<title>Logging Events with Kentico</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/3l3gTXcKclM/</link>
		<comments>http://www.johnnycode.com/blog/2012/02/27/logging-events-with-kentico/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 13:00:47 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Kentico]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Kentico API Programming]]></category>
		<category><![CDATA[Kentico CMS]]></category>
		<category><![CDATA[Kentico Event Log]]></category>
		<category><![CDATA[Kentico Module Development]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1080</guid>
		<description><![CDATA[Developing a custom web part or module and want to log some events into the Kentico Event Log? Here is some sample code to get you started. Logging Exceptions: var eventLogProvider = new EventLogProvider(); eventLogProvider.LogEvent(&#34;E&#34;, eventName, ex); Logging Custom Events: var eventLogProvider = new EventLogProvider(); eventLogProvider.LogEvent(&#34;E&#34;, DateTime.Now, &#34;source&#34;, &#34;code&#34;); FYI, I believe that the EventLogProvider [...]]]></description>
			<content:encoded><![CDATA[<p>Developing a custom web part or module and want to log some events into the Kentico Event Log? Here is some sample code to get you started.</p>
<p>Logging Exceptions:</p>
<pre class="prettyprint ">var eventLogProvider = new EventLogProvider();
eventLogProvider.LogEvent(&quot;E&quot;, eventName, ex);</pre>
<p>Logging Custom Events:</p>
<pre class="prettyprint ">var eventLogProvider = new EventLogProvider();
eventLogProvider.LogEvent(&quot;E&quot;, DateTime.Now, &quot;source&quot;, &quot;code&quot;);</pre>
<p>FYI, I believe that the <code>EventLogProvider</code> has some static methods on it to log events, but I thing they are the more verbose versions of the methods above. Happy logging!</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/3l3gTXcKclM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/02/27/logging-events-with-kentico/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/02/27/logging-events-with-kentico/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=logging-events-with-kentico</feedburner:origLink></item>
		<item>
		<title>Using HttpClient to Consume ASP.NET Web API REST Services</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/D4dcV2k0_j8/</link>
		<comments>http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 13:00:34 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HttpClient]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1234</guid>
		<description><![CDATA[So you installed the ASP.NET MVC 4 Beta and followed the Web API introduction over at the ASP.NET website. Great! You now have a nice HTTP based API that plays nicely with jQuery and other client side JavaScript libraries, and even other server-side technologies. But how exactly do we perform server side consumption of that API in [...]]]></description>
			<content:encoded><![CDATA[<p>So you installed the <a href="http://www.asp.net/mvc/mvc4" target="_blank">ASP.NET MVC 4 Beta</a> and followed the <a href="http://www.asp.net/web-api" target="_blank">Web API introduction</a> over at the <a href="http://www.asp.net" target="_blank">ASP.NET website</a>. Great! You now have a nice HTTP based API that plays nicely with jQuery and other client side JavaScript libraries, and even other server-side technologies. But how exactly do we perform server side consumption of that API in .NET?</p>
<p><strong>**UPDATE**</strong></p>
<p><strong>I updated the post and the examples with the full code for making GET&#8217;s, POST&#8217;s, PUT&#8217;s, and DELETE&#8217;s.  I didn&#8217;t have much time, so let me know if there are any mistakes/issues.</strong></p>
<p>Let&#8217;s say that you want to build an uber-flexible n-tier architecture for your next great app. One option for decoupling your layers is to build them as web services. That way you not only decouple the code relationships, but you decouple the platforms as well.</p>
<p>For example, if you build your BLL (Business Logic Layer) as a web service any platform can interact with it. Your presentation layer can be a MVC site, a WPF app, a mobile app, or anything else you can think up. The only requirement is that the front end be able to reach the web service and correctly talk to it.</p>
<h2>Where&#8217;s the meta data???</h2>
<p>How are we going to generate the proxy classes for this new web service??? I&#8217;m not going to lie and say that your old friend the &#8220;Add Service Reference&#8230;&#8221; dialog is going to be able to help you out here. Because this is a simple HTTP based API, no meta data gets generated about the API itself (at least as far as I know, and at the time of writing this post).</p>
<p>While I love the &#8220;automagical&#8221; nature of the &#8220;Add Service Reference&#8230;&#8221; dialog, it always scared me a little bit. It hid a lot of code and required an active instance of the web service to be up and running somewhere (locally was fine). Now, we have complete control over the serialization and deserialization of the data and can write more testable code (more on that later).</p>
<h2>Show me the frickin&#8217; code!</h2>
<p>Attached is a working sample solution that demonstrates my examples below.</p>
<p>First, create a new ASP.NET MVC 4 project and select the Web API template. I called mine &#8220;WebApi&#8221;:</p>
<p><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/New-ASP.NET-MVC-4-Project-Dialog.png"><img class="aligncenter size-full wp-image-1245" title="New ASP.NET MVC 4 Project Dialog" src="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/New-ASP.NET-MVC-4-Project-Dialog.png" alt="" width="683" height="618" /></a></p>
<p>After the solution loads let&#8217;s make sure that our web service is in an accesible location. Open up the project Properties &gt; Web and then set the Specific Page to be &#8220;Values&#8221; and the Specific Port to be 9000. We&#8217;ll reference that port in our test consumer in a minute:</p>
<p><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/Web-API-Project-Settings.png"><img class="aligncenter size-full wp-image-1262" title="Web API Project Settings" src="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/Web-API-Project-Settings.png" alt="" width="584" height="635" /></a></p>
<p>You can test out the default API by just hitting F5. The local web service URL (http://localhost:9000/api/values) should open in your default browser and you should see some XML (The styling may be different in your browser):</p>
<pre class="prettyprint ">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;string&gt;value 1&lt;/string&gt;
&lt;string&gt;value 2&lt;/string&gt;
</pre>
<p>(Note: If you want to see the JSON, you can send an HTTP &#8220;Accept Header&#8221;. The Web API will see this and spit back your data serialized to JSON. Make sure you use this header when making requests from jQuery. Check out the <a href="http://www.asp.net/web-api">ASP.NET Web API Introduction</a> for an example, or use <a title="A free web debugging tool" href="http://fiddler2.com/fiddler2/" target="_blank">Fiddler</a>.)</p>
<p>When you ran your project, a route defined in the Global.asax sent your request to the ValuesController in the Controllers folder. In the ValuesController, the request matched the first action via the HTTP request method verb and the parameters. To see this in action try going to http://localhost:9000/api/values/5. Additionally, requests can be mapped by name too.</p>
<p>So far so good. Let&#8217;s spice up the API a little bit and return our own custom type. Create a new class library project within your solution. I called mine &#8220;WebApi.Dal&#8221;. Rename the deafult &#8220;class1.cs&#8221; to &#8220;MyDataClass.cs&#8221; and let Visual Studio auto update the references. Now add some properties. Mine ended up like this:</p>
<pre class="prettyprint ">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebApi.Dal
{
    public class MyDataClass
    {
        public string MyProperty1 { get; set; }
        public bool MyProperty2 { get; set; }
        public int MyProperty3 { get; set; }
        public decimal MyProperty4 { get; set; }
    }
}</pre>
<p>Now let&#8217;s switch back to the Web API project. Add a reference to your DAL project and replace the first controller action with this one:</p>
<pre class="prettyprint ">// ... usings, namespace and class/controller declarations.

// GET /api/values
public MyDataClass Get()
{
    return new MyDataClass
    {
        MyProperty1 = &quot;Property 1&quot;, // String
        MyProperty2 = true, // Bool
        MyProperty3 = 987654, // Integer
        MyProperty4 = 100.87m // Decimal
    };
}

// Rest of the class/controller definition...</pre>
<p>Now run the solution again and you should see this:</p>
<pre class="prettyprint ">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;MyDataClass xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
    &lt;MyProperty1&gt;Property 1&lt;/MyProperty1&gt;
    &lt;MyProperty2&gt;true&lt;/MyProperty2&gt;
    &lt;MyProperty3&gt;987654&lt;/MyProperty3&gt;
    &lt;MyProperty4&gt;100.87&lt;/MyProperty4&gt;
&lt;/MyDataClass&gt;
</pre>
<p>Great! Piece of cake!  Now back to the problem at hand.</p>
<h2>Consuming the Web API Service</h2>
<p>Back in Visual Studio create a Console Application project. I called mine &#8220;WebApi.Tester&#8221;. <strong>Add a reference to the WebApi.Dal project, but you don&#8217;t need to add one to the WebApi project</strong>. Having access to the classes that were used to serialize the Web API data will allow us to deserialize the data easily, and we don&#8217;t need any &#8220;direct&#8221; relation to the web service itself, just the data it provides.</p>
<p>In the Nuget Package Manager search for System.Net.Http and install the package that matches that name (a bunch of other results show up, but get the one from Microsoft) and the one that matches the name with &#8220;Formatter&#8221; on the end.</p>
<p>Then search for &#8220;json&#8221; and add the Json.NET package from Newtonsoft.</p>
<p>Then Add a Reference to System.Net.Http.Formatting and System.Json.</p>
<p>Now you should now have references to:</p>
<ul>
<li>Newtonsoft.Json</li>
<li>System.Json</li>
<li>System.Net.Http</li>
<li>System.Net.Http.Formatting</li>
<li>System.Net.Http.WebRequest</li>
<li>WebApi.Dal</li>
</ul>
<p>When we go to test this setup, we want both the WebApi MVC project to run, as well as the WebApi.Tester Console app.  To do that, open up the Solution Properties, check the radio button that says &#8220;Multiple startup projects&#8221;, and set WebApi and WebApi.Tester as startup projects:</p>
<p><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/Setting-Multiple-Startup-Projects-in-Visual-Studio.png"><img class="aligncenter size-full wp-image-1265" title="Setting Multiple Startup Projects in Visual Studio" src="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/Setting-Multiple-Startup-Projects-in-Visual-Studio.png" alt="" width="590" height="481" /></a></p>
<p>Now we are ready to write some code.  Here is a base client class I whipped up that provides a generic interface to the Web API service:</p>
<pre class="prettyprint ">public class BaseClient
{
    protected readonly string _endpoint;

    public BaseClient(string endpoint)
    {
        _endpoint = endpoint;
    }

    public T Get()
    {
        using (var httpClient = new HttpClient())
        {
            T result = default(T);
            Task responseTask = null;

            httpClient.GetAsync(_endpoint).ContinueWith((requestTask) =&gt;
            {
                responseTask = requestTask;
                HttpResponseMessage response = requestTask.Result;

                response.EnsureSuccessStatusCode();

                response.Content.ReadAsAsync().ContinueWith((readTask) =&gt;
                {
                    result = readTask.Result;
                });
            });

            // HACK: My version of the await keyword
            while (responseTask == null || !responseTask.IsCompleted || result == null) { }

            return result;
        }
    }
}</pre>
<p><strong>(Important: As of this writing, the above code may fail. Keep reading for a solution.)</strong></p>
<p>So about that code above&#8230; it doesn&#8217;t always work&#8230;  It appears that there is some issue with the deserializer and I get the following exception when reading the result from the inner async method:</p>
<blockquote><p>&#8220;The input stream contains too many delimiter characters which may be a sign that the incoming data may be malicious.&#8221;</p></blockquote>
<p>Basically, there is some sort of &#8220;security&#8221; measure in place in case the data is too big and there are too many delimiters.</p>
<p>Not to worry, I got your back!  Just substitute that inner async call with this one, which delegates the deserialization to the Newtonsoft JSON library!</p>
<pre class="prettyprint ">response.Content.ReadAsStringAsync().ContinueWith((readTask) =&gt;
{
    result = JsonConvert.DeserializeObject(readTask.Result);
});</pre>
<p>I asked about the above issue on the official ASP.NET forums and I got a response on <a title="Bug with Web API deserialization?" href="http://forums.asp.net/p/1772531/4845321.aspx" target="_blank">this thread</a>. It looks like you just need to set the <code>SkipStreamLimitChecks </code>static property to true on the MediaTypeFormatter class. As of this writing, I haven&#8217;t tested that solution but I left the commented samples intact in case you want to give it a go.</p>
<p><em>But let&#8217;s be honest with eachother</em>.  You think that code is ugly.  It <strong><em>is</em></strong> ugly, it&#8217;s not just you.  So I started another thread about how to reign that code in and clean it up.  I got a great response from a guy in <a title="Making a request synchronously" href="http://forums.asp.net/p/1772530/4845269.aspx" target="_blank">this thread</a>.  Since the async code is so ugly in .NET 4, and in my case it wasn&#8217;t really needed, I left it out.  So the first return is the one that executes in the example and it&#8217;s still using Newtonsoft JSON:</p>
<pre class="prettyprint ">public T Get()
{
    using (var httpClient = new HttpClient())
    {
        var response = httpClient.GetAsync(_endpoint).Result;

        // This works:
        return JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

        // This may not work:
        return response.Content.ReadAsAsync().Result;

        // This may not work:
        return response.Content.ReadAsOrDefaultAsync().Result;
    }
}</pre>
<p>So now my code is a lot shorter, cleaner and easier to grok. For now we&#8217;re basically skipping the async stuff, but I think that&#8217;s a smart decision until we can leverage the <code>await</code> keyword and all it&#8217;s compiler magic.  For a quick sample of how the await keyword in .NET 4.5 relates to the Web API, check out this post by the architect behind all this stuff, <a title="HttpClient is Here!" href="http://blogs.msdn.com/b/henrikn/archive/2012/02/16/httpclient-is-here.aspx" target="_blank">Henrik F Nielsen</a>.</p>
<h2>Sample Solution</h2>
<p>I threw together a simple sample solution that is a complete working example.  Nuget package restore is enabled and I removed all the packages to make the zip file as small as possible.  The first build of the solution will take a minute because it has to go fetch all the packages and their dependencies.  Let me know if you have any problems running the code.</p>
<p><a href="http://www.johnnycode.com/blog/wp-content/uploads/2012/02/WebApi_v2.zip">Web API with HttpClient Sample Solution</a></p>
<p>In case you don&#8217;t feel like downloading the zip, the full relevant code from the solution is below:</p>
<pre class="prettyprint ">
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

public class BaseClient
{
    protected readonly string _endpoint;

    public BaseClient(string endpoint)
    {
        _endpoint = endpoint;
    }

    public T Get&lt;T&gt;(int top = 0, int skip = 0)
    {
        using (var httpClient = new HttpClient())
        {
            var endpoint = _endpoint + &quot;?&quot;;
            var parameters = new List&lt;string&gt;();

            if (top &gt; 0)
                parameters.Add(string.Concat(&quot;$top=&quot;, top));

            if (skip &gt; 0)
                parameters.Add(string.Concat(&quot;$skip=&quot;, skip));

            endpoint += string.Join(&quot;&amp;&quot;, parameters);

            var response = httpClient.GetAsync(endpoint).Result;

            return JsonConvert.DeserializeObject&lt;T&gt;(response.Content.ReadAsStringAsync().Result);
        }
    }

    public T Get&lt;T&gt;(int id)
    {
        using (var httpClient = NewHttpClient())
        {
            var response = httpClient.GetAsync(_endpoint + id).Result;

            return JsonConvert.DeserializeObject&lt;T&gt;(response.Content.ReadAsStringAsync().Result);
        }
    }

    public string Post&lt;T&gt;(T data)
    {
        using (var httpClient = NewHttpClient())
        {
            var requestMessage = GetHttpRequestMessage&lt;T&gt;(data);

            var result = httpClient.PostAsync(_endpoint, requestMessage.Content).Result;

            return result.Content.ToString();
        }
    }

    public string Put&lt;T&gt;(int id, T data)
    {
        using (var httpClient = NewHttpClient())
        {
            var requestMessage = GetHttpRequestMessage&lt;T&gt;(data);

            var result = httpClient.PutAsync(_endpoint + id, requestMessage.Content).Result;

            return result.Content.ReadAsStringAsync().Result;
        }
    }

    public string Delete(int id)
    {
        using (var httpClient = NewHttpClient())
        {
            var result = httpClient.DeleteAsync(_endpoint + id).Result;

            return result.Content.ToString();
        }
    }

    protected HttpRequestMessage GetHttpRequestMessage&lt;T&gt;(T data)
    {
        var mediaType = new MediaTypeHeaderValue(&quot;application/json&quot;);
        var jsonSerializerSettings = new JsonSerializerSettings();
        jsonSerializerSettings.Converters.Add(new IsoDateTimeConverter());

        var jsonFormatter = new JsonNetFormatter(jsonSerializerSettings);

        var requestMessage = new HttpRequestMessage&lt;T&gt;(data, mediaType, new MediaTypeFormatter[] { jsonFormatter });

        return requestMessage;
    }

    protected HttpClient NewHttpClient()
    {
        return new HttpClient();
    }
}
</pre>
<h2>Resources</h2>
<ul>
<li><a href="http://www.asp.net/web-api" target="_blank">Web API Section on ASP.NET</a></li>
<li><a href="http://blogs.msdn.com/b/henrikn/" target="_blank">Henrik F Nielsen&#8217;s Blog</a></li>
<li><a href="http://forums.asp.net/1246.aspx/1?Web+API" target="_blank">ASP.NET Web API Forums</a></li>
</ul>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/D4dcV2k0_j8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=consuming-your-own-asp-net-web-api-rest-service</feedburner:origLink></item>
		<item>
		<title>Get BizForm Record ID</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/bYn5jCH4MlY/</link>
		<comments>http://www.johnnycode.com/blog/2012/02/22/get-bizform-record-id/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 13:00:38 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Kentico]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Kentico API Programming]]></category>
		<category><![CDATA[Kentico BizForms]]></category>
		<category><![CDATA[Kentico CMS]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1044</guid>
		<description><![CDATA[Here is a post I wanted to write a few months ago while I was actively developing Kentico based websites, but I never got the chance to finish it. The code should be solid, and I&#8217;ll explain it as best I can. If you&#8217;re working with BizForm&#8217;s programmatically you&#8217;re going to need to get the ID [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a post I wanted to write a few months ago while I was actively developing <a title="Kentico CMS" href="http://www.kentico.com/" target="_blank">Kentico</a> based websites, but I never got the chance to finish it. The code should be solid, and I&#8217;ll explain it as best I can.</p>
<p>If you&#8217;re working with <a title="My posts on Kentico BizForm's" href="http://www.johnnycode.com/blog/tag/kentico-bizforms/" target="_blank">BizForm&#8217;s</a> programmatically you&#8217;re going to need to get the ID of a specific row so you can update or delete it. If you know the table structure, there&#8217;s nothing stopping you from going straight to the database, but if you do it using Kentico API&#8217;s and queries the code should be more upgrade-friendly.</p>
<p>This code makes some minor assumptions that are hard coded, but could be easily abstracted out:</p>
<ul>
<li>The BizForm&#8217;s code name is &#8220;ContactUs&#8221; with an ID field (Primary Key) of &#8220;ContactUsId&#8221;.</li>
<li>I&#8217;m using a hard-coded where condition getting the first record. This could easily be changed to pass in another parameter to search on.</li>
</ul>
<p>Without further ado, here&#8217;s the code:</p>
<pre class="prettyprint ">public int GetRecordId()
{
    // Given the Code Name of the BizForm and the current site, get the BizForm object.
    var bizFormInfo = BizFormInfoProvider.GetBizFormInfo(&quot;ContactUs&quot;, uxBizForm.SiteName);

    if (bizFormInfo != null)
    {
        var dataClassInfo = DataClassInfoProvider.GetDataClass(bizFormInfo.FormClassID);

        if (dataClassInfo != null)
        {
            // Using the built in Select query, get the record we're looking for.
            var connection = ConnectionHelper.GetConnection();
            var whereCondition = String.Format(&quot;ContactUsId = '1'&quot;);
            var dataSet = connection.ExecuteQuery(dataClassInfo.ClassName + &quot;.selectall&quot;, null, whereCondition);

            // Note the use of Kentico's aptly named DataHelper class.
            if (!DataHelper.DataSourceIsEmpty(dataSet) &amp;amp;&amp;amp; dataSet.Tables[0].Rows.Count == 1)
            {
                return ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0);
            }
        }
    }

    // If we get here, we didn't find a valid record.
    // If we get here you should probably do one of the following:
    //   Redirect to the &quot;new record&quot; page
    //   Redirect to an error page
    //   Or throw an exception
    return 0;
}</pre>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/bYn5jCH4MlY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/02/22/get-bizform-record-id/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/02/22/get-bizform-record-id/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=get-bizform-record-id</feedburner:origLink></item>
		<item>
		<title>How to Recursively Get Files in C# the Easy Way</title>
		<link>http://feedproxy.google.com/~r/JohnnyCode/~3/Oo-HTG0aVZE/</link>
		<comments>http://www.johnnycode.com/blog/2012/02/21/how-to-recursively-get-files-in-c-the-easy-way/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 13:00:37 +0000</pubDate>
		<dc:creator>John Bubriski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Files and I/O]]></category>

		<guid isPermaLink="false">http://www.johnnycode.com/blog/?p=1075</guid>
		<description><![CDATA[Need to get all the files contained in a directory, recursively searching through sub directories? No problem! Here is how to do it without writing your own recursive function: var fileNames = Directory.GetFiles(directoryName, &#34;*.*&#34;, SearchOption.AllDirectories); That&#8217;s it! No explicit recusrion required! If you want to do searching where you can stop when a given file [...]]]></description>
			<content:encoded><![CDATA[<p>Need to get all the files contained in a directory, recursively searching through sub directories? No problem!</p>
<p>Here is how to do it without writing your own recursive function:</p>
<pre class="prettyprint ">var fileNames = Directory.GetFiles(directoryName, &quot;*.*&quot;, SearchOption.AllDirectories);</pre>
<p>That&#8217;s it! No explicit recusrion required!</p>
<p>If you want to do searching where you can stop when a given file is found, then you would need to implement the recursion yourself. This article shows you how to do that if needed:</p>
<p><a href="http://support.microsoft.com/kb/303974">How to recursively search directories by using Visual C#</a></p>
<img src="http://feeds.feedburner.com/~r/JohnnyCode/~4/Oo-HTG0aVZE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.johnnycode.com/blog/2012/02/21/how-to-recursively-get-files-in-c-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.johnnycode.com/blog/2012/02/21/how-to-recursively-get-files-in-c-the-easy-way/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-recursively-get-files-in-c-the-easy-way</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.johnnycode.com @ 2012-05-17 18:54:08 -->

