<?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:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Devlicio.us - Just the Tasty Bits</title><link>http://devlicio.us/blogs/</link><description>Your Agile .NET Community</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Devlicious" /><feedburner:info uri="devlicious" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>.NetRocks - Making the Transition from XAML to Html</title><link>http://feedproxy.google.com/~r/Devlicious/~3/EYtCqC47JWw/netrocks-making-the-transition-from-xaml-to-html.aspx</link><pubDate>Tue, 21 May 2013 11:45:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111296</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Recently I sat down as a guest with Richard and Carl on &lt;a href="http://www.dotnetrocks.com/"&gt;.Net Rocks&lt;/a&gt; and recorded a show on my experiences on &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=873"&gt;migrating from XAML to HTML&lt;/a&gt;.&amp;nbsp; Chatting w/ Richard and Carl is always great.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;In this episode we tried to focus on my experiences on moving from XAML to Html but when you have 3 guys w/ A.D.D. staying on course is always a challenge :)&amp;nbsp; We were able to talk about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We talked about &lt;a href="http://devlicio.us/controlpanel/blogs/posteditor.aspx/typescriptlang.org"&gt;TypeScript&lt;/a&gt; and how it can make the conversion from .Net to JavaScript easier&lt;/li&gt;
&lt;li&gt;We talked about MVVM and how developers LOVE this pattern&lt;/li&gt;
&lt;li&gt;We talked about how Winforms is still prevalent in the corporate world&amp;hellip; DEAL WITH IT &lt;/li&gt;
&lt;li&gt;We talked about many of the things in XAML that can translate to HTML
&lt;ul&gt;
&lt;li&gt;MVVM&lt;/li&gt;
&lt;li&gt;Knockout&lt;/li&gt;
&lt;li&gt;XAML layout concepts loosely translate to HTML layout concepts&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;We talked about my &lt;a href="http://devlicio.us/controlpanel/blogs/posteditor.aspx/pluralsight.com/training"&gt;Pluralsight&lt;/a&gt; course on &lt;a href="http://bit.ly/18FoNxJ"&gt;Html from the XAML Developer&lt;/a&gt;.&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;Even plugged my next Pluralsight course &amp;ndash; MVVM w/ Knockout for the XAML developer&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Again, thanks Richard and Carl, I had a BLAST.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111296" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/EYtCqC47JWw" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Announcement/default.aspx">Announcement</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Pluralsight/default.aspx">Pluralsight</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/05/21/netrocks-making-the-transition-from-xaml-to-html.aspx</feedburner:origLink></item><item><title>TypeScript references not being created correctly during drag-n-drop</title><link>http://feedproxy.google.com/~r/Devlicious/~3/I9SfOJ_n_Xk/typescript-references-not-being-created-correctly-during-drag-n-drop.aspx</link><pubDate>Mon, 13 May 2013 11:49:58 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111148</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;One of the viewers of my &lt;a href="http://bit.ly/18FoNxJ"&gt;Html for the XAML developer&lt;/a&gt; course over on &lt;a href="http://pluralsight.com/training/"&gt;Pluralsight&lt;/a&gt; sent me a question regarding the ability to drag and drop a d.ts file onto a TypeScript file and have the reference added correctly.&lt;/p&gt;  &lt;p&gt;He said that when he dropped the d.ts file he was expecting to get something like:&lt;/p&gt;  &lt;p&gt;/// &amp;lt;reference path=&amp;quot;../something.d.ts&amp;quot; /&amp;gt;&lt;/p&gt;  &lt;p&gt;However, what he got was:&lt;/p&gt;  &lt;p&gt;c:\user\[usernamehere]\file\…&lt;/p&gt;  &lt;p&gt;To be honest I was not sure what the issue was but did ask 2 questions:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Do you have the &lt;a&gt;TypeScript&lt;/a&gt; IDE plugin installed?&lt;/li&gt;    &lt;li&gt;Do you have &lt;a href="http://vswebessentials.com/"&gt;Web Essentials&lt;/a&gt; installed?&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Turns out he did not have Web Essentials installed, which it appears is what gives you the nice ability to drag-drop a Typescript file into your editor and have it provide the correct reference syntax.&amp;#160; I honestly was not aware that it was Web Essentials which did this, just assumed it was part of the TypeScript plugin.&lt;/p&gt;  &lt;p&gt;Moral of the story, if you have not already installed Web Essentials DO SO NOW…!   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;  &lt;p&gt;P.S. If you are looking to make the jump from XAML based development to HTML development check out my &lt;a href="http://bit.ly/18FoNxJ"&gt;HTML for the XAML Developer&lt;/a&gt; Pluralsight course&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111148" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/I9SfOJ_n_Xk" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/05/13/typescript-references-not-being-created-correctly-during-drag-n-drop.aspx</feedburner:origLink></item><item><title>Typescript Bundler Issue - Not transforming to JavaScript</title><link>http://feedproxy.google.com/~r/Devlicious/~3/jBgAdQ35N1o/typescript-content-type-issue.aspx</link><pubDate>Sat, 11 May 2013 18:42:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111145</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Today one of the viewers of my &lt;a href="http://pluralsight.com/training/Courses/TableOfContents/html-for-xaml-developers"&gt;Pluralsight&lt;/a&gt; course was having issues and I was trying to help him via email, but to no avail.&amp;nbsp; I asked him to send me his project so I could take a look myself.&amp;nbsp; I ran the project and sure enough things were odd.&amp;nbsp; I looked at his Typescript syntax and everything looked right, as you see below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3824F2AD.png"&gt;&lt;img height="150" width="644" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2BB96035.png" alt="image" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I next took a look to ensure the JavaScript was being loaded correctly and at first glance everything looked right, but then I noticed that the loaded file was NOT JavaScript but rather the raw, untransformed TypeScript.&amp;nbsp; At this second I knew the issue.&amp;nbsp; The Bundler was not bundling the Typescript and turning it into JavaScript.&lt;/p&gt;
&lt;p&gt;I checked the bundle configuration and everything looked ok, but clearly there was an issue.&amp;nbsp; After some continued looking I noticed that the TypeScript Bundlertransformer had not been installed.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Once I added the &lt;a href="http://nuget.org/packages/BundleTransformer.TypeScript/1.6.23"&gt;BundleTransformer.Typescript&lt;/a&gt; nuget package and recompile the application the world was a happy place.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;P.S. If you are looking to make the jump from XAML based development to HTML development check out my &lt;a href="http://pluralsight.com/training/Courses/TableOfContents/html-for-xaml-developers"&gt;HTML for the XAML Developer&lt;/a&gt; Pluralsight course&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111145" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/jBgAdQ35N1o" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/05/11/typescript-content-type-issue.aspx</feedburner:origLink></item><item><title>Putting the Dynamic back into TypeScript</title><link>http://feedproxy.google.com/~r/Devlicious/~3/bcB4quV7rtg/putting-the-dynamic-back-into-typescript.aspx</link><pubDate>Wed, 08 May 2013 10:56:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111132</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>9</slash:comments><description>&lt;p&gt;One of the really powerful features that TypeScript brings to the JavaScript world is some Static Typing, even if it is only at code/compile time.&amp;#160; With TypeScript I can say that an object is of a certain type which implies there are only a limited set of properties/methods available to me.&amp;#160; This is great, but it does limit the core power of JavaScript and dynamic languages in general.&lt;/p&gt;  &lt;p&gt;Given the static nature of TypeScript, (yes I can choose to ignore this feature, but why?) which I want in most cases, the following will cause me compile time issues.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_27C9A2C5.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_393C944E.png" width="363" height="124" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The reason this is causing me issues is because MemberInitContext does NOT contain a LoadChoachingStaffStats property, but I know that the caller may provide an object which does contain this object.&amp;#160;&amp;#160; Below is my definition for MemberInitContext.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_34C61387.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_1B5E104D.png" width="345" height="150" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Given I know this property MAY be provided at runtime I have a decision to make.&amp;#160; I can do any of the following to resolve my build errors.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Add the property to the MemberInitContext &lt;/li&gt;    &lt;li&gt;Create a inherited type which contains this property &lt;/li&gt;    &lt;li&gt;Change my constructor to take an ‘any’ rather than a type &lt;/li&gt;    &lt;li&gt;Add the dynamic back into TypeScript &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I am going to choose the last option here, but how?&amp;#160; Simple, by redefining the variable to an any INSIDE my constructor as below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_48DF3010.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_5D647F8E.png" width="367" height="133" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By declaring my type as an ‘any’ TypeScript is happy and lets me hack away and complete my tasks.&lt;/p&gt;  &lt;p&gt;Long story shot is that even though TypeScript tries to impose Static typing, which is AWESOME in most cases, you can still force it back to dynamic if you want.&lt;/p&gt;  &lt;p&gt;Till Next Time,&lt;/p&gt;  &lt;p&gt;P.S. Check out my &lt;a href="http://pluralsight.com/training/Courses/TableOfContents/html-for-xaml-developers"&gt;HTML for the XAML developer&lt;/a&gt; course on &lt;a href="http://pluralsight.com/training"&gt;Pluralsight&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111132" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/bcB4quV7rtg" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/05/08/putting-the-dynamic-back-into-typescript.aspx</feedburner:origLink></item><item><title>My first Pluralsight course (HTML for the XAML Developer) as gone live</title><link>http://feedproxy.google.com/~r/Devlicious/~3/l3hYOPkK_Tc/my-first-pluralsight-course-html-for-the-xaml-developer-as-gone-live.aspx</link><pubDate>Mon, 06 May 2013 11:08:47 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111131</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;For the past 2 months I have been working on my first &lt;a href="http://pluralsight.com/training/Courses/TableOfContents/html-for-xaml-developers"&gt;Pluralsight course&lt;/a&gt;, and it has finally gone LIVE.&amp;#160; I had a great time building this course and I hope it shows.&amp;#160; In fact I enjoyed it so much I am currently working on my 2nd course.&lt;/p&gt;  &lt;p&gt;This course, HTML for the XAML Developer is intended to help XAML based developers (WPF or Silverlight) make the transition to HTML development.&amp;#160; I take you, the viewer, through the exercise of porting an existing XAML based application over to be an HTML based one.&amp;#160; In this course I used many frameworks but I tried to keep it as vanilla as possible.&amp;#160; I know there are 100 different ways to to build HTML sites and even more tools and libraries but I really wanted to focus on many of the basics.&lt;/p&gt;  &lt;p&gt;I hope everyone who watches will enjoy the course.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Module Listings&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Getting Started – Overview of what we are going to be working on along w/ a quick start of some of the tools&lt;/li&gt;    &lt;li&gt;Porting our ToDo Listing Screen – Part 1 - Introduce many of the basics and build a simple listing screen of items&lt;/li&gt;    &lt;li&gt;Porting our ToDo Listing Screen – Part 2 – Add some styling and enhanced features&lt;/li&gt;    &lt;li&gt;Porting our ToDo Maintenance Screen – Part 1 – Introduce many data entry techniques and basis persistence.&lt;/li&gt;    &lt;li&gt;Porting our ToDo Maintenance Screen – Part 2 – Data Validation&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111131" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/l3hYOPkK_Tc" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Pluralsight/default.aspx">Pluralsight</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/05/06/my-first-pluralsight-course-html-for-the-xaml-developer-as-gone-live.aspx</feedburner:origLink></item><item><title>Inheritance issue w/ Typescript (JavaScript) and MVC Bundling Ordering</title><link>http://feedproxy.google.com/~r/Devlicious/~3/XO6hJb_1AWE/inheritance-issue-w-typescript-and-mvc-bundling-ordering.aspx</link><pubDate>Tue, 30 Apr 2013 13:08:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111125</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Today I extended one of our classes to use inheritance via Typescript (love that).&amp;nbsp; When I refreshed the page I received an error here&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_4DA86122.png"&gt;&lt;img height="123" width="405" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2CB77F2C.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" title="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;When I dropped to the Chrome debugger and outputted both the values for both &amp;lsquo;d&amp;rsquo; and &amp;lsquo;b&amp;rsquo; I was a bit shocked.&amp;nbsp; &amp;lsquo;d&amp;rsquo; was valid, but &amp;lsquo;b&amp;rsquo; was undefined.&amp;nbsp; I tried a whole slew of things but nothing came to mind.&amp;nbsp; Of course I thought maybe I was using inheritance wrong, but my syntax was right.&lt;/p&gt;
&lt;p&gt;After some digging online I found this &lt;a href="http://typescript.codeplex.com/workitem/627"&gt;link&lt;/a&gt; which talks about how a parent class has to be loaded prior to it child for everything to work.&amp;nbsp; This makes perfect sense given the way JavaScript parses code.&amp;nbsp; I had this brilliant idea that I would simply add a _ prefix to my base class name and that would have the file loaded first.&amp;nbsp; WRONG&amp;hellip; &lt;/p&gt;
&lt;p&gt;If you look at the image below you can see that _BaseViewModel.js is way at the bottom of the list and my error was being thrown in the AthleteListingViewModel&amp;hellip;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_680AE4EA.png"&gt;&lt;img height="160" width="606" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_03433DEC.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" title="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Somehow I needed to force the bundler to load the files in the order I wanted.&amp;nbsp; In our case I am NOT including each file into the bundle manually, rather I am using the &amp;lsquo;IncludeDirectory&amp;rsquo; feature.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;After a bit more searching I found this &lt;a href="http://havethunk.wordpress.com/2013/04/22/javascript-dependency-order-and-asp-net-mvc-bundles/"&gt;link&lt;/a&gt; which solved the same basic problem but in a much more complex way than I needed.&amp;nbsp; However it showed me how I could solve the problem in a few lines of code.&amp;nbsp; What I needed to do was create a new instance of IBundleOrderer and use it.&lt;/p&gt;
&lt;p&gt;This code is my AlphaSortedBundleOrderer which solved my issues.&lt;/p&gt;
&lt;pre name="code" style="display:none;" class="C#"&gt;public class AlphaSortedBundleOrderer : IBundleOrderer
{
    public IEnumerable OrderFiles(BundleContext context, IEnumerable files)
    {
        var sortedFiles = files.OrderBy(x =&amp;gt; x.Name).ToList();

        return sortedFiles;
    }
}&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt; After I created my new AlphaSortedBundleOrdered I just needed to use it in my bundler.&amp;nbsp; I did this as you see below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_708E4434.png"&gt;&lt;img height="101" width="530" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_12E5D9AE.png" alt="image" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Once I had my bundler setup correctly I re-ran the page and my .js files were ordered as expected.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_725E99FB.png"&gt;&lt;img height="96" width="515" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3DE579C6.png" alt="image" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now I am sure there is a 100 ways to solve this problem, but this worked for me.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111125" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/XO6hJb_1AWE" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/04/30/inheritance-issue-w-typescript-and-mvc-bundling-ordering.aspx</feedburner:origLink></item><item><title>Knockout Click binding and the ‘this’ context</title><link>http://feedproxy.google.com/~r/Devlicious/~3/XOFvl8AXtSM/knockout-click-binding-and-the-this-context.aspx</link><pubDate>Mon, 29 Apr 2013 13:05:57 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:111118</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;When using &lt;a href="http://knockoutjs.com/"&gt;Knockout JS&lt;/a&gt; wiring to the click binding is cake and simply just works.&amp;#160; Or does it?&lt;/p&gt;  &lt;p&gt;Per the &lt;a href="http://knockoutjs.com/documentation/click-binding.html"&gt;documentation&lt;/a&gt; there are multiple ways to wire the click binding within your html.&amp;#160; Assume you have a method such as (the code below is TypeScript)&lt;/p&gt;  &lt;pre class="C#" style="display:none;" name="code"&gt;        public AddMember(member: MemberViewModel) {
            var self = this;

            // method body here 
        }&lt;/pre&gt;

