<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Right Brain Left &#187; Development</title>
	<atom:link href="http://rightbrainleft.net/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://rightbrainleft.net</link>
	<description>C# and Game Development</description>
	<lastBuildDate>Thu, 01 Dec 2011 00:29:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to use Dropbox to Share a UDK Map Folder</title>
		<link>http://rightbrainleft.net/2011/10/how-to-use-dropbox-to-share-a-udk-map-folder/</link>
		<comments>http://rightbrainleft.net/2011/10/how-to-use-dropbox-to-share-a-udk-map-folder/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 23:44:23 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=297</guid>
		<description><![CDATA[Our team was having trouble sharing our work-in-progress UDK map files with each other over the popular file sharing software Dropbox. Dropbox by default creates a single destination folder on your hard drive to store all the files on your account. However saving our map files outside of the UDK Content directories cause some significant [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://rightbrainleft.net/wp-content/uploads/2011/10/UDKDropbox.jpg"><img src="http://rightbrainleft.net/wp-content/uploads/2011/10/UDKDropbox-300x167.jpg" alt="" title="UDKDropbox" width="300" height="167" class="alignright size-medium wp-image-300" /></a>Our team was having trouble sharing our work-in-progress UDK map files with each other over the popular file sharing software <a href="https://www.dropbox.com/">Dropbox</a>. Dropbox by default creates a single destination folder on your hard drive to store all the files on your account. However saving our map files outside of the UDK Content directories cause some significant problems with finding references and level streaming just plain didn&#8217;t work.</p>
<p>There is a way, however, to make both Dropbox and UDK happy by using a symbolic link between two folders in Windows. Follow this <a href="http://www.maximumpc.com/article/howtos/howto_master_your_file_system_mklink">great write up and tutorial by Alex Castle</a> to learn more about how these work. The short version is that a simple command line utility will let you create a brand new folder within the UDK Maps folder which is bound to one of your local Dropbox folders. Here&#8217;s the command to run from your command prompt&#8230;</p>
<pre class="brush: plain;">mklink /J &quot;C:\UDK\UDK-2011-09\UDKGame\Content\Maps\MyTeamFolder\&quot; &quot;C:\Users\MyUsersFolder\Dropbox\MyTeamShareFolder&quot;</pre>
<p>The breakdown: mlink.exe is the utility which creates the link, /J says make a hard link between the two folders, the first path is where you would like a new folder to be created (it should be inside your UDK maps directory) and the second path is the path for your already existing Dropbox folder for sharing.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2011/10/how-to-use-dropbox-to-share-a-udk-map-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Default MVC model binder doesn&#8217;t like fields</title>
		<link>http://rightbrainleft.net/2011/02/default-mvc-model-binder-doesnt-like-fields/</link>
		<comments>http://rightbrainleft.net/2011/02/default-mvc-model-binder-doesnt-like-fields/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 04:42:03 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[auto implemented property]]></category>
		<category><![CDATA[DefaultModelBinder]]></category>
		<category><![CDATA[model binding]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC3]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=287</guid>
		<description><![CDATA[This issue came up both in trying to complete an MVC 3 exercise and recently again when trying to bind an existing Action with a new View model. The form in the View code was posting to the same Action with a few values specified in GET variables, but the variables were being mysteriously swallowed [...]]]></description>
			<content:encoded><![CDATA[<div>This issue came up both in trying to complete an MVC 3 exercise and recently again when trying to bind an existing Action with a new View model. The form in the View code was posting to the same Action with a few values specified in GET variables, but the variables were being mysteriously swallowed by the Model Binder and not bound despite the variables being named exactly the same as the members of my Model! This is what I discovered both times&#8230;</div>
<pre class="brush: csharp;">
public class ExampleViewModel
{
	public string ThisPropertyWillBeBound { get; set; }
	public int ThisOneToo { get; set; }

	public string ThisFieldWontThough;
	public int WatchOutForThis;
}
</pre>
<div>If you are defining a custom type as an argument for an Action, the DefaultModelBinder can only map GET variables posted to the Action to Properties on that custom type. In the above example, if I had a WatchOutForThis=really value in my GET variables, the binder ignores this entirely since WatchOutForThis is a field and not a property.</p>
<p>The difference between creating a field and an auto implemented property is so subtle this can be a really tricky one to catch! Check this if your suddenly find values mysteriously missing between receiving the request and getting to your Action code.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2011/02/default-mvc-model-binder-doesnt-like-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to select checkboxes from comma separated list with jQuery</title>
		<link>http://rightbrainleft.net/2010/09/how-to-select-checkboxes-from-comma-separated-list-with-jquery/</link>
		<comments>http://rightbrainleft.net/2010/09/how-to-select-checkboxes-from-comma-separated-list-with-jquery/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 16:12:44 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=253</guid>
		<description><![CDATA[If you have checkboxes that are grouped by having the same name, the value sent via POST will contain all the selected item values as a comma separated list. I inherited some code that was doing this and wanted a quick way of taking this same comma separated value and reselecting the checkboxes from it. [...]]]></description>
			<content:encoded><![CDATA[<p>If you have checkboxes that are grouped by having the same name, the value sent via POST will contain all the selected item values as a comma separated list. I inherited some code that was doing this and wanted a quick way of taking this same comma separated value and reselecting the checkboxes from it. The following Javascript snippet I developed using jQuery does just that.</p>
<pre class="brush: jscript;">
// Takes comma-delimited list of preselected values and selects html checkboxes
$(document).ready(function(){
var array = &quot;&lt;%=originalValue%&gt;&quot;.split(',');
for (var i in array)
$(&quot;[name=myCheckboxName][value=&quot; + $.trim(array[i]) + &quot;]&quot;).attr('checked', true);
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/09/how-to-select-checkboxes-from-comma-separated-list-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Powershell to inspect folder permissions</title>
		<link>http://rightbrainleft.net/2010/06/using-powershell-to-inspect-folder-permissions/</link>
		<comments>http://rightbrainleft.net/2010/06/using-powershell-to-inspect-folder-permissions/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 17:47:23 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[folder permissions]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[recurse]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=173</guid>
		<description><![CDATA[We wanted to find out which folders had special write/modify permissions in a website, so we could switch out the current anonymous user account for a new one. Bellow is a Powershell command that we used&#8230; dir D:\Inetpub\Wwwroot\target\ -recurse -exclude *.*  &#124; Get-Acl &#124; % { @{Path=$_.Path; Access=$_.Access}} &#124;% {$a = $_.Access $b = @($a [...]]]></description>
			<content:encoded><![CDATA[<p>We wanted to find out which folders had special write/modify permissions in a website, so we could switch out the current anonymous user account for a new one. Bellow is a Powershell command that we used&#8230;</p>
<pre class="brush: plain;">dir D:\Inetpub\Wwwroot\target\ -recurse -exclude *.*  | Get-Acl | % { @{Path=$_.Path; Access=$_.Access}} |% {$a = $_.Access
$b = @($a | ?{ $_.IsInherited -ne $true -and $_.IdentityReference -and ($_.IdentityReference -contains &quot;NT AUTHORITY\Network Service&quot; -or $_.IdentityReference -contains &quot;MACHINE\IUSR_MACHINE&quot;) }|%{ $_.IdentityReference, $_.FileSystemRights})
if ($b.count -gt 0) {$_.Path, $b}
} &gt;&gt; D:\temp\FolderPermissionsWeb.txt</pre>
<div id="_mcePaste">There&#8217;s a couple of things going on here, but it&#8217;s really rather simple. The first segment goes to a directory, and returns all child items that are not files recursively.</div>
<pre class="brush: plain;">dir D:\Inetpub\Wwwroot\target\ -recurse -exclude *.*</pre>
<p>The pipe takes the results and performs another command, in this case Get-Acl. Get-Acl returns a list of all access control levels for the items. So at this point we&#8217;ve already got all access permission for all the folders in the search. My first proof of concept included only these two commands and outputed the results straight to the command prompt. It was enough to get the job done since it showed me all access for everyone on those folders!</p>
<p>The rest of the statements are all about pruning the results down to only the information I want.</p>
<pre class="brush: plain;">$b = @($a | ?{ $_.IsInherited -ne $true -and $_.IdentityReference -and ($_.IdentityReference -contains &quot;NT AUTHORITY\Network Service&quot; -or $_.IdentityReference -contains &quot;MACHINE\IUSR_MACHINE&quot;) }|%{ $_.IdentityReference, $_.FileSystemRights})</pre>
<p>This section achieves that. The end of the first line declares $a as a list of all ACL it could find.  I then declared a variable called $b that will contain all the results from $a that match my conditions. I don&#8217;t want to see any access that has been inherited, and I only want to see right assigned for Network Service or the machine&#8217;s IUSER account (IUSER account name varies per machine).</p>
<pre class="brush: plain;">if ($b.count -gt 0) {$_.Path, $b}
} &gt;&gt; D:\temp\FolderPermissionsWeb.txt</pre>
<p>Finally, I check to see if there are any matches, and then append them to my file. The code here is sort of rough, which I will chalk up to being a novice at Powershell. I&#8217;d hope to make it shorter and format the output a little more, which I&#8217;ll work on.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/06/using-powershell-to-inspect-folder-permissions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to bind a nested enumerated control from an ObjectDataSource</title>
		<link>http://rightbrainleft.net/2010/04/how-to-bind-a-nested-enumerated-control-from-an-objectdatasource/</link>
		<comments>http://rightbrainleft.net/2010/04/how-to-bind-a-nested-enumerated-control-from-an-objectdatasource/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 04:05:27 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[IEnumerable]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=162</guid>
		<description><![CDATA[If you have multiple levels of enumerated controls (ie. Repeaters, ListViews) that need to be databound to properties of a bound DataItem, use the below DataSource property on the nested control&#8230; DataSource='&#60;%# DataBinder.Eval(Container.DataItem, &#34;Tags&#34;)%&#62;' This can be required if you have some sort of hierarchical data. My example came up while loading article posts that [...]]]></description>
			<content:encoded><![CDATA[<p>If you have multiple levels of enumerated controls (ie. Repeaters, ListViews) that need to be databound to properties of a bound DataItem, use the below DataSource property on the nested control&#8230;</p>
<pre class="brush: plain;">DataSource='&lt;%#  DataBinder.Eval(Container.DataItem, &quot;Tags&quot;)%&gt;'</pre>
<p>This can be required if you have some sort of hierarchical data. My example came up while loading article posts that contained a list of tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/04/how-to-bind-a-nested-enumerated-control-from-an-objectdatasource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glorious Toys versus Empathic Storytelling</title>
		<link>http://rightbrainleft.net/2010/03/glorious-toys-versus-empathic-storytelling/</link>
		<comments>http://rightbrainleft.net/2010/03/glorious-toys-versus-empathic-storytelling/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 06:24:37 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Full Sail]]></category>
		<category><![CDATA[game design]]></category>
		<category><![CDATA[Spore]]></category>
		<category><![CDATA[Will Wright]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=149</guid>
		<description><![CDATA[Two years ago I picked up the pre-acclaimed PC game, Spore. This was after downloading the sample Creature Creator, listening to over a year of evangelizing from Electronic Arts, and dealing with their intrusive DRM. When I finally inserted the disk and got my hands dirty, I was underwhelmed. As a long-time gamer, I could [...]]]></description>
			<content:encoded><![CDATA[<p>Two years ago I picked up the pre-acclaimed PC game, Spore. This was after downloading the sample Creature Creator, listening to over a year of evangelizing from Electronic Arts, and dealing with their intrusive DRM. When I finally inserted the disk and got my hands dirty, I was underwhelmed. As a long-time gamer, I could easily point out the product’s influences. In fact, I often felt my time could be better spent playing it’s inspiring works; flOw, World of Warcraft, Age of Empires and Civilization to name a few. It found it’s way into a box of loose disks where it sits as we speak.</p>
<p>Despite my experience, to <a href="http://www.ted.com/talks/view/id/146" target="_blank">hear Will Wright talk about his creation</a> is quite an eye opener. Having grown up in a Montessori school, Will expresses a game development philosophy based loosely on the Montessori method. This approach unlocks the potential of the audience by providing them with ‘high-leverage tools’ to allow the player to be &#8216;building this world in their imagination and extract it from them with the least amount of pain’. He is presenting the game as a toy which the player can play with, and be empowered by.</p>
<p>Hearing his justification, I feel like I’m a little more connected to the game and I can experience it the way it was intended. He created a game that does not drive the player, but let’s the player drive themselves through curiosity. Moreover his use of the term &#8216;high-leverage&#8217; tools is something I appreciate and agree with. The interface should be intuitive and empowering.</p>
<p>Still, I felt after a few days of playing that I was not engaged. Inversely to Spore&#8217;s ideal, other games may introduce a protagonist, or some relatable character that the player can empathize with. This is something the game lacks. Spore creates investment by allowing the player to personalize many, many details of the organisms they represent. But there’s always a level of separation provided by the ‘God’ complex granted by the game. Without a compelling goal paired with a sense of mortal investment, you’re left with the very feeling Mr. Wright was pursuing… the feeling of playing with a toy.</p>
<p>I can’t whole-heartedly condemn his philosophy, especially since I have an invigorated desire to play with Will Wright’s bright and well-intentioned toy once again. On the other hand, as a consumer I often seek an empathy and connectedness. To me, it is very important to give a game the staying power to live on in my memory, and I think this is the sort of thing that comes to mind for many gamers.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/03/glorious-toys-versus-empathic-storytelling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where&#8217;s Your IP?</title>
		<link>http://rightbrainleft.net/2010/03/wheres-your-ip/</link>
		<comments>http://rightbrainleft.net/2010/03/wheres-your-ip/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 03:58:28 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Full Sail]]></category>
		<category><![CDATA[game design]]></category>
		<category><![CDATA[Intellectual property]]></category>
		<category><![CDATA[IP]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=130</guid>
		<description><![CDATA[Securing your intellectual property is an important yet ambiguous aspect of being a fledgling creator. It’s hard enough developing your skills and finding inspiration, the last thing on your mind is making sure that you’ve meticulously filed away the legal rights to your own, barely existing creative notions. In June of 1972, Nolan Bushnell founded the [...]]]></description>
			<content:encoded><![CDATA[<p>Securing your intellectual property is an important yet ambiguous aspect of being a fledgling creator. It’s hard enough developing your skills and finding inspiration, the last thing on your mind is making sure that you’ve meticulously filed away the legal rights to your own, barely existing creative notions.</p>
<p>In June of 1972, Nolan Bushnell founded the company which would come to be a household name, <em>Atari</em>. By September, he would begin marketing the game <em>Pong</em>. After a shockingly positive test run of the game in a local bar named Andy Capps’s Tavern, Nolan was ready to take the country by storm and begin mass producing the game. But being a free spirit, he ignored some of the finer points of securing his intellectual property… namely all of them.</p>
<p>The first speed-bump came immediately, when Atari was taken to court by Magnavox. Magnavox had created a gaming system for the home named <em>Odyssey</em>, which played a game extremely similar to <em>Pong.</em> The matter was settled out of court, and involved Atari paying a hefty license sum to keep <em>Pong</em> on it’s path to greatness. Part of this interaction could just be chalked up to an industry leader kicking a small start-up, but the facts came down to Magnavox’s attention to the ownership and patents surrounding their product. Bushnell, a driven and talented creator/entrepreneur, was focused more on the creating. In the time following the launch of the game, he overlook filing patents for <em>Pong</em>. By the time the patents were validated, over two-thirds of the market was saturated with <em>Pong</em> imitators.</p>
<p>Was Nolan well off? Yes. Was Atari a successful company despite the missteps? Absolutely. But Nolan was in a lucky position, the market was non-existent. While competitors could pirate his innovations, Atari’s ideas were a step ahead of the curve. They would have the next big idea in the works by the time the market was oversaturated with the last. This approach was effective for the time, and you could even say that the knockoffs were good to the industry, as it increased the visibility. Also, arcade machines were sold in an era of more personal communication, will sales representatives approaching reputable brick-and-mortar locations to sell their machines with a handshake.</p>
<p>In this time, of an established games industry however, it’s not advisable to go in so haphazardly. As you put effort into divining inspiration and honing your skills, you should research what you can do to protect your work. In the digital age where ‘page views’ and total downloads are valued, it’s easy to watch your bottom line disappear. A consumer can just as easily get your product from a competitor that is only a click away. Marketing your work to become the most prevalent and connected, and challenging imitators will keep your inspired creations attached to you and allow your passion and creativity to continue unhindered.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/03/wheres-your-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script controls may not be registered before PreRender</title>
		<link>http://rightbrainleft.net/2010/01/script-controls-may-not-be-registered-before-prerender/</link>
		<comments>http://rightbrainleft.net/2010/01/script-controls-may-not-be-registered-before-prerender/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 20:44:07 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=126</guid>
		<description><![CDATA[This ended up being really simple. The page had a few UpdatePanels and a master page containing the ScriptManager. I went to add an UpdateProgress control and got the error&#8230; Script controls may not be registered before PreRender If you&#8217;ve gotten this error, before you go to explore the other possibilities, check to see if [...]]]></description>
			<content:encoded><![CDATA[<p>This ended up being really simple. The page had a few UpdatePanels and a master page containing the ScriptManager. I went to add an UpdateProgress control and got the error&#8230;</p>
<p><strong>Script controls may not be registered before PreRender</strong></p>
<p>If you&#8217;ve gotten this error, before you go to explore the other possibilities,<em> check to see if you&#8217;ve overridden the OnPreRender method for your page</em>. If so, make sure that you&#8217;ve included <strong>base.OnPreRender(e);</strong> up in the method somewhere. If this didn&#8217;t help, there are a number of other scenarios where this could happen and article about them on the internets.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2010/01/script-controls-may-not-be-registered-before-prerender/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Trim Hierarchical Data Without Breaking It</title>
		<link>http://rightbrainleft.net/2009/11/how-to-trim-hierarchical-data-without-breaking-it/</link>
		<comments>http://rightbrainleft.net/2009/11/how-to-trim-hierarchical-data-without-breaking-it/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 14:52:11 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Hierarchical]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[recursive]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=112</guid>
		<description><![CDATA[We&#8217;ve got a Hierarchical list of nodes that make up a tree where users can expand/collapse and select different nodes. The nodes however come in two distinct types, and I needed to come up with a way of trimming the list on the fly to display one type or another. I came up with the [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a Hierarchical list of nodes that make up a tree where users can expand/collapse and select different nodes. The nodes however come in two distinct types, and I needed to come up with a way of trimming the list on the fly to display one type or another. I came up with the following code.</p>
<pre class="brush: csharp;">
private static List&lt;Node&gt; FilterList(List&lt;Node&gt; list, Utilities.TypeRequired type)
{
	List&lt;Node&gt; returnList = new List&lt;Node&gt;();

	// Go through each node of the full list and run the FilterNode recursive method
	foreach (Node item in list)
		returnList.AddRange(FilterNode(item, type));

	return returnList;
}

private static List&lt;Node&gt; FilterNode(Node item, Utilities.TypeRequired type)
{
	// Prep return list
	List&lt;Node&gt; list = new List&lt;Node&gt;();

	// call this same method on each of the children of this node, store in list
	foreach (var child in item.Children)
		list.AddRange(FilterNode(child, type));

	if (item.TypeId == (int)type)
	{
		// if the node is of the correct type, set it's current children to the
		// results from above and return the item within a list
		item.Children.Clear();
		item.Children.AddRange(list);
		return new List&lt;Node&gt;() { item };
	}
	else
		// if not, just return the children without the parent
		return list;
}
</pre>
<p>The <em>FilterList()</em> method accepts a list of nodes, this is considered to be the first level of children under the root node (in this case there is no root node). It also takes an object that I&#8217;ve called <em>TypeRequired</em>, really it can be any kind of data you&#8217;d like to use to evaluate the differences between one node and another. The method self-references on the children of the current node and so works through the whole tree.</p>
<p>The real trick here is that in cases where a parent node is not a match to the desired type, the <strong>children are promoted to it&#8217;s place in the hierarchy</strong> before the parent is removed. This way qualifying children stay in the list organized in the proper fashion.</p>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2009/11/how-to-trim-hierarchical-data-without-breaking-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pushing a file to the user to download with a programmatically generated name in ASP.NET</title>
		<link>http://rightbrainleft.net/2009/11/pushing-a-file-to-the-user-to-download-with-a-programmatically-generated-name-in-asp-net/</link>
		<comments>http://rightbrainleft.net/2009/11/pushing-a-file-to-the-user-to-download-with-a-programmatically-generated-name-in-asp-net/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 16:48:28 +0000</pubDate>
		<dc:creator>Wayne Denier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[contentType]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Response]]></category>
		<category><![CDATA[Stream]]></category>

		<guid isPermaLink="false">http://rightbrainleft.net/?p=99</guid>
		<description><![CDATA[I’ve been saving the files that I am receiving via user uploads with a unique identifier as the name (ie. 8b8c9145-1ce1-4cd1-99a7-fc57871b5671.pdf) so we don’t receive collisions with like named files. Here’s how I rewrite the filename to its’ original name (loaded from the database) before sending it back to the user. Using this you can [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been saving the files that I am receiving via user uploads with a unique identifier as the name (ie. 8b8c9145-1ce1-4cd1-99a7-fc57871b5671.pdf) so we don’t receive collisions with like named files. Here’s how I rewrite the filename to its’ original name (loaded from the database) before sending it back to the user. Using this you can make up any appropriate file name (ie UserReport_CurrentDate.xls).</p>
<pre class="brush: csharp;">

// Load the physical file into a byte array

byte[] byteArray = new byte[file.Size];
System.IO.Stream stream = file.GetFile();
stream.Read(byteArray, 0, file.Size);
stream.Close();

// Push the byte array to the user as a download
context.Response.BinaryWrite(byteArray);
context.Response.ContentType = file.MimeType;
context.Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment;filename=&quot; + context.Server.UrlEncode(file.FileName));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://rightbrainleft.net/2009/11/pushing-a-file-to-the-user-to-download-with-a-programmatically-generated-name-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

