<?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>ByteCyclist.com &#187; C#</title>
	<atom:link href="http://www.bytecyclist.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bytecyclist.com</link>
	<description>A site made of bytes by a cyclist.</description>
	<lastBuildDate>Tue, 20 Sep 2011 20:49:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Json.Net Action Result with Asp.Net MVC</title>
		<link>http://www.bytecyclist.com/2010/10/08/json-dot-net-action-result-with-asp-dot-net-mvc/</link>
		<comments>http://www.bytecyclist.com/2010/10/08/json-dot-net-action-result-with-asp-dot-net-mvc/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 14:00:01 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://www.bytecyclist.com/?p=284</guid>
		<description><![CDATA[Well this has probably been done 100 times before but so what, the world could always use more code. When working with ASP.Net MVC I started and fell in love with James Newton-King&#8217;s Json.Net library. It is simple awesome and &#8230; <a href="http://www.bytecyclist.com/2010/10/08/json-dot-net-action-result-with-asp-dot-net-mvc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well this has probably been done 100 times before but so what, the world could always use more code. When working with ASP.Net MVC I started and fell in love with <a href="http://james.newtonking.com/pages/json-net.aspx">James Newton-King&#8217;s Json.Net library</a>.  It is simple awesome and does an amazing job in different parts of my app.  The control over the serialzation and deserialization is very good and thought it would be well suited for my MVC application.</p>
<p>You might be thinking, why not just use the one that comes with .Net. It&#8217;s in the box and is just as good. Well my preference was control, I wanted to control my model better and I wanted to output Json differently in different situations. So I created a new ActionResult that does just that but with the <a href="http://james.newtonking.com/pages/json-net.aspx">Json.Net library</a>.  Enjoy!</p>
<p>Example usage in any controller action:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> ActionResult List<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> Year, <span style="color: #6666cc; font-weight: bold;">int</span> Month<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Year <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        Year <span style="color: #008000;">=</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Year</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Month <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        Month <span style="color: #008000;">=</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Month</span><span style="color: #008000;">;</span>
&nbsp;
    var calendarMonth <span style="color: #008000;">=</span> _calendarService<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCalendarMonth</span><span style="color: #008000;">&#40;</span>Year, Month, <span style="color: #008000;">!</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsAdmin</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> JsonNetResult<span style="color: #008000;">&#40;</span>calendarMonth<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The code is below, but it can also be downloaded <a href="http://gist.github.com/gists/606739/download">here</a> and found on <a href="http://github.com">Github</a> <a href="http://gist.github.com/606739">here</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.Mvc</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Newtonsoft.Json</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Newtonsoft.Json.Converters</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> com<span style="color: #008000;">.</span><span style="color: #0000FF;">bytecyclist</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> JsonNetResult <span style="color: #008000;">:</span> ActionResult
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Encoding ContentEncoding <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ContentType <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">object</span> Data <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> JsonSerializerSettings SerializerSettings <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Formatting Formatting <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> JsonNetResult<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            SerializerSettings <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> JsonSerializerSettings<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            SerializerSettings<span style="color: #008000;">.</span><span style="color: #0000FF;">Converters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> JavaScriptDateTimeConverter<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Formatting <span style="color: #008000;">=</span> Formatting<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> JsonNetResult<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> data<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Data <span style="color: #008000;">=</span> data<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> ExecuteResult<span style="color: #008000;">&#40;</span>ControllerContext context<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>context <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> ArgumentNullException<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;context&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            var response <span style="color: #008000;">=</span> context<span style="color: #008000;">.</span><span style="color: #0000FF;">HttpContext</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">;</span>
            response<span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>ContentType<span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> ContentType <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;application/json&quot;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ContentEncoding <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                response<span style="color: #008000;">.</span><span style="color: #0000FF;">ContentEncoding</span> <span style="color: #008000;">=</span> ContentEncoding<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Data <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
            var writer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> JsonTextWriter<span style="color: #008000;">&#40;</span>response<span style="color: #008000;">.</span><span style="color: #0000FF;">Output</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> Formatting <span style="color: #008000;">=</span> Formatting <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
            var serializer <span style="color: #008000;">=</span> JsonSerializer<span style="color: #008000;">.</span><span style="color: #0000FF;">Create</span><span style="color: #008000;">&#40;</span>SerializerSettings<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            serializer<span style="color: #008000;">.</span><span style="color: #0000FF;">Serialize</span><span style="color: #008000;">&#40;</span>writer, Data<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            writer<span style="color: #008000;">.</span><span style="color: #0000FF;">Flush</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bytecyclist.com/2010/10/08/json-dot-net-action-result-with-asp-dot-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Asp.Net MVC Navigation Menu</title>
		<link>http://www.bytecyclist.com/2010/10/01/simple-asp-net-mvc-navigation-menu/</link>
		<comments>http://www.bytecyclist.com/2010/10/01/simple-asp-net-mvc-navigation-menu/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 19:44:59 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[MVC 2]]></category>

		<guid isPermaLink="false">http://www.bytecyclist.com/?p=304</guid>
		<description><![CDATA[Well it&#8217;s October first, it has been a really long time since I have last written anything. Oh well. Recently I have been working on applying some updates to an MVC site I maintain, as usual I updated the dependencies, &#8230; <a href="http://www.bytecyclist.com/2010/10/01/simple-asp-net-mvc-navigation-menu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well it&#8217;s October first, it has been a really long time since I have last written anything. Oh well.  Recently I have been working on applying some updates to an MVC site I maintain, as usual I updated the dependencies, ran some tests, and looked over the code.  It&#8217;s been a while since I last opened the project since it has been in production.  Of course, I was not happy with a couple things in the application and was constantly fixing the same bugs in the navigation menu.</p>
<p>There are always the same questions with a navigation menu, how do you render the html, how do you know what item is selected, how to achieve 2 level menus, and how do you trim by security.  To give some history; I went from defining only a single level with no selection (action links in an un-ordered list).  Then I found a project on <a href="http://codeplex.com/">codeplex</a> called <a href="http://mvcsitemap.codeplex.com/">ASP.NET MVC SiteMap Provider</a>, this is great it has a ton of features, fits the provider model of ASP.Net, easy to define and use in simple cases.  Unfortunately, it is not as mature as I would like.  Plus it adds another dependency that is hard to work with and does not always work the way I would expect it to.  Needless to say it is buggy (my opinion and experience only, others may differ).</p>
<p>Which brings me to my subject line.  I wanted to create my own navigation system and have full control over the levels, rendering and selection of the items. Perfect, I needed a partial to render the menu and top level items in my own un-ordered list. I also needed some helpers to render those items in my partial, in this case the top level is a list of my controllers.</p>

<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;">&lt;ul id=&quot;navigation&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Home&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Calendar&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Media&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Messages&quot;</span>, <span style="color: #cc0000;">&quot;Forum&quot;</span>, <span style="color: #cc0000;">&quot;Index&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Goods&quot;</span>, <span style="color: #cc0000;">&quot;Catalog&quot;</span>, <span style="color: #cc0000;">&quot;Index&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Links&quot;</span>, <span style="color: #cc0000;">&quot;Link&quot;</span>, <span style="color: #cc0000;">&quot;Index&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Contact&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">LoginStatusNavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span>
&lt;/ul&gt;
&nbsp;
&lt;div class=&quot;clearboth&quot;&gt;&lt;/div&gt;
&nbsp;
&lt;ul id=&quot;subnavigation&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">SubNavListItems</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">=</span> Html.<span style="color: #9900cc;">NavItem</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Join Our Mailing List!&quot;</span>, <span style="color: #cc0000;">&quot;Contact&quot;</span>, <span style="color: #cc0000;">&quot;MailingList&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span>
&lt;/ul&gt;</pre></div></div>

<p>I also added a helper to render the login/logout link in the navigation based on whether the request was authenticated.  The second level navigation was where the work came in. Essentially I wanted to render some of the actions from the current controller based on a attribute assigned to the action. The rending will then sort the list based on the sort order and perform security trimming.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>NavigationItem<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;About Us&quot;</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> ActionResult Index<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> View<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Index&quot;</span>, GetIndexModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>NavigationItem<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Secured Page&quot;</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>, Authorize<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> ActionResult Admin<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> View<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Index&quot;</span>, GetIndexModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>In order to do that I created a custom Attribute to store the link text and the order it should be in.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>AttributeUsage<span style="color: #008000;">&#40;</span>AttributeTargets<span style="color: #008000;">.</span><span style="color: #0000FF;">Method</span>, Inherited <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span>, AllowMultiple <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">internal</span> <span style="color: #0600FF; font-weight: bold;">sealed</span> <span style="color: #6666cc; font-weight: bold;">class</span> NavigationItemAttribute <span style="color: #008000;">:</span> Attribute
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> NavigationItemAttribute<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> text<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span>text, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> NavigationItemAttribute<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> text, <span style="color: #6666cc; font-weight: bold;">int</span> order<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Text <span style="color: #008000;">=</span> text<span style="color: #008000;">;</span>
        SortOrder <span style="color: #008000;">=</span> order<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Text <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> SortOrder <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>After that I needed a way to cache all this information in order to look it up later from my helpers. Populating this cache involves doing some basic reflection and type checking of controller actions. Then storing the results in a dictionary based on controller name as the key and a list of actions with the NavigationItemAttribute (stored as a ControllerNavigationItem, which is a POCO object to store data).  Since I only wanted to do this reflection once, I created a singleton to do the work.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">sealed</span> <span style="color: #6666cc; font-weight: bold;">class</span> ControllerNavigationItemCollection
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> ControllerNavigationItemCollection _instance<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">object</span> padlock <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, IEnumerable<span style="color: #008000;">&lt;</span>ControllerNavigationItem<span style="color: #008000;">&gt;&gt;</span> Controllers <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    ControllerNavigationItemCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Controllers <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, IEnumerable<span style="color: #008000;">&lt;</span>ControllerNavigationItem<span style="color: #008000;">&gt;&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        PopulateCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> PopulateCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var asm <span style="color: #008000;">=</span> Assembly<span style="color: #008000;">.</span><span style="color: #0000FF;">GetExecutingAssembly</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        var controllers <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">from</span> t <span style="color: #0600FF; font-weight: bold;">in</span> asm<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTypes</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                           <span style="color: #0600FF; font-weight: bold;">where</span>
                               <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Controller<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsAssignableFrom</span><span style="color: #008000;">&#40;</span>t<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span>
                               <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Controller<span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> t
                           <span style="color: #0600FF; font-weight: bold;">select</span> t<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToList</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        controllers<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">ForEach</span><span style="color: #008000;">&#40;</span>t <span style="color: #008000;">=&gt;</span> Controllers<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>t<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, GetControllerNavItems<span style="color: #008000;">&#40;</span>t<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> IEnumerable<span style="color: #008000;">&lt;</span>ControllerNavigationItem<span style="color: #008000;">&gt;</span> GetControllerNavItems<span style="color: #008000;">&#40;</span>Type controllerType<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var controllerDescriptor <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ReflectedControllerDescriptor<span style="color: #008000;">&#40;</span>controllerType<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        var actions <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">from</span> a <span style="color: #0600FF; font-weight: bold;">in</span> controllerDescriptor<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCanonicalActions</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                       let subNavAttr <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>NavigationItemAttribute<span style="color: #008000;">&#41;</span>a<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>NavigationItemAttribute<span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SingleOrDefault</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                       let authorize <span style="color: #008000;">=</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>AuthorizeAttribute<span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SingleOrDefault</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
                       <span style="color: #0600FF; font-weight: bold;">where</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDefined</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>NavigationItemAttribute<span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span>
                       <span style="color: #0600FF; font-weight: bold;">select</span> <span style="color: #008000;">new</span> ControllerNavigationItem
                       <span style="color: #008000;">&#123;</span>
                           Action <span style="color: #008000;">=</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">ActionName</span>,
                           Controller <span style="color: #008000;">=</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">ControllerDescriptor</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ControllerName</span>,
                           IsSecure <span style="color: #008000;">=</span> authorize <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span>,
                           SortOrder <span style="color: #008000;">=</span> subNavAttr<span style="color: #008000;">.</span><span style="color: #0000FF;">SortOrder</span>,
                           Text <span style="color: #008000;">=</span> subNavAttr<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span>
                       <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AsEnumerable</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> actions<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> ControllerNavigationItemCollection Current
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">lock</span> <span style="color: #008000;">&#40;</span>padlock<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> _instance <span style="color: #008000;">??</span> <span style="color: #008000;">&#40;</span>_instance <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ControllerNavigationItemCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Finnaly to render the second level navigation I look up the list based on the current controller and loop over the items, only rendering the secure and authenticated items or the public items in the order defined by the attribute.</p>
<p>In hindsight, there are some things I could have made better or more features I could support. Currently it just checks to see if your logged in and doesn&#8217;t take into account any specific roles on the action.  Also it lacks support for MVC 2 Areas, but I don&#8217;t have any yet so I will cross that bridge when I get to it. This solution was simply an exercise for me in creating a singleton, using reflection to find controllers and actions, and to fill a common need in an ASP.Net MVC application.  Hope you found this interesting or useful.</p>
<p>Download the code <a href="http://gist.github.com/gists/606514/download">here</a> or check out the <a href="http://gist.github.com/606514">Gist</a> on <a href="http://github.com">Github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bytecyclist.com/2010/10/01/simple-asp-net-mvc-navigation-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>log4net Dynamic Properties in XML Configuration.</title>
		<link>http://www.bytecyclist.com/2009/06/12/log4net-dynamic-properties-in-xml-configuration/</link>
		<comments>http://www.bytecyclist.com/2009/06/12/log4net-dynamic-properties-in-xml-configuration/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 17:34:17 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[log4net]]></category>

		<guid isPermaLink="false">http://www.bytecyclist.com/?p=211</guid>
		<description><![CDATA[I just learned about a new feature today of log4net that would have saved me a few hours of time had I known or been able to find this earlier.Ã‚Â  I learned that you can have dynamic properties stored into &#8230; <a href="http://www.bytecyclist.com/2009/06/12/log4net-dynamic-properties-in-xml-configuration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just learned about a new feature today of log4net that would have saved me a few hours of time had I known or been able to find this earlier.Ã‚Â  I learned that you can have dynamic properties stored into log4net&#8217;s global context from code and then access them from the XML configuration file. This is useful in the case where dynamic configuration of log4net is needed.<span id="more-211"></span></p>
<p><strong>My Case:</strong> I have been building console application that will run nightly to sync some integration records and I wanted to setup logging in order to see that status of the job and gather some reporting information (counts, time run, etc).Ã‚Â  There was a catch though this process would run multiple times in a night but each time for a different customer.Ã‚Â  This would make it difficult to read the logs for a particular customer as all I would have to go on is the file date and time.</p>
<p>I needed a way to break my log files into different customers yet retain the rolling file appender features of log4net.Ã‚Â  My first pass at with was to configure log4net using the basic configurator all in code and create the appender, with a dynamic file name, and set the level of the logger programitacally. This was not my preferred way but was my only hope to getting the application out of developement. Then I found how to set properties into log4net&#8217;s global context and access them through the configuration file. I did run into a small problem that my app.config file was not being read in so I had to add these two variable to my assembly.</p>
<pre lang="C#">
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
[assembly: log4net.Config.Repository]
</pre>
<p>My goal was to make the file name dynamic based on the CustomerID passed into the application. Please not the file tag as it is the ticket to my case.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;log4net<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;level</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;INFO&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender-ref</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;RollingLogFileAppender&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- New Log File once per execution --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;RollingLogFileAppender&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;log4net.Appender.RollingFileAppender&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;log4net.Util.PatternString&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;logs\logFile_%property{BrokerID}.txt&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- Awesomeness --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appendToFile</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rollingStyle</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Size&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;maxSizeRollBackups</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;maximumFileSize</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;50GB&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;log4net.Layout.PatternLayout&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;conversionPattern</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;%date [%thread] %-5level %logger - %message%newline&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appender<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/log4net<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Here is a sample of my log4net configuration section.  Please note the file tag and type attribute to be log4net.Util.PatternString. The pattern of the value is important to, it must be %property{property_name} to get the right replacement. This is the ticket to dynamic values.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> InitLogger<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//This is freaking awesome, put a property into the log4net context and using the </span>
    <span style="color: #008080; font-style: italic;">//  log4net.Util.PatternString type you can dynamically set values for the logging context from code.</span>
    log4net<span style="color: #008000;">.</span><span style="color: #0000FF;">GlobalContext</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Properties</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;CustomerID&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>CustomerID<span style="color: #008000;">!=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> CustomerID<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;Error&quot;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Here is an example of my small InitLogger.  This method is the very first item to be called when the main routine starts up. All that needs to be done now is get a logger and start logging.  A file will be created based on the CustomerID which in this case is retrieved from the command line arguments before InitLogger is called. If no CustomerID is passed in than the file will be to logFile_Error.txt</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> ILog Logger<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        CustomerID<span style="color: #008000;">=</span> Util<span style="color: #008000;">.</span><span style="color: #0000FF;">GetInt</span><span style="color: #008000;">&#40;</span>args<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    InitLogger<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Logger <span style="color: #008000;">=</span> LogManager<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLogger</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Process&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Pretty cool I think, I hope this saves people some headaches.  I wish I would have found this a few days ago.  Oh well it is to my benefit to learn.  Happy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bytecyclist.com/2009/06/12/log4net-dynamic-properties-in-xml-configuration/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC Release Canidate</title>
		<link>http://www.bytecyclist.com/2009/01/29/aspnet-mvc-release-canidate/</link>
		<comments>http://www.bytecyclist.com/2009/01/29/aspnet-mvc-release-canidate/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 17:54:49 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://www.bytecyclist.com/?p=159</guid>
		<description><![CDATA[If you didn&#8217;t know already, ASP.Net MVC framework is int he release candidate stages. Wahoo!!!. As per usual ScottGu over at Microsoft posted insanely detailed remarks on the new features. Check it out here.. Some notable improvements that I have &#8230; <a href="http://www.bytecyclist.com/2009/01/29/aspnet-mvc-release-canidate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you didn&#8217;t know already, ASP.Net MVC framework is int he release candidate stages. Wahoo!!!. As per usual ScottGu over at Microsoft posted insanely detailed remarks on the new features. <a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx">Check it out here.</a>. Some notable improvements that I have used and like thus far include NO MORE CODE BEHIND FILES (this is my favorite), shortcut&#8217;s to switch between views and controllers, and &#8220;scaffold&#8221; like generation of views and controllers using the T4 template engine in Visual Studio.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bytecyclist.com/2009/01/29/aspnet-mvc-release-canidate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