&lt;p&gt;You can do any of the following:&lt;/p&gt;

&lt;pre class="C#" style="display:none;" name="code"&gt;data-bind=”click: myFunction()” – this will pass in the current $data instance in by default

data-bind=”click: function(data, event){ myFunction($data, data, event)}” – this will manually pass in the current $data instance

data-bind=”click: myfunction.bind($data)”&lt;/pre&gt;

&lt;p&gt;All of the above will accomplish the same goal, passing in the current $data object into the underlying method.&amp;#160; However, what appears to be the same is actually quite different.&amp;#160; The difference comes in when you are going to use the ‘this’ context.&amp;#160; Lets take a deeper look.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;‘this’ context for option 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2DD552DF.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_620C0CD6.png" width="404" height="41" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;‘this’ context for option 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_48A4099C.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_6852E364.png" width="404" height="37" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;‘this’ context for option 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_7CD832E2.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_038B3C66.png" width="404" height="37" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Did you notice the difference?&amp;#160; 2 of the options (1 &amp;amp; 3) set the ‘this’ context equal to the passed in $data object.&amp;#160; Option 2 has the context set to the $parent object (in our case the view model).&lt;/p&gt;

&lt;p&gt;Now I am NOT saying which one is right and which one is wrong because they are all right.&amp;#160; However, I just want to make sure everyone is aware of the differences.&amp;#160; In many cases i use option 2 because I want direct access to the underlying view model and this provides this.&lt;/p&gt;

&lt;p&gt;I am sure there are many different ways in JavaScript/Knockout to get the parent View Model but honestly I like low friction and option 2 provides this for me.&lt;/p&gt;

&lt;p&gt;Till next time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=111118" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/XOFvl8AXtSM" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Knockout.js/default.aspx">Knockout.js</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/04/29/knockout-click-binding-and-the-this-context.aspx</feedburner:origLink></item><item><title>Validating all observables w/ Knockout validation and Typescript</title><link>http://feedproxy.google.com/~r/Devlicious/~3/7am4_IbRfr8/validating-all-observables-w-knockout-validation-and-typescript.aspx</link><pubDate>Sun, 21 Apr 2013 10:52:11 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:110672</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;a href="http://knockoutjs.com"&gt;Knockout&lt;/a&gt; js is an awesome MVVM framework for HTML/Javascript development and there is an extension library which performs data validation called &lt;a href="https://github.com/Knockout-Contrib/Knockout-Validation/wiki"&gt;Knockout.Validation&lt;/a&gt; which is an equally awesome library.&amp;#160; Today when doing some coding I needed to validate that all properties on a VM were valid. A quick search showed me this was very easy and should just work.&amp;#160; However, I am using Typescript and for all of its awesomeness it sometimes makes life a bit more challenging than expected.&lt;/p&gt;  &lt;p&gt;To validate an entire observable all you should need to do is first tell the validation library that your vm is under validation by doing&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_76EF51D5.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_07F6106A.png" width="383" height="66" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;and then you can simply call a .isValid() on your VM as such.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_1C7B5FE8.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_25D7251C.png" width="330" height="61" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;However, when doing this in Typescript I was getting the red squiggly as you see here.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3E66C26C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_39F041A5.png" width="306" height="48" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At first I was not sure why, so I decided to take a peek at the source for the validation and I came across the code you see below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3579C0DE.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_391A6C6C.png" width="644" height="416" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you can see, the highlighted yellow is where the .isValid() method is being added to object (obj == your passed in viiew model) so I KNOW that my view model has a .isValid.&amp;#160; Sure enough at runtime if I hit a breakpoint and did this.isValid() i would get the response I was expecting.&amp;#160; However, because .isValid() was being added to my VM dynamically (this is the amazing power of JavaScript) Typescript did not know about the method and it was causing compile time errors.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;How to fix this?&lt;/p&gt;  &lt;p&gt;The simple solution that I found was to ‘fake’ Typescript into thinking that the .isValid computed is on my VM from the start.&amp;#160; I did this by adding the following to my VM&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_33CE166C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3361E377.png" width="352" height="39" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now you will notice that I am simply declaring the computed I am NO assigning it and that is ok.&amp;#160; In fact if you look at the generated output from the Typescript compiler you will NOT see a computed created for .isValid().&amp;#160; But this does not matter.&amp;#160; The Typescript compiler thinks it is there so you are free to use it off of your VM as you see here.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_1C7B5FE8.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_25D7251C.png" width="330" height="61" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After adding my declaration for isValid() I was good to go and my code worked as expected both at code time and run time.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=110672" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/7am4_IbRfr8" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Knockout.js/default.aspx">Knockout.js</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/04/21/validating-all-observables-w-knockout-validation-and-typescript.aspx</feedburner:origLink></item><item><title>Typescript, jQuery and the ‘this’ context causing issues</title><link>http://feedproxy.google.com/~r/Devlicious/~3/-6VCT4bYgBc/typescript-jquery-and-the-this-context-causing-issues.aspx</link><pubDate>Fri, 12 Apr 2013 15:36:26 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:109644</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Today I was in the middle of porting some raw javascript over to TypeScript as well as moving inline javascript into separate classes.&amp;#160; In the middle of doing this I started to run into some really odd stuff.&amp;#160; Namely, the ‘this’ context in one of my methods was set to window, not to the parent object.&amp;#160; This was really weird and at first I thought maybe it had to do w/ Inheritance and Typescript (this class implemented a base class).&amp;#160; Sadly even when I removed the base class I was still getting the results.&lt;/p&gt;  &lt;p&gt;After a bunch of digging I was able to find the root cause, Derik was doing something stupid and jQuery was making it worse :)&lt;/p&gt;  &lt;p&gt;In order to get some feedback and to help illustrate my issue.&lt;/p&gt;  &lt;p&gt;Here is what my Typescript class which was having the issue looked like.&amp;#160; The box in red is what was throwing the error.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_7340CAAC.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_061A6FB9.png" width="546" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From Chrome’s debugger when I would output ‘this’ it would be the browsers window object, not my parents object.&amp;#160; This told me something was screwed up but I could not find the cause.&amp;#160; That was until I started walking the call stack to see WHERE PerformSearch was being called.&amp;#160; Turns out PerformSearch was being called by jQuery… that was odd.&amp;#160; In fact below is the code making the call.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_0781233C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_373ECBBB.png" width="653" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Again, why was jQuery calling my method I had not told it to.&amp;#160; Well I kept walking the stack and I realized that this was being called during a .ajax call as seen below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2BA90E7C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2013513D.png" width="555" height="58" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It turns out that the ‘data’ object I was passing across the wire was not just a property bag, but it had methods.&amp;#160; These methods referenced ‘this’ and when jQuery tried to searlize the object it is executing the functions, and when it does the ‘this’ context is wrong and BOOM.&lt;/p&gt;  &lt;p&gt;To solve this issue I simply refactored my code to NOT have a method and then it just worked.&lt;/p&gt;  &lt;p&gt;My question is this.&amp;#160; Is what I was doing just dumb and I was an idiot, or is there a way to tell jQuery to NOT try and call my methods during serialization?&amp;#160; &lt;/p&gt;  &lt;p&gt;Till Next time,&lt;/p&gt;  &lt;p&gt;P.S. I know I could have guarded against this in my method by checking that ‘this != window’ but that felt dirty and I had a better solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=109644" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/-6VCT4bYgBc" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/04/12/typescript-jquery-and-the-this-context-causing-issues.aspx</feedburner:origLink></item><item><title>Moving a TFS Git Repository to Github</title><link>http://feedproxy.google.com/~r/Devlicious/~3/z4ubaQEvmQ0/moving-a-tfs-git-repository-to-github.aspx</link><pubDate>Tue, 09 Apr 2013 11:16:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:109235</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;We gave using the git support in TFS the old college try but the friction and issues were just too much so we decided to move our repository over to github.&amp;nbsp; I am not going to go over our issues w/ TFS git here, but I am thinking of creating a separate post for it.&lt;/p&gt;
&lt;p&gt;Because we already had our repository w/ change history setup all we really wanted to do was &amp;lsquo;change remote origin&amp;rsquo; for our repository and here are the steps WE took to accomplish this.&lt;/p&gt;
&lt;p&gt;Our Steps (it is assume you already have a github account setup)&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to github.com and create your repository.&lt;/li&gt;
&lt;li&gt; Create a copy of your existing tfs/git source and move it to a new directly.&amp;nbsp; I do this simply to ensure I don&amp;rsquo;t screw anything up and have to do a new pull (i am lazy and xcopy is faster).&amp;nbsp; &lt;ol&gt;
&lt;li&gt;from c:\TFSRepo &amp;ndash;&amp;gt; c:\GithubRepo&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;Open a git command prompt and CD into the destination directory from step 1&lt;/li&gt;
&lt;li&gt;From the command prompt run &amp;lsquo;git remote &amp;ndash;v&amp;rsquo;&amp;nbsp; this command is a sanity check to double check the current origin of your repository&lt;/li&gt;
&lt;li&gt;From the command prompt run &amp;lsquo;git remote rm origin&amp;rsquo; this command will remove/clear the origin settings for your reporsitory&lt;/li&gt;
&lt;li&gt;From the command prompt run &amp;lsquo;git remote add origin &lt;a href="https://github.com/[AccountUserNameHere]/[RepoNameHere].git&amp;rsquo;"&gt;https://github.com/[AccountUserNameHere]/[RepoNameHere].git&amp;rsquo;&lt;/a&gt; this command will set the origin information to your new repository path in github.&amp;nbsp; Pay attention to the url&amp;rsquo;s casing as github is case sensitive and you may experience issues if the casing is off.&amp;nbsp; &lt;ol&gt;
&lt;li&gt;PS. You can get the url above from the github repository page&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;From the command prompt run &amp;lsquo;git push origin master&amp;rsquo; this command will push your current files up to github and publish them.&amp;nbsp; Please note that this will ONLY push the master branch.&amp;nbsp; If you want to push other branches you will need to do a &amp;lsquo;git push origin [branchnamehere]&amp;rsquo; for each branch.&lt;/li&gt;
&lt;li&gt;Refresh the github.com project page and rejoice in the fact that you are out of TFS and your pain should be greatly reduced :)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These are the steps that worked for us, of course they may be different or better ways, but again these worked for us.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=109235" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/z4ubaQEvmQ0" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/GitHub/default.aspx">GitHub</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Git/default.aspx">Git</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/04/09/moving-a-tfs-git-repository-to-github.aspx</feedburner:origLink></item><item><title>Using Entity Framework Profiler to find Undisposed Object Context’s</title><link>http://feedproxy.google.com/~r/Devlicious/~3/nbMnhb5Ty9I/using-entity-framework-profiler-to-find-undisposed-object-context-s.aspx</link><pubDate>Fri, 29 Mar 2013 13:17:11 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:107122</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;If you are using Entity Framework, or any other ORM for that matter you need to head over to &lt;a href="http://www.hibernatingrhinos.com/products/EFProf"&gt;Hibernating Rhinos&lt;/a&gt; and buy a copy of Entity Framework Profiler, the license will pay for itself in no time flat.&lt;/p&gt;  &lt;p&gt;When using any ORM, but in our case EF it is recommended, ok I would say required that you dispose or close your Data Context once you are done with your database transitions.&amp;#160; Not closing the context will not immediately bring your system to its knees, but over time as your grow and scale you are going to start noticing memory and performance issues.&amp;#160; Sure, you can let the .Net Garbage collector dispose of your context, but you really should be a responsible developer and clean up after yourself, trust me it is worth the effort.&lt;/p&gt;  &lt;p&gt;When using EFProfiler you can very easily determine when you left a context dangling open, all you need to do is look at the timings on the executed statements as seen below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_15199138.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3B11D23F.png" width="404" height="219" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is the code which produced the above&lt;/p&gt;  &lt;pre class="C#" style="display:none;" name="code"&gt;var ve = new Entities(DataUtilities.GetConnectionString());&lt;/pre&gt;

