I'm new to Umbraco and have decided to learn it by "doing".
Ninject is my tool of choice, so my first move was to set it up as the main container solution for my project. I could use 2 containers at the same time (Autofac+Ninject) however this just doesn't seem right to me.
I'd very much apreciate assistance with replacing Autofac with Ninject, sadly I know very little of Autofac so some of the intricacies - elude me.
You can create a new class that inherits from MvcApplication and then change your global.asax file to point to this new class. So your new class will look something like this:
public class YourUmbracoWebApplication : MvcApplication {
Right, that's simple enough. However I still need to initialize the container properly, so that Umbraco can use Ninjecvt instead of Autofac - how do I go about that?
I have never used Ninject so I cannot really provide code samples for it.
Using Castle you'd initialize your container and register your types (I am assuming Ninject is not too dissimilar). So the Application_Start (using a very crude example) would look like this:
I have just re-read your first post and you are actually looking to completely replace AutoFaq with Ninject not just control your own custom objects with a different IoC container, sorry I should have read it more carefully.
Having a look at the Umbraco 5 source it appears that the DI has been abstracted and there is a IContainerBuilder interface in Umbraco.Framework.DependencyManagement that is implemented in a seperate AutoFac library (Umbraco.Framework.DependencyManagement.Autofac).
I'd probably start with the source from this library and adapt it to use Ninject (sorry that's a really obvious statement!).
Umbraco 5.1 : Replacing Autofac with Ninject?
Hi there,
I'm new to Umbraco and have decided to learn it by "doing".
Ninject is my tool of choice, so my first move was to set it up as the main container solution for my project. I could use 2 containers at the same time (Autofac+Ninject) however this just doesn't seem right to me.
I'd very much apreciate assistance with replacing Autofac with Ninject, sadly I know very little of Autofac so some of the intricacies - elude me.
Cheers.
I have done a similar thing with Castle.
You can create a new class that inherits from MvcApplication and then change your global.asax file to point to this new class. So your new class will look something like this:
And your Global.asax will look like this:
Hope this helps :)
Right, that's simple enough. However I still need to initialize the container properly, so that Umbraco can use Ninjecvt instead of Autofac - how do I go about that?
I have never used Ninject so I cannot really provide code samples for it.
Using Castle you'd initialize your container and register your types (I am assuming Ninject is not too dissimilar). So the Application_Start (using a very crude example) would look like this:
That's absolutely correct.
Is there a list of types that needs to be registered for Umbraco to run?
Is there some kind of a adapter to the container ? For instance Umbraco might wish to resolve a named instance of a given type etc.
I have just re-read your first post and you are actually looking to completely replace AutoFaq with Ninject not just control your own custom objects with a different IoC container, sorry I should have read it more carefully.
Having a look at the Umbraco 5 source it appears that the DI has been abstracted and there is a IContainerBuilder interface in Umbraco.Framework.DependencyManagement that is implemented in a seperate AutoFac library (Umbraco.Framework.DependencyManagement.Autofac).
I'd probably start with the source from this library and adapt it to use Ninject (sorry that's a really obvious statement!).
I'll have a look at it later tonight, and get back to the topic ;) Cheers for the hints.
I am curious as to how easily you'll be able to do this :)
is working on a reply...