Step 2: Basic solution structure of an ASP.NET MVC in Visual Studio with Ninject

by sunil ravulapalli /15. June 2013 00:16 /software-design /Comments (0)

Add Ninject using Nuget to the Data and Service projects.

Add Ninject.Mvc3 using Nuget to the Web project.

In Data project add a class called DataNinjectModule which looks like this

using System;
using Ninject.Modules;
namespace Wishlist.Data.DependencyConfiguration
{    
    public class DataNinjectModule : NinjectModule    
    {        
       public override void Load()        
       {            
           throw new NotImplementedException();
        }
    }
}

In Service project add a class ServiceNinjectModule which looks like this

using System;
using Ninject.Modules;
namespace Wishlist.Service
{    
     public class ServiceNinjectModule : NinjectModule    
     {        
          public override void Load()        
          {            
                  throw new NotImplementedException();
          }    
     }
}

In Web project add these lines of code to the RegisterServices class in the NinjectWebCommon class found in the App_Start folder.(Substitute "Wishlist" with your project name)

kernel.Load("Wishlist.Data.dll");
kernel.Load("Wishlist.Service.dll");

You can find the solution on GitHub.

https://github.com/sunilrav/Wishlist.2.BasicSolutionWithNinject

blog comments powered by Disqus