&lt;p&gt;Now I am only showing you the creation of this because as you can assume it was NEVER closed.&lt;/p&gt;

&lt;p&gt;To close this I could manually call the .Dispose method or I could use a using statement as seen here&lt;/p&gt;

&lt;pre class="C#" style="display:none;" name="code"&gt;using ( var ve = new Entities(DataUtilities.GetConnectionString()) )
{
}&lt;/pre&gt;

&lt;p&gt;By using the Using statement above I am explicitly telling the runtime to close the connection, thus freeing my resources and reducing my over head.&amp;#160; The image below shows the statement now&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_285CD888.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_78A1C0B9.png" width="407" height="163" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As you can see you can find open connections w/ little ease using Entity Framework profiler.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=107122" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/nbMnhb5Ty9I" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/29/using-entity-framework-profiler-to-find-undisposed-object-context-s.aspx</feedburner:origLink></item><item><title>Windows 8 Development w/ C# and XAML – Video Shoot</title><link>http://feedproxy.google.com/~r/Devlicious/~3/f0LanCVnIlU/windows-8-development-w-c-and-xaml-video-shoot.aspx</link><pubDate>Fri, 22 Mar 2013 12:06:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:104637</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>7</slash:comments><description>&lt;p&gt; A while back I was commissioned to do a video series for Pearson Education.&amp;nbsp; This series will be available on their site as well as on Safari online in the near future.&amp;nbsp; One of the unique things Pearson does for their videos is video headshots of you introducing your lessons, which by the way is way harder than I ever thought.&lt;/p&gt;
&lt;p&gt;Yesterday the &lt;a href="http://www.eaglevideo.com/"&gt;videographer&lt;/a&gt; stopped by to do the shoot and I took a few photos so I thought I would share them.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000004_5F00_3FE50C74.jpg"&gt;&lt;img height="184" width="244" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000004_5F00_thumb_5F00_236D3BF6.jpg" alt="WP_000004" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="WP_000004" /&gt;&lt;/a&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000003_5F00_23010901.jpg"&gt;&lt;img height="184" width="244" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000003_5F00_thumb_5F00_3E396202.jpg" alt="WP_000003" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="WP_000003" /&gt;&lt;/a&gt; &lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000002_5F00_19A7D47E.jpg"&gt;&lt;img height="184" width="244" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000002_5F00_thumb_5F00_49657CFD.jpg" alt="WP_000002" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="WP_000002" /&gt;&lt;/a&gt; &lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000001_5F00_128B28B7.jpg"&gt;&lt;img height="184" width="244" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000001_5F00_thumb_5F00_2DC381B8.jpg" alt="WP_000001" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="WP_000001" /&gt;&lt;/a&gt; &lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000000_5F00_5B44A17B.jpg"&gt;&lt;img height="184" width="244" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/WP_5F00_000000_5F00_thumb_5F00_5661EDBF.jpg" alt="WP_000000" border="0" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" title="WP_000000" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I have the link to the live content I will share it here as well.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=104637" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/f0LanCVnIlU" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Windows+8/default.aspx">Windows 8</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/22/windows-8-development-w-c-and-xaml-video-shoot.aspx</feedburner:origLink></item><item><title>Deploying Database Projects with psake</title><link>http://feedproxy.google.com/~r/Devlicious/~3/pgbJzMmmcxY/deploying-database-projects-with-psake.aspx</link><pubDate>Tue, 19 Mar 2013 10:32:16 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:103233</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;Recently I joined a project that was using a Sql Server Database Project to manage their DB scheme and so far it is pretty cool.&amp;#160; This project type like others has a deploy/publish option which will allow you to publish your changes to a target database.&amp;#160; And like other project types this is very easy to do via Visual Studio, but if you know me you will know that I like to automate tasks like these rather than have to use the IDE so I did.&amp;#160; Here is what I did in order to use &lt;a href="https://github.com/JamesKovacs/psake"&gt;pSake&lt;/a&gt;, a build automation tool written in powershell, to handle my clean, build and deployment of my database projects.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step 1: Learn&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Understand the automation options available for this &lt;a href="http://msdn.microsoft.com/en-US/library/aa833165(v=vs.80).aspx"&gt;project type&lt;/a&gt; and MSBuild&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step 2: Create your psake task file (database.upgrade.ps1)&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="C#" style="display:none;" name="code"&gt;Framework &amp;quot;4.0x64&amp;quot;

properties {
    $buildSolution = &amp;quot;Database.sqlproj&amp;quot;
    $targetServer = $parmTargetServer
    $targetDatabase = $parmTargetdatabase
    $databaseUsername = $parmDatabaseUsername
    $databasePassword = $parmDatabasePassword
}


task default -depends upgrade

task upgrade{

    Write-Host &amp;quot;Upgrading the $target_database database from $build_solution&amp;quot; 
        
    msbuild /target:clean`;build`;deploy 
                /p:UseSandboxSettings=false 
                /p:TargetDatabase=$targetDatabase 
                /p:TargetConnectionString=`&amp;quot;Data Source=$targetServer`;user id=$databaseUsername`;password=$databasePassword`;Pooling=False`&amp;quot; $buildSolution
    
}&lt;/pre&gt;

&lt;p&gt;**** Please not that the formatting of the MSBuild above will NOT RUN and is done to allow the sample code to be clean.&amp;#160; You the entire MSBuild task needs to be on ONE LINE ****&lt;/p&gt;

&lt;p&gt;**** I am setting my properties to ‘parm’ variables because I am passing these into the script by using the –&lt;a href="https://github.com/JamesKovacs/psake/wiki/How-can-I-pass-parameters-to-my-psake-script%3F"&gt;parameters&lt;/a&gt; feature of psake **** &lt;/p&gt;

&lt;p&gt;There is one part of the MSBuild task above that you MUST PAY ATTENTION TO, that is the way items are escaped.&amp;#160; They are being escaped with the back tick (`).&amp;#160; If you omit this you are going to get some odd errors depending on what you do.&amp;#160; These errors could range from ‘Multiple projects were provided’ to issues with the connection string not being formatted.&amp;#160; The root cause for these errors and the need to use the back tick (`) has to do with white space in the connection string… ugg&lt;/p&gt;

