IoC example

Posts   
 
    
Posts: 27
Joined: 22-Feb-2012
# Posted on: 27-Mar-2012 00:15:36   

Hello,

I'm looking to use my current IoC ninject (mvc3) are there any examples to illustrate how I would go about swapping out containers for v3.5?

Thank you, Stephen

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Apr-2012 07:37:26   

Hi Stephen,

Honestly I never worked with ninject but I have seen people working with LLBLGen and similar IoC frameworks like Unity, Spring.Net, etc with with no problems.

There are no examples about this, mostly because LLBLGen works with all kind of stuff over there and we cannot make examples using LLBLGen and every new framework/technology over there.

However we would be very happy to help you. What is exactly what you are doing with mvc3 and how would you like to use ninject with LLBLGen? Also, Are you using Adapter or SelfServicing?

I will give NInject a spin to see what we can do wink

(Edit) When you say "MVC3", Are you saying that you are using Ninject.Web.Mvc extension?

David Elizondo | LLBLGen Support Team
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Apr-2012 08:01:30   

I was checking the NInject project. It's like other IoC frameworks, what I like the most is that it looks pretty simple to use. I downloaded some examples, install it with NuGet and all seems pretty simple.

From NInject's point of view, LLBLGen Pro Framework classes are just other interfaces/classes to bind. All LLBLGen Frameswok classes are friendly with those IoC fameworks. The question is What would you want to inject , where and how?

You might want to inject IDataAccessAdapter in some middle layer/business layer class that is agnostic of what IDataAccessAdapter implementation you are using. That way you could, for instance, have multiple DBSpecific projects, each one targeting different database types, and let NInject binding to decide which to use.

You also could create a custom Controller that receives a IEntity(2) in the constructor and perform some actions (Add, Edit, View, List, etc), and let NInject binding to decide what to use and where. This might sound great if you are using some kind of generic gui CRUD, but it will have limitations while you try to specialize the way some entities should be treated.

I tried some of these scenarios and those are working great with LLBLGen. However the way you set the NInject binding rules and what you really want to achieve is key to advance. Based on that, you can make your own tests and examples and we can help you, of course, if have further questions. I will close this thread for now, but feel free to re-open it if you want to elaborate more. Hope helpful wink

David Elizondo | LLBLGen Support Team