<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Context Variables in Ninject</title>
	<atom:link href="http://kohari.org/2008/03/13/context-variables-in-ninject/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohari.org/2008/03/13/context-variables-in-ninject/</link>
	<description>Rambling and occasional wisdom from Nate Kohari</description>
	<lastBuildDate>Tue, 09 Mar 2010 12:47:18 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Haacked</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-80</link>
		<dc:creator>Haacked</dc:creator>
		<pubDate>Fri, 29 May 2009 21:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-80</guid>
		<description>If you don&#039;t need to change the default behavior for looking up controller types by name, there&#039;s a simpler option. Simply have your controller factory inherit from DefaultControllerFactory. Then in your CreateController method:

public override IController CreateController(RequestContext requestContext, string controllerName)
{
    IController controller = null;
    Type controllerType = base.GetControllerType(controllerName);
    if (controllerType != null) {
        controller = this.Kernel.Get(controllerType, new IParameter[0]) as IController;
    }
    return controller;
}

Note that I&#039;m simply calling into DefaultController&#039;s implementation for looking up the controller type based on the controller name. Once I have the type, then I call into Ninject. Saves a lot of work.</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t need to change the default behavior for looking up controller types by name, there&#8217;s a simpler option. Simply have your controller factory inherit from DefaultControllerFactory. Then in your CreateController method:</p>
<p>public override IController CreateController(RequestContext requestContext, string controllerName)<br />
{<br />
    IController controller = null;<br />
    Type controllerType = base.GetControllerType(controllerName);<br />
    if (controllerType != null) {<br />
        controller = this.Kernel.Get(controllerType, new IParameter[0]) as IController;<br />
    }<br />
    return controller;<br />
}</p>
<p>Note that I&#8217;m simply calling into DefaultController&#8217;s implementation for looking up the controller type based on the controller name. Once I have the type, then I call into Ninject. Saves a lot of work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Dickinson</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-86</link>
		<dc:creator>Jonathan Dickinson</dc:creator>
		<pubDate>Mon, 06 Oct 2008 13:12:11 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-86</guid>
		<description>And I just noticed my angle brackets were stripped. Here we go again:

GetAs&lt;T&gt;(Type) where T : class
GetCastedTo&lt;T&gt;(Type)</description>
		<content:encoded><![CDATA[<p>And I just noticed my angle brackets were stripped. Here we go again:</p>
<p>GetAs&lt;T&gt;(Type) where T : class<br />
GetCastedTo&lt;T&gt;(Type)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Dickinson</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-85</link>
		<dc:creator>Jonathan Dickinson</dc:creator>
		<pubDate>Mon, 06 Oct 2008 13:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-85</guid>
		<description>Oops. I meant to type GetAs(Type) where T : class</description>
		<content:encoded><![CDATA[<p>Oops. I meant to type GetAs(Type) where T : class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Dickinson</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-84</link>
		<dc:creator>Jonathan Dickinson</dc:creator>
		<pubDate>Mon, 06 Oct 2008 13:06:17 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-84</guid>
		<description>I have a [very] small suggestion. How about creating a little more syntactic sugar. Currently your Get(Type) method returns an object, how about creating the following methods:

GetAs(Type type) where T : object
... Other ones similar to Get() or Get(Type)

GetCastedTo(Type type) // Attempts a cast and will not handle the exception if it occurs.
... Other ones similar to Get() or Get(Type)</description>
		<content:encoded><![CDATA[<p>I have a [very] small suggestion. How about creating a little more syntactic sugar. Currently your Get(Type) method returns an object, how about creating the following methods:</p>
<p>GetAs(Type type) where T : object<br />
&#8230; Other ones similar to Get() or Get(Type)</p>
<p>GetCastedTo(Type type) // Attempts a cast and will not handle the exception if it occurs.<br />
&#8230; Other ones similar to Get() or Get(Type)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Kohari</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-83</link>
		<dc:creator>Nate Kohari</dc:creator>
		<pubDate>Wed, 24 Sep 2008 10:24:20 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-83</guid>
		<description>@How: You&#039;re right, this post shows the old syntax, which has changed in the latest trunk build (which will become Ninject 1.5).</description>
		<content:encoded><![CDATA[<p>@How: You&#8217;re right, this post shows the old syntax, which has changed in the latest trunk build (which will become Ninject 1.5).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How Lun</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-82</link>
		<dc:creator>How Lun</dc:creator>
		<pubDate>Wed, 24 Sep 2008 08:33:07 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-82</guid>
		<description>There are errors in the code:

No ContextVariable found under Ninject.Core.Parameters.With class:
    With.Parameters.ContextVariable(“controllerName”, controllerName)

I use the below one:
    With.Parameters.Variable(&quot;controllerName&quot;, controllerName)


Same to:
    When.ContextVariable(“controllerName”).EqualTo(“user”)

I use:
    When.Context.Variable(&quot;controllerName&quot;).EqualTo(&quot;user&quot;)

Cheers.</description>
		<content:encoded><![CDATA[<p>There are errors in the code:</p>
<p>No ContextVariable found under Ninject.Core.Parameters.With class:<br />
    With.Parameters.ContextVariable(“controllerName”, controllerName)</p>
<p>I use the below one:<br />
    With.Parameters.Variable(&#8221;controllerName&#8221;, controllerName)</p>
<p>Same to:<br />
    When.ContextVariable(“controllerName”).EqualTo(“user”)</p>
<p>I use:<br />
    When.Context.Variable(&#8221;controllerName&#8221;).EqualTo(&#8221;user&#8221;)</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How Lun</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-81</link>
		<dc:creator>How Lun</dc:creator>
		<pubDate>Tue, 23 Sep 2008 09:55:05 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-81</guid>
		<description>Perfect, this is what I have been looking for the past 3 days! Thanks.</description>
		<content:encoded><![CDATA[<p>Perfect, this is what I have been looking for the past 3 days! Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Hanselman's Computer Zen - List of .NET Dependency Injection Containers (IOC)</title>
		<link>http://kohari.org/2008/03/13/context-variables-in-ninject/comment-page-1/#comment-79</link>
		<dc:creator>Scott Hanselman's Computer Zen - List of .NET Dependency Injection Containers (IOC)</dc:creator>
		<pubDate>Fri, 14 Mar 2008 21:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2008/03/13/context-variables-in-ninject/#comment-79</guid>
		<description>&lt;p&gt;[...] Context Variables in Ninject [...]&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>[...] Context Variables in Ninject [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