&lt;p&gt;One you have this psake task setup you can call it like any other task and it should just work.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=103233" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/pgbJzMmmcxY" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/PSake/default.aspx">PSake</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Powershell/default.aspx">Powershell</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/19/deploying-database-projects-with-psake.aspx</feedburner:origLink></item><item><title>Durandal 1.2.0 and Caliburn.Micro 1.5.0 Released!</title><link>http://feedproxy.google.com/~r/Devlicious/~3/Xa2ko-4A5Y0/durandal-1-2-0-and-caliburn-micro-1-5-0-released.aspx</link><pubDate>Tue, 19 Mar 2013 00:10:59 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:102953</guid><dc:creator>Rob Eisenberg</dc:creator><slash:comments>8</slash:comments><description>&lt;p&gt;Two awesome releases in the last week! Much thanks to the great community surrounding both projects! Here’s what’s new:&lt;/p&gt;  &lt;h3&gt;Durandal 1.2.0&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Tons of bug fixes.&lt;/li&gt;    &lt;li&gt;Lots of improvements to the router.&lt;/li&gt;    &lt;li&gt;Better support for integrating with Q, KendoUI and Dojo.&lt;/li&gt;    &lt;li&gt;More docs.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="https://github.com/BlueSpire/Durandal/blob/master/Changes.txt" target="_blank"&gt;Check out the full set of changes.&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Caliburn.Micro. 1.5.0&lt;/h3&gt;  &lt;p&gt;Nigel Sampson and Thomas Ibel are going to town these days! Some really cool stuff happening in this release. Here’s a few things:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Task and Async support (on all platforms except SL4 and WP71)&lt;/li&gt;    &lt;li&gt;Task/Coroutine integration.&lt;/li&gt;    &lt;li&gt;Actions can return tasks.&lt;/li&gt;    &lt;li&gt;More async stuff in general.&lt;/li&gt;    &lt;li&gt;Support for the WinRT Share Charm&lt;/li&gt;    &lt;li&gt;Support for the WinRT Settings Charm&lt;/li&gt;    &lt;li&gt;Various bug fixes and minor improvements throughout.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can get the latest versions of both of these frameworks on Nuget.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=102953" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/Xa2ko-4A5Y0" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/WPF/default.aspx">WPF</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/Xaml/default.aspx">Xaml</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/WPF_2F00_e/default.aspx">WPF/e</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/Caliburn/default.aspx">Caliburn</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/RIA/default.aspx">RIA</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/MVVM/default.aspx">MVVM</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/UI+Architecture/default.aspx">UI Architecture</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/Caliburn+Micro/default.aspx">Caliburn Micro</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/WP7/default.aspx">WP7</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/NuGet/default.aspx">NuGet</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://devlicio.us/blogs/rob_eisenberg/archive/tags/Durandal/default.aspx">Durandal</category><feedburner:origLink>http://devlicio.us/blogs/rob_eisenberg/archive/2013/03/18/durandal-1-2-0-and-caliburn-micro-1-5-0-released.aspx</feedburner:origLink></item><item><title>Where to put custom Knockout Binding Implementations</title><link>http://feedproxy.google.com/~r/Devlicious/~3/DQouLoXY6FI/where-to-put-custom-knockout-binding-implementations.aspx</link><pubDate>Sun, 17 Mar 2013 11:10:16 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:101875</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>10</slash:comments><description>&lt;p&gt;The other day I was creating my first &lt;a href="http://knockoutjs.com/documentation/custom-bindings.html"&gt;Knockout Custom Binding&lt;/a&gt; which was pretty straight forward.&amp;#160; But I was a bit stumped as to what was the ‘best’ practice for where to put this custom binding.&amp;#160; Of course I did not want to put it in my view model as that would defeat the purpose/idea behind creating a custom binding, which is to provide a global, reusable way to perform an action.&amp;#160; My gut told me to put the binding in its own file but I thought I would ask twitter for its advice and below are some of the responses I received, this told me I was on the right path.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_1F7F5A7A.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_35D79070.png" width="884" height="126" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Since the conclusion was to put all custom Knockout bindings in their own file the only thing left to do was to implement this.&amp;#160; Here is what I did.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Create CustomKnockoutBindings.ts file&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In my case I am using &lt;a href="http://typescriptlang.org"&gt;Typescript&lt;/a&gt; (in case .ts extension threw you off) So I needed to implement the code below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_32C5327B.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_6FE8EE00.png" width="730" height="410" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you look at the implemented code you should understand 2 things&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;We are going to create our bindings within the &lt;a href="http://docs.jquery.com/Tutorials:Introducing_%24%28document%29.ready%28%29"&gt;jQuery Document Ready&lt;/a&gt; method.&amp;#160; This will allow for our bindings to be created when the page loads.&amp;#160; This also prevents us from having to ‘call an init’ method from any of our view models&lt;/li&gt;    &lt;li&gt;We are extending the KnockoutBindingHandlers interface (this is found in knockout.d.ts).&amp;#160; We need to extend this interface otherwise you will get a compile error from Typescript saying that bindingHandlers.strikeThroughCompleted does not exist on KnockoutBindingHandlers&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Once you have the above implemented you should be good to go, only thing left to do now is to implement this in side your HTML.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Implement my custom binding in HTML&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_722576BC.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_7F8B89C2.png" width="821" height="65" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the code above you can see that I am using our strikeThroughCompleted binding in the same manor as the ‘text’ binding immediately to its left.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=101875" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/DQouLoXY6FI" height="1" width="1"/&gt;</description><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/17/where-to-put-custom-knockout-binding-implementations.aspx</feedburner:origLink></item><item><title>0 to 60 with Web API Slide Deck from Columbia Enterprise Guild</title><link>http://feedproxy.google.com/~r/Devlicious/~3/opPnhKYJTAc/0-to-60-with-web-api-slide-deck-from-columbia-enterprise-guild.aspx</link><pubDate>Fri, 15 Mar 2013 09:34:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:100631</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;The other night I had the opportunity to head down to Columiba SC to speak at their Enterprise Guild about Web API.&amp;nbsp; First I would like to thank everyone who showed up, I had a great time and I hope everyone found the information useful.&lt;/p&gt;
&lt;p&gt;Below is the content from the session:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://bit.ly/XDoe5h"&gt;Slides&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/15Qd0u8"&gt;IISHosted&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/WrU1Dd"&gt;Self Host&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/YwN4AG"&gt;Actions&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/YvBker"&gt;Filters&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/10PoZFi"&gt;Routing&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/154K2nW"&gt;Model Binding&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://bit.ly/13ZS71g"&gt;Dependency Injection&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have fun w/ the content and hope to see the group in the future.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=100631" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/opPnhKYJTAc" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WebApi/default.aspx">WebApi</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/15/0-to-60-with-web-api-slide-deck-from-columbia-enterprise-guild.aspx</feedburner:origLink></item><item><title>Building a Game With JavaScript: Making Things Move</title><link>http://feedproxy.google.com/~r/Devlicious/~3/4Bb38w8zlx0/building-a-game-with-javascript-making-things-move.aspx</link><pubDate>Wed, 13 Mar 2013 16:36:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:99712</guid><dc:creator>Christopher Bennage</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;i&gt;This is a continuation from the &lt;a href="http://dev.bennage.com/blog/2013/01/11/game-dev-02/" target="_blank"&gt;previous post&lt;/a&gt;.&lt;/i&gt;&lt;/p&gt;
&lt;h2&gt;Setting The Stage&lt;/h2&gt;

&lt;p&gt;The game we’re building will have waves of enemy ships fly in to attack the player’s units. Let’s begin by making a simple enemy as well as some dummy targets for them to attack. I’m going to keep the graphics very simple for the moment. Likewise we are going to focus on the enemy behavior and not worry about any player interaction just yet.&lt;/p&gt;

&lt;p&gt;&lt;img style="cursor:default;" class="right" src="http://dev.bennage.com/images/posts/game-dev-move-01.png" title="[little, yellow, different]" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;Here’s a &lt;a href="http://jsfiddle.net/bennage/HqYeD/18/"&gt;demo&lt;/a&gt; of what we’ll make. Click on the start screen to transition into the game. The little yellow rectangles are our enemy ships. Each one projects its own target as a little red circle. Once it touches its target, it projects a new one and then flies toward it.&lt;/p&gt;

&lt;p&gt;Let’s start from the top down. Our enemy units will “live” in our main screen for the game. (At least for the time being.) This screen needs to expose the same interface that we had for the start screen we made in the last post. We’ll also add a &lt;code&gt;start&lt;/code&gt; method that we’ll call just once in order to initialize things.&lt;/p&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;

&lt;p&gt;Here’s the implementation:&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;  var mainGameScreen = (function () {
    
        // the set of entities we&amp;#39;re updating and rendering
    var entities = [];
    // how many enemy ships do we want to start with
    var numOfEnemyShips = 12;
    
    // intitalize the screen, expected to be called
    // once when transitioning to the screen
    function start() {
        for (var i = 0; i &amp;lt;= numOfEnemyShips; i++) {
            // the numbers passed into `makeEnemyShip` could be anything 
            // they don&amp;#39;t need to be derived from `i`
            entities.push(makeEnemyShip(i * 10, i));
        }
    }

    // drawing the screen means drawing each of its constituents
    function draw(ctx) {
        // first, clean the canvas
        ctx.fillStyle = &amp;#39;black&amp;#39;;
        ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
        
        // delegate the drawing of each entity to itself
        // note the difference in the way the for loop is set up
        var entityIndex = entities.length - 1;
        for (; entityIndex != 0; entityIndex--) {
            entities[entityIndex].draw(ctx);
        }
    }

    // much like draw, we update each of the screen&amp;#39;s constituents
    function update(elapsed) {
        var entityIndex = entities.length - 1;
        for (; entityIndex != 0; entityIndex--) {
            entities[entityIndex].update(elapsed);
        }
    }

    // this is the object that will be the main screen
    return {
        draw: draw,
        update: update,
        start: start
    };
}());&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;Explanation&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;entities&lt;/code&gt; array will contain a list of the enemies we’re tracking. I used the name “entity” because this is a common term in game development. In general, it means something that has behavior and is drawn to the screen. Thus, you can expect entities to have &lt;code&gt;update&lt;/code&gt; and &lt;code&gt;draw&lt;/code&gt; methods. This is not a hard and fast definition though. You’ll find that the specifics of the definition can vary among engines, frameworks, and developers.&lt;/p&gt;

&lt;p&gt;In our &lt;code&gt;start&lt;/code&gt; function we populate &lt;code&gt;entities&lt;/code&gt; by invoking our (as yet undefined) &lt;code&gt;makeEnemyShip&lt;/code&gt; function. I’m passing in two numbers that &lt;code&gt;makeEnemyShip&lt;/code&gt; will use to set the x and y position of the ship. I could have used random numbers or even hard coded values, however deriving from the loop’s controls makes it easy to cluster all the ships in the upper left corner of the screen.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;draw&lt;/code&gt; and &lt;code&gt;update&lt;/code&gt; functions for the screen are very similar. They both iterate over &lt;code&gt;entities&lt;/code&gt; and invoke the corresponding function on each entity. They also pass along the necessary context. For &lt;code&gt;draw&lt;/code&gt;, this is the 2D drawing context of the canvas and for &lt;code&gt;update&lt;/code&gt; it’s the elapsed time since the last frame.&lt;/p&gt;

