Los Techies : Blogs about software and anything tech!

ASP.Net MVC Portable Area – Part 4 IoC framework support.


Using an Inversion of Control Container is a common scenario that would be needed by a Message Handler.  The Bus has an extensibility point to create the handlers. The model for this should feel similar to the ControllerFactory extension point in the ASP.Net MVC framework.  The sample below shows how to create a Message Handler factory for the StructureMap framework. 

 

image

 

The SetMessageHandlerFactory method should be called once at application startup.   Other than that … this is a pretty simple way to add a Dependency Injection Framework support to the Portable Area infrastructure.

 

This makes it pretty simple for your message handlers to use constructor injection to manage their dependencies.

Kick It on DotNetKicks.com
Posted Nov 04 2009, 12:00 AM by erichexter

Comments

ASP.Net MVC Portable Areas via MvcContrib - Eric Hexter - Los Techies : Blogs about software and anything tech! wrote ASP.Net MVC Portable Areas via MvcContrib - Eric Hexter - Los Techies : Blogs about software and anything tech!
on 11-08-2009 3:19 PM

Pingback from  ASP.Net MVC Portable Areas via MvcContrib - Eric Hexter - Los Techies : Blogs about software and anything tech!

ASP.Net MVC Portable Areas ??? Part 2 - Eric Hexter - Los Techies : Blogs about software and anything tech! wrote ASP.Net MVC Portable Areas ??? Part 2 - Eric Hexter - Los Techies : Blogs about software and anything tech!
on 11-08-2009 3:20 PM

Pingback from  ASP.Net MVC Portable Areas ??? Part 2 - Eric Hexter - Los Techies : Blogs about software and anything tech!

ASP.Net MVC Portable Areas ??? Part 3 - Eric Hexter - Los Techies : Blogs about software and anything tech! wrote ASP.Net MVC Portable Areas ??? Part 3 - Eric Hexter - Los Techies : Blogs about software and anything tech!
on 11-08-2009 3:25 PM

Pingback from  ASP.Net MVC Portable Areas ??? Part 3 - Eric Hexter - Los Techies : Blogs about software and anything tech!

Reflective Perspective - Chris Alcock » The Morning Brew #472 wrote Reflective Perspective - Chris Alcock » The Morning Brew #472
on 11-09-2009 3:46 AM

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #472

ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric … Scripts Rss wrote ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric … Scripts Rss
on 11-09-2009 4:32 AM

Pingback from  ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric … Scripts Rss

ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric … wrote ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric …
on 11-09-2009 6:38 AM

Pingback from  ASP.Net MVC Portable Area ??? Part 4 IoC framework support. - Eric …

bogardj wrote re: ASP.Net MVC Portable Area – Part 4 IoC framework support.
on 11-09-2009 8:51 AM

I wonder if there's a way to do away with all the Factory classes by just standardizing on CSL....

erichexter wrote re: ASP.Net MVC Portable Area – Part 4 IoC framework support.
on 11-09-2009 9:53 AM

@jbogard,  That is certainly an option.. We have talked for some time about putting CSL into mvccontrib and adding a CSL ControllerFactory.. this would be the same thing.. where the default CSL does the Activator .CreateInstance... On the other hand we have followed the conventions that are already baked into the MVC framework. So having mvccontrib be consistent with the MVC framework has value as well.

progg.ru wrote ASP.Net MVC Portable Area – часть 4, поддержка IoC
on 11-09-2009 12:21 PM

Thank you for submitting this cool story - Trackback from progg.ru

ASP.NET MVC Archived Blog Posts, Page 1 wrote ASP.NET MVC Archived Blog Posts, Page 1
on 11-09-2009 11:54 PM

Pingback from  ASP.NET MVC Archived Blog Posts, Page 1

Joshua Arnold wrote re: ASP.Net MVC Portable Area – Part 4 IoC framework support.
on 11-24-2009 4:29 PM

Eric, this is a huge step in reusability for MVC. Kudos to the ASP.NET MVC team for including Areas and great contributions by you and Headspring!

I have a handful of MVC applications that require a "widget" like infrastructure. Rather than reinventing the wheel, I'm working on some modifications to this to do so. Would love to talk with you about some of our ideas.

Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems