<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>{get; set;} : CODE</title>
	<atom:link href="http://daveswersky.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://daveswersky.com</link>
	<description>Dave Swersky&#039;s {mis}Adventures in .NET Programming</description>
	<lastBuildDate>Mon, 08 Mar 2010 15:09:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='daveswersky.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/194cabc2fcba5c79c24715cf0d22aaa2?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>{get; set;} : CODE</title>
		<link>http://daveswersky.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://daveswersky.com/osd.xml" title="{get; set;} : CODE" />
	<atom:link rel='hub' href='http://daveswersky.com/?pushpress=hub'/>
		<item>
		<title>C# Switching on Types</title>
		<link>http://daveswersky.com/2010/03/08/c-switching-on-types/</link>
		<comments>http://daveswersky.com/2010/03/08/c-switching-on-types/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:09:30 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=391</guid>
		<description><![CDATA[Have you ever wanted to do this?

Type t = typeof(int);

switch (t) {
   case typeof(int):
      Console.WriteLine(&#34;int!&#34;);
      break;
   case typeof(string):
      Console.WriteLine(&#34;string!&#34;);
      break;
   default:
      Console.WriteLine(&#34;unknown!&#34;);
   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=391&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to do this?</p>
<pre class="brush: csharp;">
Type t = typeof(int);

switch (t) {
   case typeof(int):
      Console.WriteLine(&quot;int!&quot;);
      break;
   case typeof(string):
      Console.WriteLine(&quot;string!&quot;);
      break;
   default:
      Console.WriteLine(&quot;unknown!&quot;);
      break;
}
</pre>
<p>Doesn&#8217;t work, right?  Throws &#8216;A value of an integral type expected&#8217;.  This is because C# switch statement is picky when it evaluates the cases.  It wants static values and can&#8217;t get fancy with object comparisons.  Switch statements aren&#8217;t just a bunch of if/else statements when boiled down to IL.  There is more detail in this <a href="http://stackoverflow.com/questions/44905/c-switch-statement-limitations-why" target="_blank">StackOverflow question</a>.</p>
<p>So we&#8217;re out of luck, right?  Not so fast.  Let&#8217;s think about what we want: behavior associated with a .NET type.  How can we accomplish that?  I got an idea from <a href="http://stackoverflow.com/questions/44905/c-switch-statement-limitations-why/44941#44941" target="_blank">Judah&#8217;s answer</a> to the aforementioned SO question.  Judah uses a generic dictionary to associate the actual type, as the key, with a string.   Interesting.  Why not associate <em>behavior</em> with those types instead?  With delegates like <span style="font-family:Courier;">Action&lt;T&gt;</span> and <span style="font-family:Courier;">Func&lt;T&gt;</span>, we can do that.</p>
<p>Here is Judah&#8217;s answer refactored to use a generic dictionary:</p>
<pre class="brush: csharp;">
Type someType = typeof(int);

Dictionary&lt;Type, Func&lt;string&gt;&gt; typeTable = new Dictionary&lt;Type, Func&lt;string&gt;&gt;();
typeTable.Add(typeof(string), () =&gt; { return &quot;It's a string!&quot;; });
typeTable.Add(typeof(int), () =&gt; { return &quot;It's an int!&quot;; });

Console.Write(typeTable[someType].Invoke());
</pre>
<p>Now we can call any of a number of associated delegates based on a Type object.  We can get even fancier if we want, using <span style="font-family:Courier;">Action&lt;T&gt;</span> if we don&#8217;t need a return value or <span style="font-family:Courier;">Func&lt;T, TResult&gt;</span> if we want to pass parameters into the behavior.  We get the usual performance hit of using delegates, but unless you&#8217;re guiding a missile in real time I don&#8217;t think it&#8217;s a dealbreaker.</p>
<p>I&#8217;ve used this technique and it works great for me, hope you find it useful as well.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=391&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2010/03/08/c-switching-on-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>MetaWork</title>
		<link>http://daveswersky.com/2010/03/07/metawork/</link>
		<comments>http://daveswersky.com/2010/03/07/metawork/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 19:20:13 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=390</guid>
		<description><![CDATA[I&#8217;m working on a personal project related to some work I&#8217;m doing for my day job.  It&#8217;s a big idea I had recently based on ASP.NET MVC and I&#8217;m excited about it, so I&#8217;m pushing hard to get the work in.  I&#8217;ve done a lot more coding in the last couple weeks than I have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=390&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a personal project related to some work I&#8217;m doing for my day job.  It&#8217;s a big idea I had recently based on ASP.NET MVC and I&#8217;m excited about it, so I&#8217;m pushing hard to get the work in.  I&#8217;ve done a lot more coding in the last couple weeks than I have since I &#8220;finished&#8221; VSTime.</p>
<p>My &#8220;productive&#8221; time starts at about 6am and ends, on a good day, around 6pm.  On a very good day, caffeine can extend that time into the evening.  I know this schedule is grounds for revocation of my geek card, but I&#8217;m a husband and dad with three kids, so my schedule is largely theirs.  Outside my productive time, my brain slowly descends into guacamole.  The frontal lobes turn to runny eggs and I can&#8217;t focus on code anymore.</p>
<p>This means that I have about eight good hours a day to devote to work, be it my own or otherwise.  Eight hours sounds like a lot, but when you count drive time, boot time (our login scripts are glacial,) lunch, and body breaks, it rounds out to more like six.  I try to game the system by working from home when I can (no drive time) and eating at my desk, but it&#8217;s still less than eight hours.</p>
<p>Six hours per day isn&#8217;t a lot.  I have to squeeze every possible moment out of those six hours in order to accomplish anything meaningful from one day to the next.  This means staying as focused as possible on the tasks that will truly make things happen.  I&#8217;ve recently noticed a major productivity killer: metawork.</p>
<p>Metawork is what we do to convince ourselves we&#8217;re doing something useful when we&#8217;re actually slacking off.  When our brains seize up and our focus is off, we turn to metawork to look and feel busy.  Examples of metawork include:</p>
<ul>
<li>Updating to-do lists</li>
<li>Writing pseudocode</li>
<li>Tweeting/Talking about writing code</li>
<li>Meetings</li>
<li>Reading about technology that has nothing to do with anything you&#8217;re working on</li>
<li>Answering random StackOverflow questions</li>
<li>Reading blog posts (D&#8217;oh!)</li>
<li>Writing a blog post (Double D&#8217;oh!)</li>
</ul>
<p>This is an incomplete list and will probably apply differently to different people.  Some people are paid to blog, so that wouldn&#8217;t be metawork for those people.  I&#8217;m not paid to blog, so I&#8217;m currently burning valuable time.</p>
<p>Back to it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/390/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=390&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2010/03/07/metawork/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>MVC Melee</title>
		<link>http://daveswersky.com/2010/03/06/mvc-melee/</link>
		<comments>http://daveswersky.com/2010/03/06/mvc-melee/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 01:07:26 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=384</guid>
		<description><![CDATA[I&#8217;m grabbing my ASP.NET MVC gun and going into town!
MVC Melee is coming June 18-20.  Inspired by Rails Rumble, MVC Melee is a 48-hour competition in which the ASP.NET MVC men and women will be separated from the metaphorical boys and girls.  Read their FAQ and Rules for details.
I&#8217;ve been having a ton of fun [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=384&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m grabbing my ASP.NET MVC gun and going into town!</p>
<p><a href="http://http://www.mvcmelee.com/faq.html" target="_blank">MVC Melee</a> is coming June 18-20.  Inspired by <a href="http://r09.railsrumble.com/entries" target="_blank">Rails Rumble</a>, MVC Melee is a 48-hour competition in which the ASP.NET MVC men and women will be separated from the metaphorical boys and girls.  Read their <a href="http://http://www.mvcmelee.com/faq.html">FAQ </a>and <a href="http://http://www.mvcmelee.com/rules.html">Rules </a>for details.</p>
<p>I&#8217;ve been having a ton of fun with ASP.NET MVC for about a year now, and I&#8217;m just starting to feel like I really &#8220;get&#8221; how it works.  Now that I do, I&#8217;m never looking back to webforms.  MVC (and it&#8217;s bigger, better cousin MVVM) just makes more sense, though it was quite a new way of thinking to really grok it.</p>
<p>I&#8217;m going to be sharing some of my most recent work with ASP.NET MVC.  Watch this space for that soon, and let me know if you&#8217;re interested in forming up a team for MVC Melee!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/384/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=384&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2010/03/06/mvc-melee/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>It&#8217;s Alive: VSTime</title>
		<link>http://daveswersky.com/2009/11/30/its-alive-vstime/</link>
		<comments>http://daveswersky.com/2009/11/30/its-alive-vstime/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 18:10:08 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[timetracking]]></category>
		<category><![CDATA[visualstudio]]></category>
		<category><![CDATA[vstime]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=347</guid>
		<description><![CDATA[I&#8217;ve been quiet for a while because I&#8217;ve been working on a pet project: VSTime.  It&#8217;s finally ready to try out and is available at http://vstime.codeplex.com.
What it Does
VSTime is a simple little Visual Studio plugin that records events such as file opening, compiling, and debugging.  It tallies up all that time spent doing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=347&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been quiet for a while because I&#8217;ve been working on a pet project: VSTime.  It&#8217;s finally ready to try out and is available at <a href="http://vstime.codeplex.com" target="_blank">http://vstime.codeplex.com</a>.</p>
<p><span style="text-decoration:underline;"><strong>What it Does</strong></span></p>
<p>VSTime is a simple little Visual Studio plugin that records events such as file opening, compiling, and debugging.  It tallies up all that time spent doing those individual things and presents a report.  You can see how much time you spent editing files, building, and debugging, and a total time spent on a solution.</p>
<p>I hope that this utility will be useful to developers in measuring the time you spend actually doing the rubber-to-road work of development.  I hope no pointy-haired managers get it in their heads that this tool can or should be used to measure productivity.  It can&#8217;t and won&#8217;t, so don&#8217;t try.</p>
<p>However, if your pointy-haired manager insists that a 386 with 256MB of RAM should be plenty, don&#8217;t be shy about showing him/her how most of your time is spent building/compiling your projects.  Graphs like the one in VSTime could be very effective that way!</p>
<p><span style="text-decoration:underline;"><strong>Design</strong></span></p>
<p>I agonized over some of the design decisions, most especially the method for persisting the event records.  I finally settled on SQL Server 2005 Express for two primary reasons:</p>
<p>1.  If you have Visual Studio 2008 installed, SQL Server 2005 Express is installed by default.<br />
2.  The row_number function in SQL 2005 makes tallying the time of each event rather easy.</p>
<p>VSTime is designed in a way that should make it easy to plug in a different persistence layer.  I may develop a SQL Compact or SQLite-based DAL plugin in the future.</p>
<p>VSTime takes advantage of the EnvDTE.DTE interface, which is the wrapped COM interface that represents the Visual Studio IDE automation object model.  EnvDTE.DTE exposes an Events interface, which in turn exposes a bundle of interesting events, including Solution, Window, Build, and Debug -related events.</p>
<p><span style="text-decoration:underline;"><strong>How It Works</strong></span></p>
<p>Each of the events, including file open, build, debug, and a few others, is recorded to an EventRecord table.  The duration of an event is the time it occurs to the time the next event is recorded.  So, for example, if a file is opened at 12:00.00 and then the project is built at 12:05.00, then that file has been &#8220;active&#8221; for five minutes.  The action of the next event &#8220;ends&#8221; the current event.  If the user then goes back to the file, the WindowActivated event is registered and time begins to accrue on that file again.</p>
<p>If you walk away from your desk for a break, an idle counter kicks off after five minutes of no activity.  This records an IDLE event, and the duration of IDLE events are filtered out in the reporting.  If you are editing a file, a keyboard event resets the counter each time you hit the Enter key.  The idle timer is hardcoded at the moment.  I have set up a work item to make it configurable.</p>
<p>You can view the time spent on the currently-opened solution by selecting Tools-VSTime.  Like the little stopwatch in the menu?  It&#8217;s the extent of my artistic ability <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The first tab of the VSTime ToolWindow displays a grid of the time spent on each activity, in descending order.  Based on my experience, you will likely find a file or two (or more) at the top that contains all the important stuff, with lesser files, debugging, and building further down.  This of course will depend on your usage patterns and the nature of your projects.</p>
<p>The second tab displays a horizontal graph of all the events.  You can zoom in on the events by drag-selecting an area of the graph.  Zoom back out by clicking the little button above the scrollbar.</p>
<p><span style="text-decoration:underline;"><strong>Data</strong></span></p>
<p>The VSTime database is very simple.  There are two tables: Solution and EventRecord.  Each EventRecord relates to a Solution.  As explained above, Event duration is defined as the moment an event occurs to the to moment of the subsequent event.  I believe this is effective, but there are some issues.</p>
<p>The primary issue to be aware of is that it is possible to edit a file while debugging in Visual Studio.  This means that you could be, in practical terms, &#8220;Debugging&#8221; and editing a file at the same time.  The Solution Total Time will still be accurate, because the act of activating a file window will &#8220;end&#8221; the debugging event.  However, VSTime does not currently support the idea of concurrent events, so your event time tallies for Debugging may be off if you often edit files while debugging.</p>
<p><span style="text-decoration:underline;"><strong>Future Development</strong></span></p>
<p>Support for VS 2010 is planned and will be in the next release.  I don&#8217;t think I&#8217;ll be spending any time on VS 2005 compatibility, but if there is tons of interest I may reconsider.  Future releases will include more tests.  I&#8217;m also looking into the possiblity of tracking additional interesting events such as source control commits.</p>
<p><span style="text-decoration:underline;"><strong>Yes, It&#8217;s Open Source</strong></span></p>
<p>Please try out VSTime if you think you&#8217;ll find it useful.  If you love it/like it/hate it, don&#8217;t be shy.  Post here or on Codeplex.  Tell the world what you like/hate about it.  If you&#8217;re really passionate about it either way, get involved and make suggestions or even post a patch!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/347/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=347&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/11/30/its-alive-vstime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ Aggregate Queries: Multiple Group By Columns</title>
		<link>http://daveswersky.com/2009/11/12/linq-aggregate-queries-multiple-group-by-columns/</link>
		<comments>http://daveswersky.com/2009/11/12/linq-aggregate-queries-multiple-group-by-columns/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:51:04 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aggregate]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=338</guid>
		<description><![CDATA[I recently had the need to SUM a column grouped by two other columns.  Here&#8217;s the view:

SELECT SolutionID, EventName, EventDuration
FROM Events

I needed this:

SELECT SolutionID, EventName, SUM(EventDuration) EventTotal
FROM Events
GROUP BY SolutionID, EventName

Here&#8217;s the LINQ:

var events = from e in summary
   group e by new { e.SolutionID, e.EventDetail } into g
   let [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=338&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I recently had the need to SUM a column grouped by two other columns.  Here&#8217;s the view:</p>
<pre class="brush: sql;">
SELECT SolutionID, EventName, EventDuration
FROM Events
</pre>
<p>I needed this:</p>
<pre class="brush: sql;">
SELECT SolutionID, EventName, SUM(EventDuration) EventTotal
FROM Events
GROUP BY SolutionID, EventName
</pre>
<p>Here&#8217;s the LINQ:</p>
<pre class="brush: csharp;">
var events = from e in summary
   group e by new { e.SolutionID, e.EventDetail } into g
   let TotalMinutes = g.Sum(x =&gt; x.EventDuration)
   orderby TotalMinutes descending
   select new EventSummary
     {
          SolutionID = g.Key.SolutionID,
          Name = g.Key.EventDetail,
          Seconds = TotalMinutes,
          Minutes = TotalMinutes / 60.0,
          Hours = (TotalMinutes / 60.0) / 60.0
     };
</pre>
<p>The magic is in line 2:</p>
<pre class="brush: csharp;">   group e by new { e.SolutionID, e.EventDetail } into g</pre>
<p>You can group by as many columns as you need with that little nugget.  Using the anonymous type feature in C# 3.0 you can group on as many columns as you need.  Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/338/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=338&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/11/12/linq-aggregate-queries-multiple-group-by-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>What&#8217;s the big deal with RIA?</title>
		<link>http://daveswersky.com/2009/10/30/whats-the-big-deal-with-ria/</link>
		<comments>http://daveswersky.com/2009/10/30/whats-the-big-deal-with-ria/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 14:28:52 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[RIA]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[air]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=270</guid>
		<description><![CDATA[Rich Internet Applications are about more than visual bling and animations.  It&#8217;s the beginning of the end of the &#8220;traditional&#8221; desktop application.  I&#8217;m really excited about RIA in general, because I think it portends big changes in the way applications are developed and delivered.  How exactly will that change happen, and what [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=270&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Rich Internet Applications are about more than visual bling and animations.  It&#8217;s the beginning of the end of the &#8220;traditional&#8221; desktop application.  I&#8217;m really excited about RIA in general, because I think it portends big changes in the way applications are developed and delivered.  How exactly will that change happen, and what will it be?  That question begs another question: what is the point of RIA, and what&#8217;s all the buzz about?</p>
<p>In a nutshell, RIA applications are client apps that are delivered over the web.  They run in a sandboxed runtime environment on the client, and get their data mostly through services hosted in the cloud.  So what&#8217;s the big deal?</p>
<p>The runtime is the big deal.  With a sandboxed runtime environment, you get a few things for free.  Most important among these is security and cross-platform compatibility.  Whether it&#8217;s an AIR or Sliverlight applicaiton, it will (theoretically) run anywhere the environment is installed.  No worrying about HTML/CSS formatting or quirky browser implementations- if the environment is there, it runs.  You also get the speed benefit of moving processing back to the client.  No more waiting for IIS/Apache to process your request- RIA apps run locally.  As a developer you also get the rich UX capabilites, <a href="http://sixrevisions.com/usabilityaccessibility/creating-a-timeless-user-experience/">which could be the most important aspect of any application.</a></p>
<p>So why are Microsoft and Adobe beating a path to developers&#8217; doors?  Why do they care about RIA?  Here&#8217;s a tweet from <a href="http://www.codinghorror.com/blog/">Jeff Atwood</a>:</p>
<p>&#8220;When everything is a web app, maybe we&#8217;ll have new operating systems&#8230;&#8221;</p>
<p>This simple, casual comment sums it up.  Eventually, just about every application will be delivered over the web. Sticking in a CD or downloading an installer is just so 2005.  The winner(s) in the RIA platform space will offer to developers a potential audience of millions of users, regardless of OS.  All this with practically free delivery over the web.  That&#8217;s a big deal.</p>
<p>As the move to RIA continues, &#8220;web application development&#8221; will mean less HTML and more XAML/MXML.  Browser compatibility will be less of a concern.  Web developers will rely on the platforms to handle runtime compatibility while they focus on application development (as it should be!)  A single codebase targeted to a RIA platform can support a potentially huge audience, making development cheaper and reducing testing cycles.</p>
<p>RIA is still in its infancy.  So far I see way more potential than real applications, though that&#8217;s changing fast.  I think Adobe&#8217;s AIR is currently beating Silverlight for features overall, but I see that gap closing with each release of Silverlight.  Over time, I see both platforms effective across just about every major market OS, including mobile.  As Adobe and Microsoft figure out how loose they can safely make the sandbox, more powerful features will be offered.</p>
<p>Eventually, I see a time when users spend more total minutes interacting with RIA applications than they do their OS.  I see fully-featured RIA &#8220;desktop replacements.&#8221;  Imagine booting up any old OS, visiting a website, and getting a completely different experience wherever you are.  Store your data in the cloud, run a RIA OS, and the local OS suddenly doesn&#8217;t matter so much.  Call it a &#8220;Virtual OS&#8221; or a &#8220;Cloud OS&#8221; or whatever you like, it&#8217;s coming fast.</p>
<p>The one thing I can say for sure is this: no one can say with certainty what RIA will mean over the long term, but it smells to me like opportunity.  Shifts like this come maybe once a decade.  It&#8217;s not often you can see the swell of a new meme ahead of its crest.  Getting into RIA development is easy and getting easier, so jump in!  The water&#8217;s great!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/270/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=270&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/10/30/whats-the-big-deal-with-ria/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>Cleveland Windows 7 Launch Event</title>
		<link>http://daveswersky.com/2009/10/12/cleveland-windows-7-launch-event/</link>
		<comments>http://daveswersky.com/2009/10/12/cleveland-windows-7-launch-event/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 20:52:56 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Win7]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=289</guid>
		<description><![CDATA[I attended the Developer track for Windows 7 in Cleveland today.  I&#8217;ve been running Windows 7 Ultimate RTM on my work laptop (when I&#8217;m not at work, unfortunately) since it became available on MSDN.  Here&#8217;s a little writeup of my experience at the event and with Windows 7 in general.

My Experience

Windows 7 has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=289&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I attended the Developer track for Windows 7 in Cleveland today.  I&#8217;ve been running Windows 7 Ultimate RTM on my work laptop (when I&#8217;m not at work, unfortunately) since it became available on MSDN.  Here&#8217;s a little writeup of my experience at the event and with Windows 7 in general.</p>
<div style="margin-bottom:5px;text-decoration:underline;">
<h3>My Experience</h3>
</div>
<p>Windows 7 has been a joy to use overall.  The entire install on my Dell D830 took less than 30 minutes.  That&#8217;s an estimate, I didn&#8217;t time it because I was too impatient!  I can say the 64-bit version fairly screams.  I have a 7200RPM hard drive and 4GB RAM on this machine, so it&#8217;s well powered.  I can honestly say this is the most responsive OS I have ever used.  Startup and shutdown are insanely fast.  I don&#8217;t remember ever waiting for the system to grind, which has been wonderful for my productivity.  I run VS.NET, SQL Management Studio, Gimp, IE, and many other apps simultaneously and it&#8217;s smooth as silk.</p>
<p>When I started making plans to run Win7, I didn&#8217;t know my laptop was 64-bit ([blush] I&#8217;ve been on the developer side so long my hardware chops have atrophied!)  Windows 7 64-bit has none of the hardware compatibility problems that plagued XP 64-bit and even Vista.  I run XP x86 on the same machine by day, so I can compare the difference in performance.  Wow.  I&#8217;m sure there are many others like me out there running a 32-bit OS on 64-bit hardware.  If that&#8217;s you, UPGRADE.  You&#8217;re running a Ferrari on two cylinders.  It&#8217;s the cheapest performance upgrade you&#8217;ll get in a long time.</p>
<div style="margin-bottom:5px;text-decoration:underline;">
<h3>Launch Event</h3>
</div>
<p>I learned several things at the launch event today that I didn&#8217;t know before.</p>
<h4>Hardware Target</h4>
<p>The first presenter at the launch event explained that Windows 7 is the first OS in Microsoft&#8217;s history that is targeted to run fast, not just acceptably, on <em>older, slower</em> hardware than its predecessor.  He cited the popularity of netbooks and the &#8220;breakdown of Moore&#8217;s law&#8221; as the thinking behind this targeting.  I don&#8217;t have much experience with Vista, but I can say from personal experience that the boot time for Windows 7 is good if not great when compared to XP, and shutdown is almost like a lightswitch.  Apparently the improved startup time is due partly to parallel loading of drivers, where possible.</p>
<h4>Problem Step Recorder</h4>
<p>This is a support dream.  It&#8217;s simple: have your end-user (mom, dad, grandma) go to Start and type &#8220;PSR&#8221; in the search box.  The Problem Step Recorder will appear in the list.  Have your end-user hit record, then follow the set of steps that led to the error about which they&#8217;re bugging you.  Hit stop, then save the file, which is a ZIP file.  They email you the file, and you see a wonderful stream of screenshots with detailed information about the system state, all in your browser.  Cool stuff.</p>
<div style="text-align:center;margin:10px;"><img src="http://daveswersky.files.wordpress.com/2009/10/psr.png?w=600" alt="" /></div>
<h4>Shake</h4>
<p>I knew about the ease of side-by-side windows: just drag a window all the way to the right or left and it will pop to that side.  I didn&#8217;t know about shake, though.  Grab the window bar and give it a shake.  All other windows will minimize.  Shake again and they restore.  Neat.</p>
<h4>Powershell UI</h4>
<p>Powershell 2.0 is now baked right in, and has a cool little editor.  I haven&#8217;t dug into Powershell very much yet but it looks very cool for automating tasks.</p>
<div style="text-align:center;margin:10px;"><img src="http://daveswersky.files.wordpress.com/2009/10/psedit.png?w=600" alt="" /></div>
<h4>Windows API Codepack</h4>
<p>During the developer demo, the presenter introduced the <a href="http://code.msdn.microsoft.com/WindowsAPICodePack">Windows API Codepack</a>.  This is a managed wrapper around the native API bits that make Windows 7 sing.  We saw demos on Jump Lists, Icon Overlays, and Trigger-Start Services.  Very little code was required to make these things work.  If you&#8217;re migrating an application to Windows 7 the CodePack is the place to start.  You may also want to check out the <a href="http://code.msdn.microsoft.com/XP2Win7">Photoview</a> uber-demo.</p>
<h4>Libraries</h4>
<p>I was actually surprised that I had been looking at them in Explorer since installing Windows 7 but never really noticed them.  Now that I know what they are I like them a lot.  It&#8217;s simple: Libraries are collections of folders.  There is an API for creating and manipulating them, though you will want to be careful changing something that is really a user-preference system.</p>
<h4>Windows 7 Troubleshooter Packs</h4>
<p>This is more cool stuff for reducing those pesky support costs.  The presenter demoed an issue where there was no sound coming from his laptop.  He ran the Audio Troubleshooter, and it unmuted his audio for him.  You can write your own packs, which are simply collections of Powershell scripts held together with an XML manifest.  You can pack them into a singed CAB file and distribute them with application installers or over the web.  I found a great crash course <a href="http://www.withinwindows.com/2009/01/12/crash-course-on-authoring-windows-7-troubleshooting-packs/">here</a>.</p>
<div style="margin-bottom:5px;text-decoration:underline;">
<h3>Conclusion</h3>
</div>
<p>This is just a few of the cool things in Windows 7.  For more, take a look at <a href="http://edge.technet.com/Media/Windows-7-DirectAccess-the-next-killer-enterprise-feature/">Direct Access</a>, <a href="http://windowsteamblog.com/blogs/windows7/archive/2009/08/04/windows-xp-mode-rc-now-available.aspx">XP Mode</a>, and <a href="http://www.microsoft.com/windows/enterprise/products/windows-7/features.aspx#bitlocker">BitLocker</a>.  All in all, Windows 7 looks like a win for Microsoft.  I&#8217;ve enjoyed it personally and it looks compelling for businesses, which is a big improvement over Vista.  It&#8217;s in stores and shipping from vendors October 22nd.  Check it out!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=289&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/10/12/cleveland-windows-7-launch-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>

		<media:content url="http://daveswersky.files.wordpress.com/2009/10/psr.png" medium="image" />

		<media:content url="http://daveswersky.files.wordpress.com/2009/10/psedit.png" medium="image" />
	</item>
		<item>
		<title>&#8220;Not Invented Here&#8221; Syndrome</title>
		<link>http://daveswersky.com/2009/10/09/not-invented-here-syndrome/</link>
		<comments>http://daveswersky.com/2009/10/09/not-invented-here-syndrome/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 01:04:10 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Practices]]></category>
		<category><![CDATA[practices codesmell antipattern]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=279</guid>
		<description><![CDATA[I responded yesterday to a post by Steve Smith about programming anti-patterns.  After writing a brief note about &#8220;Not Invented Here&#8221; syndrome, I thought about it some more and decided to expand on my comment.
Not Invented Here (NIH) happens for a variety of reasons.  Those that follow NIH are loath to incorporate any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=279&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I responded yesterday to a post by <a href="http://stevesmithblog.com/blog/principles-patterns-and-practices-of-mediocre-programming/">Steve Smith</a> about programming anti-patterns.  After writing a brief note about &#8220;Not Invented Here&#8221; syndrome, I thought about it some more and decided to expand on my comment.</p>
<p>Not Invented Here (NIH) happens for a variety of reasons.  Those that follow NIH are loath to incorporate any ideas from outside their own team (and sometimes their own heads.)  It&#8217;s a sort of mental ossification that occurs when a developer is unable to value contributions from outside.  This may manifest as a reluctance to incorporate open source code into a project.  NIH adherents tend to distrust frameworks developed by other companies or developers.  At its worst, NIH folks won&#8217;t even accept contributions from other team members.</p>
<div style="margin:8px;">
<h3>&#8220;If it wasn&#8217;t Invented Here, by me or my peeps, we won&#8217;t use it.&#8221;</h3>
</div>
<p>It is understandable why developers might prefer their own code and methods over those written by another.  Codebase familiarity is comfortable and fast.  New methods take time to learn and really incorporate, and we don&#8217;t always have the time or management blessings to climb new learning curves on the company nickel.  We rarely get paid extra to write good, reliable software (there&#8217;s a whole other can of worms!)</p>
<p>It&#8217;s important to fight the urge to stick to your comfort zone.  As developers, our value comes not from what we know, but what we can learn and how quickly we incorporate new information.  Imagine trying to write an entire application without an Internet connection.  The most competent developers still need to research and look up syntax now and again.  It&#8217;s important to go beyond simple task-focused research.  Challenge yourself to the core!  Ask tough questions about why you do things the way you do them.  Try new things.  You can&#8217;t expect to maintain good professional bona fides while working in a bubble.  New ideas are essential to any developer&#8217;s continuing education.</p>
<p>Avoiding NIH will also help you avoid RTW: Reinventing the Wheel.  If you decide to build the biggest baddest new blogging system (for example), first ask yourself why you think yours will be better than the other million open source blogging systems out there.  If you have a good answer, go for it!  However, even if you think you have a totally new concept filled with win, do yourself a favor and evaluate the other systems.  You&#8217;ll learn a TON.</p>
<p>There is a caveat here: don&#8217;t go looking for nails every time you find a shiny new hammer.  Tools are just that: tools.  You can build something great or smash your (or your clients!) thumb.  Evaluate each newfangled thingie, whether it&#8217;s TDD, IoC Containers, Mocking, frameworks, or whatever, with a critical eye.  Take some time to try it out.  With a little practice, the really compelling stuff will feel like an old shoe that you&#8217;ve worn for years.  Let the stuff that doesn&#8217;t sing for you just fall away.  It&#8217;s extra effort, but it&#8217;s totally worth it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=279&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/10/09/not-invented-here-syndrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows 7 x64 and IIS 7.5: AspNetHostingPermission Error</title>
		<link>http://daveswersky.com/2009/09/30/windows-7-x64-and-iis-7-5-aspnethostingpermission-error/</link>
		<comments>http://daveswersky.com/2009/09/30/windows-7-x64-and-iis-7-5-aspnethostingpermission-error/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 17:45:10 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[iis7.5]]></category>
		<category><![CDATA[visualstudio]]></category>
		<category><![CDATA[windows7]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=263</guid>
		<description><![CDATA[Quick Fix
I&#8217;m running Windows 7 Ultimate x64 on my laptop.  I was setting up a downloaded code sample from the inimitable Rick Strahl and got this:
Exception Details: System.Security.SecurityException: Request for the permission of type &#8216;System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242; failed.
After much Googling, discovered this:

If that setting is blank, it&#8217;s trying to use &#8220;pass-through credentials,&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=263&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h2>Quick Fix</h2>
<div>I&#8217;m running Windows 7 Ultimate x64 on my laptop.  I was setting up a downloaded code sample from the inimitable <a href="http://www.west-wind.com/Weblog/">Rick Strahl</a> and got this:</div>
<p><strong>Exception Details: System.Security.SecurityException: Request for the permission of type &#8216;System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242; failed.</strong></p>
<p>After much Googling, discovered this:</p>
<p><img src="http://daveswersky.files.wordpress.com/2009/09/iisphysicalpathsecurity.png?w=600" alt="" /></p>
<div>If that setting is blank, it&#8217;s trying to use &#8220;pass-through credentials,&#8221; which I assume is Anonymous access.  I tried to get anonymous working by adding the IUSR account to that folder, but no luck.  Obviously this isn&#8217;t the way you&#8217;d set things up in production but it works for my dev machine.  Hope this saves someone some time.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=263&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/09/30/windows-7-x64-and-iis-7-5-aspnethostingpermission-error/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>

		<media:content url="http://daveswersky.files.wordpress.com/2009/09/iisphysicalpathsecurity.png" medium="image" />
	</item>
		<item>
		<title>Silverlight Research Summary</title>
		<link>http://daveswersky.com/2009/09/29/silverlight-research-summary/</link>
		<comments>http://daveswersky.com/2009/09/29/silverlight-research-summary/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 20:44:35 +0000</pubDate>
		<dc:creator>dswersky</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://daveswersky.com/?p=180</guid>
		<description><![CDATA[
So, I made it through Step 2: Read of my Learning Process 2.0 for Silverlight.  Here is the product of that process.


Prologue:  There is a really cool demo of Silverlight capabilities here.


What is Silverlight?

Remember &#8220;Write Once, Run Anywhere?&#8221; This lofty goal has been promised before &#60;cough Java cough&#62;.  It&#8217;s still a desirable [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=180&subd=daveswersky&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">
So, I made it through <a href="http://daveswersky.com/2009/09/25/deconstructing-my-learning-process/#Step2Read">Step 2: Read</a> of my Learning Process 2.0 for Silverlight.  Here is the product of that process.
</p>
<p style="text-align:justify;">
Prologue:  There is a really cool demo of Silverlight capabilities <strong><a href="http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=HomePage">here</a></strong>.
</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">What is Silverlight?</div>
</h3>
<p style="text-align:justify;">Remember <strong><a href="http://en.wikipedia.org/wiki/Write_once,_run_anywhere">&#8220;Write Once, Run Anywhere?&#8221;</a></strong> This lofty goal has been promised before <span style="font-size:10px;">&lt;cough Java cough&gt;</span>.  It&#8217;s still a desirable thing, to be sure: just ask any developer that still has to code webpages to look decent on IE6.</p>
<p style="text-align:justify;">A new generation of technologies is beginning to deliver on the multi-platform promise of old.  <strong>Silverlight</strong> is Microsoft&#8217;s entry into that fray.  The Silverlight runtime is a subset of the .NET Base Class Library, runs on PC and Mac, and runs in all the major browsers including IE, Firefox, Safari, Opera, Chrome, and more.</p>
<p style="text-align:justify;">Silverlight was born as &#8220;WPF/E&#8221;, which stands for <strong>Windows Presentation Foundation/Everywhere</strong>.  WPF and Silverlight are both Microsoft&#8217;s latest User Interface technology offerings.  Both are based on eXtensible Application Markup Language, aka XAML.  The difference between WPF and Silverlight is in delivery: WPF is a desktop technology.  Silverlight is a Rich Internet Application framework for delivery of rich user interfaces via the web.</p>
<p style="text-align:justify;">No discussion of Silverlight is complete without mentioning Flash.  Yes, Silverlight competes with Flash.  Directly.</p>
<ol>
<li>Both Flash and Silverlight run in a sandboxed environment on the client.</li>
<li>Both offer vector graphics and media (audio/video) capability.</li>
<li>As of Silverlight 3.0, both support an out-of-browser running mode (Adobe AIR allows Flash/Flex programs to run locally outside a browser.)</li>
<ol>
<p style="margin-top:5px;">The primary difference between them is that Flash uses Actionscript, and Silverlight is based on .NET, which means Silverlight applications may be developed in any .NET-compliant language.  These include VB.NET, C#, and with the Dynamic Languages support in Silverlight, IronPython and IronRuby.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Browser Integration</div>
</h3>
<p style="text-align:justify;">A Silverlight application may be embedded into a webpage using the Silverlight ActiveX control and the &lt;object&gt; notation, or by using javascript.  A javascript bridge (HTML Bridge) between Silverlight applications and the hosting page allows javascript to call into the Silverlight app, and managed Silverlight code to call out to javascript functions declared in the hosting page.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">XAML</div>
</h3>
<p style="text-align:justify;">XAML stands for eXtensible Application Markup Language.  It is an XML-based language for describing visual elements of a User Interface.</p>
<p style="text-align:justify;">Think back to the days of VB6: the UI was all tangled up in the code.  Then came .NET, and for some time the UI was all tangled up in auto-generated &#8220;designer&#8221; code.  Now comes WPF, Silverlight, and XAML.  Using XAML, the UI definition is <em>completely</em> separated from the programming logic.  XAML pages declaratively describe an object graph.  Parsing a Silverlight XAML page results in the instantiation of that graph and the rendering of the user interface it describes.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Dynamic Language Support</div>
</h3>
<p>Dynamic Languages in Silverlight allow IronPython and IronRuby programs to manipulate and interact with the user interface in the same way as C# or VB.NET.  This opens up Silverlight to Python and Ruby developers.  The <a href="http://www.silverlight.net/content/samples/sl2/dlrconsole/index.html">DLR Console Sample</a> demonstrates another capability: interacting with a running Silverlight application in real time using code.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Layout System</div>
</h3>
<p style="text-align:justify;">The Silverlight layout system determines how visible elements of an application are positioned relative to the application host and each other.  Several layout controls are included with Silverlight, including Canvas, Grid, and StackPanel, to name a few.</p>
<p style="text-align:justify;">Controls are laid out by the engine using inherited <a href="http://msdn.microsoft.com/en-us/library/cc645025%28VS.95%29.aspx#LayoutSystem_MeasureArrange">Measure and Arrange methods</a> that cooperate to determine how much visible area a control wants, and how much it gets as a result of the overall layout of all visible elements.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Controls</div>
</h3>
<p style="text-align:justify;">Silverlight 2.0 introduced a library of ready-made controls, such as TextBlock, TextBox, ComboBox, etc.  MSDN has a handy <a href="http://msdn.microsoft.com/en-us/library/cc645072%28VS.95%29.aspx">directory of controls</a>.</p>
<p style="text-align:justify;">Silverlight controls are &#8220;look-less&#8221; in that the code that defines their behavior contains absolutely nothing about how they appear visually.  The visual appearance of controls, including custom controls, is defined entirely in XAML.  The .NET class that implements the control is referred to as a &#8220;control contract.&#8221;</p>
<p style="text-align:justify;">Just as with .NET Winforms and ASP.NET controls, WPF/Silverlight controls can be customized or created from scratch.  Customization of controls in Silverlight is quite different, however.  Winforms and ASP.NET controls can be subclassed and then customized.  Silverlight control customization involves replacing the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.controltemplate%28VS.95%29.aspx">ControlTemplate</a> of a control.  This allows a developer to completely replace the visual behavior of an existing control.</p>
<p style="text-align:justify;">Common content may be <a href="http://msdn.microsoft.com/en-us/library/cc903959%28VS.95%29.aspx">shared across controls</a> using a <a href="http://msdn.microsoft.com/en-us/library/system.windows.datatemplate%28VS.95%29.aspx">DataTemplate</a>.  This supports adding a common icon to a custom &#8220;submit&#8221; button, for example.</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Networking</div>
</h3>
<p style="text-align:justify;">Communicating with the cloud in Silverlight presents several security challenges.  Silverlight applications cannot freely communicate with just any service over any port; there are restrictions to prevent security threats such as malware, viruses, and spyware.  Depending on configuration, communication is either handled for the Silverlight application by the browser, or the Silverlight client itself handles HTTP/HTTPS communications.  The latter configuration is useful for RESTful communications or when the developer wants to handle cookies manually.
</p>
<p style="text-align:justify;">
The standard class for network communcation is <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient%28VS.95%29.aspx">WebClient</a>.  WebClient has asynchronous methods for writing and reading to a network stream.  The <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28VS.95%29.aspx">HttpWebRequest</a> and <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse%28VS.95%29.aspx">HttpWebResponse</a> classes contain methods for more granular communications, including the ability to manipulate HTTP headers.  Silverlight also supports <a href="http://msdn.microsoft.com/en-us/library/cc296248%28VS.95%29.aspx">Sockets</a> for low-level TCP communications.
</p>
<p style="text-align:justify;">
The security model Silverlight uses allows minimally-restricted communication between the hosting domain and a Silverlight application.  If a Silverlight app wants resources (i.e. files, read/write to a service) from another domain, however, a cross-domain policy file must be present on that domain.  Flash/Flex/AIR applications use a similar security model, and Silverlight can read Flash cross-domain policy files.  The policy file is an XML-formatted file that indicates what services and resources are accessible, and to whom.
</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Data</div>
</h3>
<p style="text-align:justify;">
This was a source of confusion for me when I first started with Silveright.  It&#8217;s important to remember that Silverlight apps run <i>in the browser</i>.  This makes them more like Winforms apps than ASP.NET apps.  Silverlight apps get their data over the wire just like any other desktop application. What does a Winforms app do when it needs data from the cloud?  It uses a webservice.
</p>
<p style="text-align:justify;">
Silverlight apps can get their data over the wire via RESTful or SOAP-based services like WCF.  Microsoft provides some help for data access in the form of ADO.NET Data Services (formerly Astoria) and .NET RIA Services.
</p>
<p style="text-align:justify;">Here I am going to punt and guide you to the best authority I&#8217;ve seen on the difference between these options:  <strong><a href="http://bit.ly/zxmRR">Shawn Wildermuth.</a></strong></p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Media and Animation</div>
</h3>
<p style="text-align:justify;">Silverlight&#8217;s Animation system is centered on the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard%28VS.95%29.aspx">Storyboard</a> control and the Animation controls.  &#8220;From-To&#8221; animations including DoubleAnimation, PointAnimation, and ColorAnimation are used to animate double, point, and color-type properties of a control.  These animations have keyframe-based companions (DoubleAnimationUsingKeyFrames, PointAnimationUsingKeyframes, you get the idea) that use keyframing to perform the animation.  Keyframing is a technique by which frames are interpolated between key points that are set in an animation.
</p>
<h3>
<div style="text-decoration:underline;margin-bottom:10px;">Bonus: DependencyObject and DependencyProperty</div>
</h3>
<p style="text-align:justify;">DependencyObjects and DependencyProperties were not in the mind map, but they are important enough that they probably should have been, so I&#8217;ll go into them briefly here.
</p>
<p style="text-align:justify;">
Silverlight controls need lots of dependencies on each other for things like animation and layout.  This requires more than the common model of using private fields to back public properties.  <a href="http://msdn.microsoft.com/en-us/library/cc221408%28VS.95%29.aspx">DependencyProperties</a> are like super-properties.  When the values of a DependencyProperty are getted (is that a word?) or setted (again?) the internal implementation of DependencyObject (DependencyProperties&#8217; base class) allows other things to happen, like notifying an ObservableCollection that a member has been updated (this is databinding), or animating a property of a control from outside the scope of that control.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daveswersky.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daveswersky.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daveswersky.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daveswersky.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daveswersky.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daveswersky.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daveswersky.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daveswersky.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daveswersky.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daveswersky.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daveswersky.com&blog=9388197&post=180&subd=daveswersky&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://daveswersky.com/2009/09/29/silverlight-research-summary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9deb91da08d8ec815376a517793eccca?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">daveswersky</media:title>
		</media:content>
	</item>
	</channel>
</rss>