&lt;p&gt;Notice how the loop is structured differently from the loop in &lt;code&gt;start&lt;/code&gt;. This is a performance optimization; though it has little consequence with so small an array. On some browsers, the call to &lt;code&gt;length&lt;/code&gt; is a bit expensive. (Especially in cases when the array isn’t an array, but something that is &lt;a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-536297177"&gt;array-like&lt;/a&gt;.) This adds up when you make the call once per iteration of the loop. We move it out of the loop so that we only call it once. Check out &lt;a href="http://jsperf.com/loop-iteration-length-comparison-variations"&gt;this test&lt;/a&gt;. Performance optimizations are tricky and change every time new browsers are released. It’s easy to get confused, and I recommend profiling your code frequently to look for hot spots rather than just guessing about optimizations. I hope to talk more about them later, but if you want more now check out the book &lt;a href="http://www.amazon.com/Performance-JavaScript-Faster-Application-Interfaces/dp/059680279X"&gt;High Performance JavaScript&lt;/a&gt; by &lt;a href="http://www.nczonline.net/"&gt; Nicholas C. Zakas&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I had originally written my loops using the newer &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach"&gt;Array.forEach&lt;/a&gt; to iterate over &lt;code&gt;entities&lt;/code&gt;. However, this proved to be &lt;strong&gt;significantly&lt;/strong&gt; slower than a &lt;code&gt;for&lt;/code&gt; loop.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The screen’s &lt;code&gt;draw&lt;/code&gt; method also resets the canvas at the beginning of each iteration. If we did not do this, then every thing we drew on previous frames would still be present. For the start screen, I used &lt;code&gt;clearRect&lt;/code&gt; however here I used &lt;code&gt;fillRect&lt;/code&gt; with a solid color.&lt;/p&gt;

&lt;p&gt;Here’s a function that will produce a simple enemy. It follows the same structure we’ve been using, &lt;code&gt;update&lt;/code&gt; to handle the behavior and &lt;code&gt;draw&lt;/code&gt; to actually draw it on the screen.&lt;/p&gt;
&lt;h2&gt;Some Bad Guys&lt;/h2&gt;

&lt;p&gt;Our enemy ships are a little more complicated than the screen they live on. Visually, they &lt;em&gt;appear&lt;/em&gt; to have two components. The little yellow rectangle that moves about the screen and the phantom target that they project as a little red circle. In the final game, they will target one of the player’s units. However, the logic is very similar. In fact, it may become useful in debugging to how each enemy ship render something over it’s actual target.&lt;/p&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;// alias (and pre-compute) the angle of 
// a full circle (360°, but in radians)
var fullCircle = Math.PI * 2;

// invoke this function to create an emeny ship entity
// to add to the main game screen
function makeEnemyShip(x, y) {
    
    // position is set based upon the values
    // provided to the function
    var position = {
        x: x,
        y: y
    };
    // the diretion the ship is facing
    var orientation = 0;

    // how quickly can the ship turn?
    var turnSpeed = fullCircle / 50;
    // how quickly can the ship move?
    var speed = 2;
    
    // the phantom target the ship
    // is pursing
    var target = findNewTarget();    

    // the function invoked from the screen&amp;#39;s update
    function update(elapsed) {
        // determine how close we are to our target
        var y = target.y - position.y;
        var x = target.x - position.x;
        var d2 = Math.pow(x, 2) + Math.pow(y, 2);
        if (d2 &amp;lt; 16) {
            // we&amp;#39;ve essentially &amp;quot;touched&amp;quot; it,
            // so create a new target
            target = findNewTarget();
        } else {

            // what&amp;#39;s the different between our orientation
            // and the angle we want to face in order to 
            // move directly at our target
            var angle = Math.atan2(y, x);
            var delta = angle - orientation;
            var delta_abs = Math.abs(delta);

            // if the different is more than 180°, convert
            // the angle a corresponding negative value
            if (delta_abs &amp;gt; Math.PI) {
                delta = delta_abs - fullCircle;
            }

            // if the angle is already correct,
            // don&amp;#39;t bother adjusting
            if (delta !== 0) {
                // do we turn left or right?
                var direction = delta / delta_abs;
                // update our orientation
                orientation += (direction * Math.min(turnSpeed, delta_abs));
            }
            // constrain orientation to reasonable bounds
            orientation %= fullCircle;

            // use orientation and speed to update our position
            position.x += Math.cos(orientation) * speed;
            position.y += Math.sin(orientation) * speed;
        }

    }
    
    // the function invoked from the screen&amp;#39;s draw
    function draw(ctx) {
        
        // save the context&amp;#39;s state before we translate
        // and rotate
        ctx.save();

        // translate to the entity&amp;#39;s position
        ctx.translate(position.x, position.y);
        // rotate the canvas according to the 
        // entity&amp;#39;s orientation
        ctx.rotate(orientation);
        
        // now we begin the actual drawing
        ctx.fillStyle = &amp;#39;yellow&amp;#39;;
        // using negative number to center 
        // around the translated origin
        ctx.fillRect(-3, -1, 6, 2);
        // restore the canvas since we&amp;#39;re 
        // done drawing the entity 
        ctx.restore();

        // now we draw the phantom target
        // though we&amp;#39;ll do so without translating
        // since it&amp;#39;s so simle to draw
        ctx.beginPath();
        ctx.fillStyle = &amp;#39;rgba(255,0,0,0.5)&amp;#39;;
        ctx.arc(target.x, target.y, 2, 0, Math.PI * 2, true);
        ctx.fill();
    }

    // create a random x,y within the bounds of the canvas
    // note, we&amp;#39;ve hard coded the bounds
    function findNewTarget() {
        var target = {
            x: Math.round(Math.random() * 600),
            y: Math.round(Math.random() * 300)
        };

        return target;
    }

    // return an instance of the enemy,
    // it&amp;#39;s state is captured in the closure
    // of the functions
    return {
        draw: draw,
        update: update
    }
}&lt;/pre&gt;&lt;h3&gt;&lt;/h3&gt;&lt;h3&gt;Explanation&lt;/h3&gt;

&lt;p&gt;Each enemy ship will be responsible for tracking its own state. In this code, the state is captured in a closure. In later code, we’ll track the track in a more traditional way. (I haven’t ran tests yet but I think that using a closure may have a performance impact.)&lt;/p&gt;

&lt;p&gt;All of these variables represent the enemy ship’s state.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;var position = { x: 0, y: 0 };
var orientation = 0;
var turnSpeed = fullCircle / 50;
var speed = 2;
var target = findNewTarget();  
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;position&lt;/code&gt; is the location on the screen where we will render our ship.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Technically, the is the position in “world space”. World space is the logical space that entities in your game “live in”. This is distinct from “screen space”, which corresponds to the actual pixels on the screens. You can think of it this way: in your game you might have a circle with a radius of 10 and located at (100,100). However, where you draw it on the screen will depend upon where the player is viewing it from. If the player zooms in, the circle will grow larger but this doesn’t change the logical position or radius of the circle. We use the term “projection” to describe this. We project from world space into screen space based upon how the player is viewing the game world. The simplest project of course is just 1:1. Which means that there is no difference between world space and screen space. That’s what will stick with for the moment.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;orientation&lt;/code&gt; is the direction the ship is currently facing. Our ship will always travel in the direction of its orientation. This constraints causes the ship travel in smooth arcs as opposed to abruptly changing its course.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;turnSpeed&lt;/code&gt; and &lt;code&gt;speed&lt;/code&gt; represent how quickly the ship can turn and how fast it can travel respectively. We won’t be modifying these values after setting them, which means the ship will turn and travel at constant rates. These values represent the rates of change for &lt;code&gt;orientation&lt;/code&gt; and &lt;code&gt;position&lt;/code&gt;. Note also, we defined &lt;code&gt;turnSpeed&lt;/code&gt; in terms of &lt;code&gt;fullCircle&lt;/code&gt;. This is an alias for &lt;code&gt;Math.PI * 2&lt;/code&gt;; we are dealing in &lt;a href="http://en.wikipedia.org/wiki/Radian"&gt;radians&lt;/a&gt; and not degrees.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;target&lt;/code&gt; is a value with the shape &lt;code&gt;{ x: Number, y: Number }&lt;/code&gt;. The ship will always attempt to move towards this value by adjusting its &lt;code&gt;orientation&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;Update&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;update&lt;/code&gt; function is the real meat of the enemy ship. First, we check to see if we are close to our target. If we are close enough, we consider our goal accomplished and we set a new target. Otherwise, we change our &lt;code&gt;orientation&lt;/code&gt; so that we are flying toward our current target.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;var y = target.y - position.y;
var x = target.x - position.x;
var d2 = Math.pow(x, 2) + Math.pow(y, 2);&lt;/pre&gt;&lt;p&gt;&lt;code&gt;
&lt;/code&gt;&lt;/p&gt;
 
&lt;p&gt;&lt;img style="cursor:default;" class="right" src="http://dev.bennage.com/images/posts/game-dev-move-02.png" title="[calculating the distance]" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;Here, &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are really the distance between &lt;code&gt;target&lt;/code&gt; and &lt;code&gt;position&lt;/code&gt; along the respective axises. We want to know these values in order to calculate the distance between them. In general, you use the &lt;a href="http://en.wikipedia.org/wiki/Pythagorean_theorem"&gt;Pythagorean theorum&lt;/a&gt; to calculate distance. &lt;em&gt;For deeper dive into the math, watch &lt;a href="http://www.khanacademy.org/video/distance-formula"&gt;Distance Formula&lt;/a&gt; on Khan Academy.&lt;/em&gt; Finding the actual real distance uses a square root and calculating a square root is an expensive operation that’s best to avoid whenever you can.&lt;/p&gt;

&lt;p&gt;We can bypass the need by working with the distance² (hence the variable name &lt;code&gt;d2&lt;/code&gt;). We compare this against the hard-coded value of 16 (that’s 4²). In other words, if the distance between the ship and its target is less than 4 units we find a new target.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;if (d2 &amp;lt; 16) {
    target = findNewTarget();
}&lt;/pre&gt;&lt;p&gt;&lt;code&gt;
&lt;/code&gt;&lt;/p&gt;
 
&lt;p&gt;Once we’ve established what the ship’s target should be, we want the ship to move toward the target. As I’ve just mentioned, I’ve chosen to have the ship move at a constant speed. This means that it does not slow down or speed up. The only thing it can do is to change the direction it’s facing (&lt;code&gt;orientation&lt;/code&gt;). These sort of constraints determine the personality and character of your game. Bear in mind, you don’t need to simulate the physics to have a fun game. Instead, you need to establish behaviors for your game entities that are merely fun. Fortunately, fun behaviors can often be easier to implement that the actual physics. I recommend taking a look at &lt;a href="http://jsfiddle.net/bennage/HqYeD/18/"&gt;the demo&lt;/a&gt; and tweaking the &lt;code&gt;turnSpeed&lt;/code&gt; and &lt;code&gt;speed&lt;/code&gt; values to get a small taste for how the behavior can affect the game’s character.&lt;/p&gt;

&lt;p&gt;&lt;img style="cursor:default;width:336px;height:252px;" class="right" src="http://dev.bennage.com/images/posts/game-dev-move-03.png" title="[what&amp;#39;s the delta between the angles?]" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;In order to change the ship’s orientation we need to first determine where the ship &lt;em&gt;ought&lt;/em&gt; to be facing. The values of &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; we just calculated can be interpreted as a &lt;a href="http://en.wikipedia.org/wiki/Euclidean_vector"&gt;vector&lt;/a&gt;. Meaning, it represents the direction and distance (magnitude) from the ship to the current target. To extract the actual angle (in radian) we use &lt;code&gt;Math.atan2(x,y)&lt;/code&gt;.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;var angle = Math.atan2(y, x);
var delta = angle - orientation;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;So now we have the direction the ship &lt;em&gt;wants&lt;/em&gt; to face, &lt;code&gt;angle&lt;/code&gt;, and the direction that it &lt;em&gt;is&lt;/em&gt; facing, &lt;code&gt;orientation&lt;/code&gt;. We calculate the difference between them and store it as &lt;code&gt;delta&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img style="cursor:default;" class="right" src="http://dev.bennage.com/images/posts/game-dev-move-04.png" title="[turning the wrong way]" alt="" /&gt;&lt;/p&gt;

&lt;p&gt;The basic idea is that add the value of &lt;code&gt;turnSpeed&lt;/code&gt; to &lt;code&gt;orientation&lt;/code&gt; once each invocation of &lt;code&gt;udpate&lt;/code&gt; until &lt;code&gt;delta&lt;/code&gt; is 0 (meaning that the ship is flying directly at the target). However, some values of &lt;code&gt;delta&lt;/code&gt; will cause the ship to “turn the wrong way”. For example, imagine that the ship is facing the top of the screen and that we’ve defined that as &lt;code&gt;orientation === 0&lt;/code&gt;. Now, imagine that the target is directly to its right. The value of &lt;code&gt;angle&lt;/code&gt; would be π/2 (or 90°). Adding &lt;code&gt;turnSpeed&lt;/code&gt; to &lt;code&gt;orientation&lt;/code&gt; each frame increments the value from 0 to π/2. However, if the target is directly to the left, then the value of &lt;code&gt;angle&lt;/code&gt; would be 3π/2 (or 270°). Simply incrementing &lt;code&gt;orientation&lt;/code&gt; would cause the ship to turn right and keep turning right. This is unintuitive behavior; we expect the ship to turn the shorted distance. In order to accomplish this, we translate any value of &lt;code&gt;delta&lt;/code&gt; higher than π (180°) by subtracting &lt;code&gt;fullCircle&lt;/code&gt;. This normalizes the value of &lt;code&gt;delta&lt;/code&gt; between -π and π (or between -180° and 180°).&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;var delta_abs = Math.abs(delta);
if (delta_abs &amp;gt; Math.PI) {
    delta = delta_abs - fullCircle;
}
&lt;/pre&gt;&lt;p&gt;&lt;code&gt;
&lt;/code&gt;&lt;/p&gt;
 
&lt;p&gt;We take the absolute value of &lt;code&gt;delta&lt;/code&gt; because otherwise we’d have to check for &lt;code&gt;delta &amp;lt; -Math.PI&lt;/code&gt; as well. Also, we’ll use &lt;code&gt;delta_abs&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;delta&lt;/code&gt; is 0, we don’t need to change &lt;code&gt;orientation&lt;/code&gt;. When it is different we need to modify the value of &lt;code&gt;orientation&lt;/code&gt;.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;if (delta !== 0) {
    var direction = delta / delta_abs;
    orientation += (direction * Math.min(turnSpeed, delta_abs));
    orientation %= fullCircle;
}
&lt;/pre&gt;&lt;p&gt;&lt;code&gt;
&lt;/code&gt;&lt;/p&gt;
 
&lt;p&gt;First, we decide &lt;em&gt;how much&lt;/em&gt; to change it using &lt;code&gt;Math.min(turnSpeed, delta_abs)&lt;/code&gt;. We could just use &lt;code&gt;turnSpeed&lt;/code&gt;. However if we did it’s likely that &lt;code&gt;delta&lt;/code&gt; would never quite be 0 and (depending on the size of &lt;code&gt;turnSpeed&lt;/code&gt;) it could result is jittery motion. Secondly, we want to decided which &lt;em&gt;direction&lt;/em&gt; to turn: positive values to the right and negative values to the left. We multiply the amount &lt;code&gt;direction&lt;/code&gt; to change the sign, because &lt;code&gt;direction&lt;/code&gt; will only ever be 1 or -1. Finally, we modulo &lt;code&gt;orientation&lt;/code&gt; to ensure that it stays within a range of -2π to 2π. Otherwise, the calculation of &lt;code&gt;delta&lt;/code&gt; would be off.&lt;/p&gt;

&lt;p&gt;Our last step in &lt;code&gt;update&lt;/code&gt; is to modifiy the actual position using the latest &lt;code&gt;orientation&lt;/code&gt; and &lt;code&gt;speed&lt;/code&gt;.&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;position.x += Math.cos(orientation) * speed;
position.y += Math.sin(orientation) * speed;
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Some basic trigonometry is fairly fundamental for most game development. If you’re mathematically lost at this point, I recommend &lt;a href="https://www.khanacademy.org/math/trigonometry/basic-trigonometry"&gt;reviewing over at Khan Academey&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here’s the geometric interpretation of the code. We want the ship to move a distance of &lt;code&gt;speed&lt;/code&gt; in the direction of &lt;code&gt;orientation&lt;/code&gt;. To do this, we need to project this vector (distance and direction) on the x and y axises. Since the distance is the length of the hypothenuse of right triangle, cosine gives us the x part and sine gives us the y part. We can then add these values to the current position.&lt;/p&gt;
&lt;h4&gt;Draw&lt;/h4&gt;

&lt;p&gt;Drawing the ship to the screen is a bit easier to follow. Here’s the flow of the logic:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Save the state of the drawing context.&lt;/li&gt;
    &lt;li&gt;Transform the context to make it easier to draw our ship.&lt;/li&gt;
    &lt;li&gt;Draw the ship.&lt;/li&gt;
    &lt;li&gt;Restore the context back to its original state.&lt;/li&gt;
    &lt;li&gt;
&lt;p&gt;Draw the target&lt;/p&gt;&lt;pre class="javascript" style="display:none;" name="code"&gt;  function draw(ctx) {

      ctx.save();

      ctx.translate(position.x, position.y);
      ctx.rotate(orientation);

      ctx.fillStyle = &amp;#39;yellow&amp;#39;;
      ctx.fillRect(-3, -1, 6, 2);

      ctx.restore();

      ctx.beginPath();
      ctx.fillStyle = &amp;#39;rgba(255,0,0,0.5)&amp;#39;;
      ctx.arc(target.x, target.y, 2, 0, Math.PI * 2, true);
      ctx.fill();
  }&lt;/pre&gt;&lt;p&gt;&lt;code&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Recall that &lt;code&gt;ctx&lt;/code&gt; is the drawing context for the canvas. The context provide a useful API that allows us to move it around before we draw on it. This is analgous to having a sheet of paper that you might shift and rotate in order to make it easier to draw something complicated. This is the purpose of the &lt;code&gt;translate&lt;/code&gt; and &lt;code&gt;rotate&lt;/code&gt; methods.&lt;/p&gt;

&lt;p&gt;First, we use ‘save’ to establishing a checkpoint for the drawing context that we can easily revert back to using ‘restore.’ The calls to &lt;code&gt;translate&lt;/code&gt; and &lt;code&gt;rotate&lt;/code&gt; modify the state of the drawing context. This modified state is very specific to the drawing of our enemy ship. If we didn’t translate and rotate the canvas, we’d have to do a lot more work to figure out where to draw the four corners of the rectangle.&lt;/p&gt;

&lt;p&gt;I decided that I want my ship to be 6px long and 2px wide. Since I want the middle of the middle of my ship to be the point where it rotates, I shift by half the length and half the width. Hence, the values passed to &lt;code&gt;ctx.fillRect(-3, -1, 6, 2)&lt;/code&gt;. This point the new origin (0,0) at the middle of the rectangle, and it makes our call to &lt;code&gt;rotate&lt;/code&gt; behave intuitively. If we used &lt;code&gt;ctx.fillRect(0, 0, 6, 2)&lt;/code&gt; instead, then the ship would appear to rotate around its upper left corner. We’ll use these same techniques once we switch to using &lt;em&gt;sprites&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;After we restore the context’s state, we draw the target. We don’t bother using &lt;code&gt;rotate&lt;/code&gt; because it’s meaningless to rotate a simple circle. Likewise, we don’t bother &lt;code&gt;translate&lt;/code&gt; since the drawing logic is so simple.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The canvas is a broad topic in itself. I recommend taking a look at the tutorials over at &lt;a href="https://developer.mozilla.org/en-US/docs/HTML/Canvas"&gt;MDN&lt;/a&gt;. A handy reference for the APIs themselves can be found on &lt;a href="http://msdn.microsoft.com/en-us/library/ff975057"&gt;MSDN&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;em&gt;Comment on this post at &lt;a href="http://dev.bennage.com/blog/2013/03/05/game-dev-03/"&gt;dev.bennage.com&lt;/a&gt;&lt;/em&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=99712" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/4Bb38w8zlx0" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/christopher_bennage/archive/tags/Game+Development/default.aspx">Game Development</category><category domain="http://devlicio.us/blogs/christopher_bennage/archive/tags/javascript/default.aspx">javascript</category><category domain="http://devlicio.us/blogs/christopher_bennage/archive/tags/HTML/default.aspx">HTML</category><feedburner:origLink>http://devlicio.us/blogs/christopher_bennage/archive/2013/03/13/building-a-game-with-javascript-making-things-move.aspx</feedburner:origLink></item><item><title>Working on my first Pluralsight course – Html for the XAML Developer</title><link>http://feedproxy.google.com/~r/Devlicious/~3/jzlChmH7L4A/working-on-my-first-pluralsight-course-html-for-the-xaml-developer.aspx</link><pubDate>Fri, 08 Mar 2013 11:27:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:97753</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>11</slash:comments><description>&lt;p&gt;It&amp;rsquo;s official, I have been commissioned to author my first &lt;a href="http://pluralsight.com/training/"&gt;Pluralsight&lt;/a&gt; course and I am pretty excited.&amp;nbsp; My first course is going to be &amp;lsquo;Html for the XAML Developer&amp;rsquo;.&amp;nbsp; The objective for this course is to walk a XAML developer (Sliverlight, WPF, WP7, etc) through the process of porting a Silverlight application over to HTML.&amp;nbsp; I will accomplish this by breaking our reference application down into bit size chunks and rebuilding it in HTML.&amp;nbsp; In each step along the way I am going to compare our XAML code to our new HTML code in order to allow the view to understand how their existing knowledge can be applied to HTML.&lt;/p&gt;
&lt;p&gt;In the course I am going to use the following tools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;jQuery&lt;/li&gt;
&lt;li&gt;Knockout&lt;/li&gt;
&lt;li&gt;Typescript&lt;/li&gt;
&lt;li&gt;ASP.Net MVC&lt;/li&gt;
&lt;li&gt;ASP.Net Web Api&lt;/li&gt;
&lt;li&gt;Many, many others&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is a screenshot of part of our reference XAML application&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_05328D0D.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_08D5C94C.png" width="756" height="280" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is what we expect to build via HTML&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_3CA0504E.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_6B1E8150.png" width="755" height="475" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am planning to have this course go live sometime in May so if your a pluralight subscriber please be sure to check it out when it does.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=97753" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/jzlChmH7L4A" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Pluralsight/default.aspx">Pluralsight</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/08/working-on-my-first-pluralsight-course-html-for-the-xaml-developer.aspx</feedburner:origLink></item><item><title>Knockout JS and mapping from Json to a custom object type</title><link>http://feedproxy.google.com/~r/Devlicious/~3/YEuqQBWXUqk/knockout-js-and-mapping-from-json-to-a-custom-object-type.aspx</link><pubDate>Wed, 06 Mar 2013 11:28:03 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:96304</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>8</slash:comments><description>&lt;p&gt;One of the really cool features of &lt;a href="http://knockoutjs.com/"&gt;Knockout js&lt;/a&gt; is the ability to take a raw json object, say from a web endpoint, and map it to an observable.&amp;#160; This is done via the &lt;a href="http://knockoutjs.com/documentation/plugins-mapping.html"&gt;mapping&lt;/a&gt; plug-in.&lt;/p&gt;  &lt;p&gt;Take a look at the code below for an example&lt;/p&gt;  &lt;pre class="javascript" style="display:none;" name="code"&gt;$.get(url)
    .done((data) =&amp;gt; {
        var temp = self.ToDos();

        _.each(data, (item) =&amp;gt; {
            var toDoVM = ko.mapping.fromJS(item);

            temp.push(toDoVM);
        });

        self.ToDos.valueHasMutated();
    });&lt;/pre&gt;

&lt;p&gt;The magic above is the line ko.mapping.fromJS(item), this is what will take my json object and convert it to an observable.&amp;#160; Proof is below.&lt;/p&gt;

&lt;p&gt;Below is the output via the Chrome Dev tools of our ‘item’ prior to mapping.&amp;#160; Notice we have raw properties.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_333B4EF5.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_4B614A01.png" width="664" height="69" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Here is the output after the mapping, notice how now we have functions rather than properties.&amp;#160; This tells me I have a knockout observable.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_0DD3EC38.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_023E2EF9.png" width="741" height="66" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;There is one little issue here in the mapping above.&amp;#160; The issue is that the resulting type from the mapping is ‘object’.&amp;#160; Now this could be 100% ok but what if you want to custom object type for your binding.&amp;#160; Maybe you have computed properties you want to use as well.&amp;#160; Fortunately you can accomplish this via Knockout as well.&lt;/p&gt;

&lt;p&gt;Assume I have this custom type as seen below (this is using TypeScript&lt;/p&gt;

&lt;pre class="javascript" style="display:none;" name="code"&gt;export class ToDoListItemViewModel {
    public Id: KnockoutObservableNumber = ko.observable(0);
    public Task: KnockoutObservableString = ko.observable(&amp;quot;&amp;quot;);
    public DueDate: KnockoutObservableString = ko.observable(&amp;quot;&amp;quot;);
    public ReminderDate: KnockoutObservableString = ko.observable(&amp;quot;&amp;quot;);
    public Priority: KnockoutObservableString = ko.observable(&amp;quot;&amp;quot;);
    public Category: KnockoutObservableString = ko.observable(&amp;quot;&amp;quot;);

    public DisplayDueDate: KnockoutComputed = ko.computed(() =&amp;gt; { return &amp;quot;aaa&amp;quot; });

    constructor() {
        this.DisplayDueDate = ko.computed(() =&amp;gt; {
            var displayDate = &amp;quot;&amp;quot;;
            if (this.DueDate &amp;amp;&amp;amp; this.DueDate() != &amp;quot;&amp;quot;) {
                displayDate = moment(this.DueDate()).format(&amp;#39;L&amp;#39;);
            }
            return displayDate;
        });
    }
}&lt;/pre&gt;

&lt;p&gt;How could I use Knockout mapping to returned a typed observable?&lt;/p&gt;

&lt;p&gt;Turns out it is really simple.&amp;#160; The code below shows how&lt;/p&gt;

&lt;pre class="javascript" style="display:none;" name="code"&gt;$.get(url)
    .done((data) =&amp;gt; {
        var temp = self.ToDos();

        _.each(data, (item) =&amp;gt; {
            var toDoVM = ko.mapping.fromJS(item, {}, new ToDoListItemViewModel());

            temp.push(toDoVM);
        });

        self.ToDos.valueHasMutated();
    });&lt;/pre&gt;

&lt;p&gt;The ONLY difference in this code is in the ko.mapping.fromJs line.&amp;#160; Notice how I am passing in 2 extra arguments.&amp;#160; The 2nd argument is the one I want and this is the ‘target’ output type.&lt;/p&gt;

&lt;p&gt;Now when I look at the output in the debugging tools I get what I want, a typed object being returned&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_73FFB608.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_763C3EC4.png" width="689" height="53" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So the trick to returned a typed observable is to use the overload of the .fromJS method.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=96304" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/YEuqQBWXUqk" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Knockout.js/default.aspx">Knockout.js</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/03/06/knockout-js-and-mapping-from-json-to-a-custom-object-type.aspx</feedburner:origLink></item><item><title>Nuget Packages for Typescript Definition Files</title><link>http://feedproxy.google.com/~r/Devlicious/~3/Y1RnA7rzQVg/nuget-packages-for-typescript-definition-files.aspx</link><pubDate>Sun, 24 Feb 2013 12:09:10 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:89474</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;If you have been using TypeScript you should be aware the definition file repository maintained by Boris Yankov called &lt;a href="https://github.com/borisyankov/DefinitelyTyped"&gt;DefinitelyTyped&lt;/a&gt;.&amp;#160; This repository is awesome because it saves so much time and effort when working with 3rd party libraries with Typescript.&lt;/p&gt;  &lt;p&gt;However, as great as this repository is it has always been painful getting the actual d.ts files for each library.&amp;#160; You would have to go to the site, navigate to the file, save the file and add it to your solution…. this sucked.&amp;#160; &lt;/p&gt;  &lt;p&gt;If only there was a tool to help automate this?&amp;#160; Oh wait there is, it is called &lt;a href="https://nuget.org"&gt;Nuget&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;I got the bright idea to start creating some Nuget packages around the d.ts files I am using so I posted them &lt;a href="https://nuget.org/packages?q=Derik+whittaker"&gt;here&lt;/a&gt;.&amp;#160; The only problem with this is I was only creating the packages I cared about but more importantly I was creating these by hand and that is time consuming and I am lazy.&lt;/p&gt;  &lt;p&gt;But yesterday I received some awesome news from &lt;a href="http://staxmanade.blogspot.com/"&gt;Jason Jarret&lt;/a&gt; (aka &lt;a href="https://twitter.com/staxmanade"&gt;@staxmanade&lt;/a&gt;) on twitter as seen below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_74B5DA5F.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_41E8649C.png" width="644" height="180" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is awesome news.&amp;#160; Now all the d.ts files hosted in the DefinitelyTyped repository now have Nuget pacakges… w00t!&lt;/p&gt;  &lt;p&gt;To see the list of Nuget packages follow this &lt;a href="https://nuget.org/packages?q=definitelytyped"&gt;link&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Awesome work Jason,&lt;/p&gt;  &lt;p&gt;Till Next Time,&lt;/p&gt;  &lt;p&gt;P.S. I will be taking my nuget packages offline very shortly as they should not be used anymore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=89474" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/Y1RnA7rzQVg" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Best+Practice/default.aspx">Best Practice</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/NuGet/default.aspx">NuGet</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/02/24/nuget-packages-for-typescript-definition-files.aspx</feedburner:origLink></item><item><title>Introducing Durandal</title><link>http://feedproxy.google.com/~r/Devlicious/~3/R-lt4EwiiBg/introducing-durandal.aspx</link><pubDate>Mon, 18 Feb 2013 18:32:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:86082</guid><dc:creator>Rob Eisenberg</dc:creator><slash:comments>22</slash:comments><description>&lt;p&gt;Today I&amp;#39;m very excited to officially bring to you &lt;a target="_blank" href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt; is a new open source JavaScript library for rich client application development. It focuses on providing an enjoyable and productive developer experience centered around simple conventions and standard patterns like MVC, MVP and MVVM. &lt;a target="_blank" href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt; is built on libs you know and love like &lt;a target="_blank" href="http://jquery.com/"&gt;jQuery&lt;/a&gt;, &lt;a target="_blank" href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt; and &lt;a target="_blank" href="http://requirejs.org/"&gt;RequireJS&lt;/a&gt;, so there&amp;#39;s little to learn and building apps feels comfortable and familiar.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a short list of it&amp;#39;s features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Clean MV* Architecture&lt;/li&gt;
&lt;li&gt;JS &amp;amp; HTML Modularity&lt;/li&gt;
&lt;li&gt;Simple App Lifecycle&lt;/li&gt;
&lt;li&gt;Eventing, Modals, Message Boxes, etc.&lt;/li&gt;
&lt;li&gt;Navigation &amp;amp; Screen State Management&lt;/li&gt;
&lt;li&gt;Consistent Async Programming w/ Promises&lt;/li&gt;
&lt;li&gt;App Bundling and Optimization&lt;/li&gt;
&lt;li&gt;Use any Backend Technology&lt;/li&gt;
&lt;li&gt;Built on top of &lt;a target="_blank" href="http://jquery.com/"&gt;jQuery&lt;/a&gt;, &lt;a target="_blank" href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt; &amp;amp; &lt;a target="_blank" href="http://requirejs.org/"&gt;RequireJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Integrates with other libraries such as &lt;a target="_blank" href="http://sammyjs.org/"&gt;SammyJS&lt;/a&gt; &amp;amp; &lt;a target="_blank" href="http://twitter.github.com/bootstrap/"&gt;Bootstrap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Make jQuery &amp;amp; Bootstrap widgets templatable and bindable (or build your own widgets).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;#39;m also pleased to announce that I&amp;#39;ve been working with the ASP.NET team to bring &lt;a target="_blank" href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt; to you as an ASP.NET MVC Template, released today and compatible with the new Web Tools 2012.2 release. You can&lt;a href="http://go.microsoft.com/fwlink/?LinkId=282648"&gt; grab the VSIX&lt;/a&gt;, install it and get started very quickly building rich web apps now. If using the VSIX isn&amp;rsquo;t your style, we&amp;rsquo;ve got &lt;a target="_blank" href="http://www.nuget.org/packages?q=durandal"&gt;several nuget packages available too&lt;/a&gt;. Finally, if you just love &lt;a target="_blank" href="http://nodejs.org/"&gt;NodeJS&lt;/a&gt;, you might be interested in &lt;a target="_blank" href="http://durandaljs.com/documentation/Mimosa.html"&gt;using our Mimosa skeleton&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To&amp;nbsp; learn more, please visit &lt;a target="_blank" href="http://durandaljs.com/"&gt;the official site&lt;/a&gt;, where you will find the &lt;a target="_blank" href="http://durandaljs.com/pages/get-started"&gt;getting started guide&lt;/a&gt;, &lt;a target="_blank" href="http://durandaljs.com/pages/docs"&gt;documentation&lt;/a&gt;, &lt;a target="_blank" href="http://durandaljs.com/pages/videos"&gt;videos&lt;/a&gt;, &lt;a target="_blank" href="http://durandaljs.com/pages/training"&gt;training&lt;/a&gt; and &lt;a target="_blank" href="http://durandaljs.com/pages/support"&gt;commercial support&lt;/a&gt; options.&lt;/p&gt;
&lt;p&gt;Stay tuned. There&amp;#39;s lots to say about Durandal and I look forward to sharing it with you in the coming weeks and months.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=86082" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/R-lt4EwiiBg" height="1" width="1"/&gt;</description><feedburner:origLink>http://devlicio.us/blogs/rob_eisenberg/archive/2013/02/18/introducing-durandal.aspx</feedburner:origLink></item><item><title>Entity Frame Performance Gotcha</title><link>http://feedproxy.google.com/~r/Devlicious/~3/mHTDoo9CAkM/entity-frame-performance-gotcha.aspx</link><pubDate>Tue, 12 Feb 2013 19:44:19 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:82206</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>14</slash:comments><description>&lt;p&gt;I was doing some profiling of our Entity Framework stuff via &lt;a&gt;EFProfiler&lt;/a&gt; the other day and noticed something really odd.&amp;#160; When I was watching the profiler I noticed that I had a query returning back over 1300 results and that was NOT right, I had expected only 1 result.&amp;#160; I looked the resulting sql and immediately I ‘thought’ I knew the issue.&amp;#160; I thought the issue was that I had not setup my where clause correctly in my EF… Turns out I was both right and wrong at the same time. &lt;/p&gt;  &lt;p&gt;Below is a sample of my EF code &lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;** note that I replaced the dynamic variables w/ static for testing inside of &lt;a href="http://www.linqpad.net/"&gt;LinqPad&lt;/a&gt; **&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_49D06E30.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_7F198095.png" width="790" height="66" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When I run these statements above and look at the resulting sql in &lt;a href="http://www.linqpad.net/"&gt;LinqPad&lt;/a&gt; I would expect to see 2 queries.&amp;#160; Sure enough I did have 2 of them.&amp;#160; What shocked me was that the 2nd query ONLY did a where clause filter on ClientID (see below)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_04F4242F.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_0E6CE2A5.png" width="397" height="185" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This had a resulting output of below, which is the expected result&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_01FEBF7C.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_610B4CD4.png" width="520" height="64" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;But if you run the sql generated above (2nd statement) you actually get 1327 results.&amp;#160; This tells me that indeed the ENTIRE result for a client was being pull out of the DB, pulled over the wire and filtered down on the client…This is not good.&lt;/p&gt;  &lt;p&gt;Now I tried a few different things to see if I could get different results such as doing a .FirstOrDefault rather than a .Where… No dice&lt;/p&gt;  &lt;p&gt;Finally one of my coworkers found this &lt;a href="http://stackoverflow.com/questions/5173389/linq-to-sql-entityset-is-not-iqueryable-any-workarounds"&gt;Stack Overflow&lt;/a&gt; link which talks directly to this issue.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Turns out this behavior is by design and I had never noticed it before.&amp;#160; I (and 3 of my coworkers mind you) had just assumed that when EF did a lazy load off of a previously fetched IQueryable it would include any filter statements and pass those to the SERVER.&amp;#160; But because the .Images is NOT a IQuerable but rather an EntitySet&amp;lt;T&amp;gt; it did not work as expected.&lt;/p&gt;  &lt;p&gt;To solve this issue I simply just changed my statement to go directly at my EF context for the ONE row I wanted w/ both keys (client and type).&amp;#160; This solved my issue as well as give me a pretty significant performance enhancement.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2B2657BA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_777DEB5B.png" width="926" height="65" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Long story short is that if you are going to lazy gather data in EF make sure you are doing your filtering on the server rather than the client and make sure you understand that an EntitySet does NOT do this only an IQuerable does this.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=82206" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/mHTDoo9CAkM" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Linq/default.aspx">Linq</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/02/12/entity-frame-performance-gotcha.aspx</feedburner:origLink></item><item><title>Help I am getting an XMLHttpRequest exception of Access-Control-Allow-Orig</title><link>http://feedproxy.google.com/~r/Devlicious/~3/c9isQJ3Br4A/help-i-am-getting-an-xmlhttprequest-exception-of-access-control-allow-orig.aspx</link><pubDate>Sun, 10 Feb 2013 12:34:06 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:80352</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>10</slash:comments><description>&lt;p&gt;When working on a demo application recently I was trying to get an ajax call to hit one of my Web API routes and I was immediately hit with the following exception.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;XMLHttpRequest cannot load &lt;a href="http://localhost:33884/api/ToDo/"&gt;http://localhost:33884/api/ToDo/&lt;/a&gt;. Origin &lt;a href="http://localhost/"&gt;http://localhost:3462&lt;/a&gt; is not allowed by Access-Control-Allow-Orig&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Of course this sucked because I KNEW what the issue was but not exactly how to solve it.&amp;#160; Well solve it the way I wanted.&amp;#160; Of course i could have just put both my sites (MVC project and WebAPI project) under the same web application in IIS to remove this but that was not an acceptable answer for my needs.&lt;/p&gt;  &lt;p&gt;After a bit of searching online I thought I came across an solution that would work.&amp;#160; I thought that I could just set the &lt;strong&gt;&lt;a href="http://api.jquery.com/jQuery.ajax/"&gt;crossDomain&lt;/a&gt;&lt;/strong&gt; switch in my ajax call as below to get it to work, but no dice.&lt;/p&gt;  &lt;pre class="c#" style="display:none;" name="code"&gt;$.ajax({
    url: url,
    type: &amp;#39;Get&amp;#39;,
    crossDomain: true,
    success: (data) = &amp;amp; gt; {
        // do something here
    },
    error: (data) = &amp;amp; gt; { }
});&lt;/pre&gt;

&lt;p&gt;I found another suggestion telling me to change the dataType of request form json to jsonp as below, but as you may have guessed that did not work.&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;$.ajax({
    url: url,
    type: &amp;#39;Get&amp;#39;,
    dataType: jsonp,
    success: (data) = &amp;amp; gt; {
        // do something here
    },
    error: (data) = &amp;amp; gt; { }
});&lt;/pre&gt;

&lt;p&gt;Finally at a bit more searching I found more information which suggested I needed to add a response header on the server side to allow ‘Access-Control-Allow-Origin’ and this &lt;a href="http://stackoverflow.com/questions/14104289/strange-behavior-when-using-jquery-asp-net-webapi/14105313#14105313"&gt;Stack Overflow&lt;/a&gt; answer gave me all the details needed to make this happen in Web API.&amp;#160; Once I implemented the solution inside my WebApi endpoints and REMOVED the 2 un-needed attributes in my .ajax call the world was a happy place and I was able to make cross domain calls to my other services.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=80352" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/c9isQJ3Br4A" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WebApi/default.aspx">WebApi</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/02/10/help-i-am-getting-an-xmlhttprequest-exception-of-access-control-allow-orig.aspx</feedburner:origLink></item><item><title>How to use the Accelerometer in Windows 8 C#/XAML Applications</title><link>http://feedproxy.google.com/~r/Devlicious/~3/Hlc2lmrpCs0/how-to-use-the-accelerometer-in-windows-8-c-xaml-applications.aspx</link><pubDate>Sun, 27 Jan 2013 20:15:24 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:72764</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>11</slash:comments><description>&lt;p&gt;This post is part of a mulit-part posting series on how to use some of the onboard device sensors in Windows 8 applications.&amp;#160; Other posts are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2013/01/16/how-to-use-the-light-sensor-in-windows-8-c-xaml-applications.aspx"&gt;Light Sensor&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2013/01/21/how-to-use-the-gyrometer-sensor-in-windows-8-c-xaml-applications.aspx"&gt;Gyrometer Sensor&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2013/01/23/how-to-use-the-inclinometer-sensor-in-windows-8-c-xaml-applications.aspx"&gt;Inclinometer Sensor&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Accelerometer Sensor (this post) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Most tablets and laptops these days have an array of sensors onboard the device that developers can use and take advantage of. One of the sensors which is on most tables and laptops is the Accelerometer Sensor.&amp;#160; The Accelerometer sensor can be used to get a acceleration force of the device on the x y and z axis, or basically measure how fast it is moving in any given direction.&amp;#160; With the Accelerometer you could build interesting augmented reality applications which react to the forces of the device.&amp;#160; In this post we are going to take a look at how to use the Accelerometer Sensor from within your C#/XAML Windows 8 application.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How to get access to the Inclinometer &lt;/strong&gt;&lt;/p&gt;  &lt;pre class="c#" style="display:none;" name="code"&gt;private Sensor.Accelerometer _accelerometer;
private void SetupSensor()
{
    _accelerometer = Sensor.Accelerometer.GetDefault();

    if (_accelerometer == null)
    {
        // tell user they don&amp;#39;t have an Accelerometer
    }
}&lt;/pre&gt;

&lt;p&gt;In the above code what we are doing is making the call to get the Default sensor, this is the sensor on the device.&amp;#160; If there is NO sensor on the users device it will return a NULL instance which is why we are checking for null.&amp;#160; Make sure you do the same in your code&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Register to receive event updates when the Accelerometer values change&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;private void SetupEventing(bool enableEventing)
{
    if( enableEventing)
    {
        _accelerometer.ReadingChanged += AccelerometerOnReadingChanged;
        CurrentReadingStyle = &amp;#39;Eventing&amp;#39;;
    }
    else
    {
        _accelerometer.ReadingChanged -= AccelerometerOnReadingChanged;
        CurrentReadingStyle = &amp;#39;Stopped&amp;#39;;
    }
}&lt;/pre&gt;

&lt;p&gt;In the above I am either registering for an event or unregistering.&amp;#160; The event is what will give us the updated values as they change based on the movement of the users device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Doing something useful with the sensor readings&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;private CoreDispatcher _dispatcher;

private async void AccelerometerOnReadingChanged(Sensor.Accelerometer sender, Sensor.AccelerometerReadingChangedEventArgs args)
{
    await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, 
        () =&amp;gt;
            {
                XAcceleration = args.Reading.AccelerationX;
                YAcceleration = args.Reading.AccelerationY;
                ZAcceleration = args.Reading.AccelerationZ;

                SetupNewLocation();
            });
}&lt;/pre&gt;

