﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Dependency Injection: Separating the Container</title><description>Adam,
  
There are few options here.
  
The first is not dealing with that and letting the GC handle it. That is my most used option.
  
The other option is to add a Release() method to the Redirection service (or similar)
  
The final option is to use Dispose(), and supply an interceptor that would release the component from the container after dispose was called.
</description><link>http://ayende.com/2731/dependency-injection-separating-the-container#comment5</link><guid>http://ayende.com/2731/dependency-injection-separating-the-container#comment5</guid><pubDate>Fri, 24 Aug 2007 05:16:25 GMT</pubDate></item><item><title>Adam commented on Dependency Injection: Separating the Container</title><description>How do you deal with releasing components with out exposing the container?
</description><link>http://ayende.com/2731/dependency-injection-separating-the-container#comment4</link><guid>http://ayende.com/2731/dependency-injection-separating-the-container#comment4</guid><pubDate>Fri, 24 Aug 2007 01:10:07 GMT</pubDate></item><item><title>Tobias commented on Dependency Injection: Separating the Container</title><description>Thanks for picking this up from my comments. Moving/Hiding the calls to the IoC container solely into infrastructure code is something I haven't considered yet. I've always treated the DI container as part of my infrastructure, so "ObjectFactory.GetInstance&lt;OrderController&gt;().Activate()" doesn't look that much different than "Redirection.To&lt;OrderController&gt;().ActivateAndWait()" at the first sight. The latter improves the readability and might be the better way in the longer run. I have to try this out and see how far I get.
  
  
@Jeremy: Stop kicking yourself, "ObjectFactory" perfectly describes, what StructureMap does. I think "Container" is worse. I expect a container to be something I can put things in, move it around and get the things out of it again.
</description><link>http://ayende.com/2731/dependency-injection-separating-the-container#comment3</link><guid>http://ayende.com/2731/dependency-injection-separating-the-container#comment3</guid><pubDate>Thu, 23 Aug 2007 12:43:31 GMT</pubDate></item><item><title>Kevin Radcliffe commented on Dependency Injection: Separating the Container</title><description>This is a very nice looking API for the controller redirection, Thanks so much. I suspect I'll be able to move some code out of the application level and into infrastructure just as you suggest.
  
  
However, is there any source for a more fleshed-out example of this? Not looking for you to make a blog post out of it, but any links to source examples you know of that use something like this would be really really helpful. Thanks again
</description><link>http://ayende.com/2731/dependency-injection-separating-the-container#comment2</link><guid>http://ayende.com/2731/dependency-injection-separating-the-container#comment2</guid><pubDate>Wed, 22 Aug 2007 23:16:27 GMT</pubDate></item><item><title>Jeremy D. Miller commented on Dependency Injection: Separating the Container</title><description>ObjectFactory.GetInstance&lt;IMyView&gt;()
  
  
That's awesome code.  Truly inspired code.  I've been kicking myself for close to 3 years now about "ObjectFactory" since every framework under the sun has an "ObjectFactory" class.
  
  
  
I'm doing similar things now to register Command classes with TreeNode's like this:
  
  
            AddCommand&lt;AddSetupCommand&gt;().AppliesTo&lt;FragmentGroupNode&gt;();
  
            AddCommand&lt;AddTearDownCommand&gt;().AppliesTo&lt;FragmentGroupNode&gt;();
  
            AddCommand&lt;AddNamedFragmentCommand&gt;().AppliesTo&lt;FragmentGroupNode&gt;();
  
  
  
            AddCommand&lt;DeleteCommand&gt;()
  
                .AppliesTo&lt;SuiteNode&gt;()
  
                .AppliesTo&lt;TestNode&gt;()
  
                .AppliesTo&lt;FragmentNode&gt;();
  
  
            AddCommand&lt;BatchRunCommand&gt;()
  
                .AppliesTo&lt;SystemUnderTestNode&gt;()
  
                .AppliesTo&lt;SuiteNode&gt;();
  
  
StructureMap is under the covers to hook up everything the concrete Command classes need in their constructors, but it's hidden in this usage.
</description><link>http://ayende.com/2731/dependency-injection-separating-the-container#comment1</link><guid>http://ayende.com/2731/dependency-injection-separating-the-container#comment1</guid><pubDate>Wed, 22 Aug 2007 22:50:40 GMT</pubDate></item></channel></rss>