&lt;p&gt;In the above I am doing 2 things of note:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;I am using a CoreDispatcher (you can get this from Window.Current.Dispatcher) in order to message the results back onto the UI thread.&amp;#160; If you do not need to message back to the UI thread you will NOT need this &lt;/li&gt;

  &lt;li&gt;I am getting the current reading for each axis via the .Reading property of the event argument.&amp;#160; It is here you could do something useful with the reading. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apart from being able to get the changed events for the Accelerometer you can also detect if the device has been shaking by listing to those events as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Register to receive event updates when the Accelerometer shaek change&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;private void SetupShaken(bool enableShaking)
{
    if ( enableShaking )
    {
        _accelerometer.Shaken += AccelerometerOnShaken;
        ShakeCount = 0;
        CurrentReadingStyle = &amp;quot;Shaking&amp;quot;;
    }
    else
    {
        _accelerometer.Shaken -= AccelerometerOnShaken;
        CurrentReadingStyle = &amp;quot;Stopped&amp;quot;;
    }
}&lt;/pre&gt;

&lt;p&gt;In the above code I am wiring an event to tell me each time the Accelerometer notices the device has been shaken.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handle the Shaken Event and do something.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;private async void AccelerometerOnShaken(Sensor.Accelerometer sender, Sensor.AccelerometerShakenEventArgs args)
{
    await _dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                () =&amp;gt;
                                    {
                                        ShakeCount = ShakeCount + 1;
                                    });
}&lt;/pre&gt;

&lt;p&gt;In the above code I have received the Shaken Event and I am simply updating a counter.&amp;#160; Of course in a real world app you would want to do something a bit more exciting, but this gets the point across.&lt;/p&gt;

&lt;p&gt;As you can see working with the Accelerometer sensor is not too hard and can lead to some pretty useful features in your application.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=72764" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/Hlc2lmrpCs0" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Metro/default.aspx">Metro</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Windows+8/default.aspx">Windows 8</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/01/27/how-to-use-the-accelerometer-in-windows-8-c-xaml-applications.aspx</feedburner:origLink></item><item><title>Handling Resuming in your Windows 8 Applications</title><link>http://feedproxy.google.com/~r/Devlicious/~3/fvKCpoFyEXE/handling-resuming-in-your-windows-8-applications.aspx</link><pubDate>Sat, 26 Jan 2013 12:43:31 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:72525</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;Windows 8 applications (aka Windows Store applications) have 3 different life cycle states they can go through:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Launching &lt;/li&gt;    &lt;li&gt;Suspending &lt;/li&gt;    &lt;li&gt;Resuming &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Handling both Launching and Suspending is pretty much covered out of the box but what if you need to resume from a suspended state?&amp;#160; In most normal scenarios you should not have to do too much here because the built in SuspensionManager (this is generated code, not framework code) will handle putting your application back together in terms of what page your user was on and how the page/screen was populated when it was suspended.&lt;/p&gt;  &lt;p&gt;However, if you are using data which is gathered from a remote source such as a web service you may want to refresh your application when it is resuming from suspension.&amp;#160; But how exactly can we accomplish this?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Hooking up the Resuming Event&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="c#" style="display:none;" name="code"&gt;public App()
{
    this.InitializeComponent();
    this.Suspending += OnSuspending;
    this.Resuming += OnResuming;
}&lt;/pre&gt;

&lt;p&gt;You need to wire up the .Resuming event inside your App.cs class.&amp;#160; By default the template only wires the Suspending event as it is used in almost every application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling the Resuming Event&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;private void OnResuming(object sender, object o)
{
    var asFrame = Window.Current.Content as Frame;

    var layoutAwarePageContent = ((LayoutAwarePage) asFrame.Content);

    if (layoutAwarePageContent != null)
    {
        if (layoutAwarePageContent.DataContext is IResumable)
        {
            var asIResumable = ((IResumable) layoutAwarePageContent.DataContext);
            asIResumable.Resume();
        }
    }
}&lt;/pre&gt;

&lt;p&gt;As you can see above it does take some effort to get to your underlying viewmodel in order to make the Resume() call but it is well worth it. &lt;/p&gt;

&lt;p&gt;We first need to get the current frame.&amp;#160; Once we have the frame we want to check to ensure it is of the correct type in order to further check its underlying data context.&amp;#160; Finally we want to check out data context to ensure it is of the correct type.&amp;#160; Doing this final&amp;#160; check will safe guard us and allow us to only make the resume calls on pages which require it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Doing something useful in our Resume() call&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;public class DashboardViewModel : BaseViewModel, IResumable
{
    public void Resume()
    {
        // do something useful here like fetching data via a web service
    }
}&lt;/pre&gt;

&lt;p&gt;In the Resume() is where you would need to handle any remote data fetching or updating of existing data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defining our IResumable interface&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="c#" style="display:none;" name="code"&gt;public interface IResumable
{
    void Resume();
}&lt;/pre&gt;

&lt;p&gt;Our above interface is small, but it does the trick.&amp;#160; It allows us to identify which pages need to be resumed and enables a way to make the call&lt;/p&gt;

&lt;p&gt;As you can see handling the Resuming event in a Windows 8 application is not hard, however getting to your underlying data context does take a bit of work, but this work is well worth it in my opinion.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=72525" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/Devlicious/~4/fvKCpoFyEXE" height="1" width="1"/&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/XAML/default.aspx">XAML</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Metro/default.aspx">Metro</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Windows+8/default.aspx">Windows 8</category><feedburner:origLink>http://devlicio.us/blogs/derik_whittaker/archive/2013/01/26/handling-resuming-in-your-windows-8-applications.aspx</feedburner:origLink></item></channel></rss>
