1

I have this in my MVC2 app but I think I might move to Ninject as its becoming more popular and Castle Windsor seems a tad over complicated.

How would I do something like this in Ninject however?

Maybe Castle Windsor is more developed and I should stick with it.

container.Register(AllTypes.FromThisAssembly()
               .Where(type => type.Name.EndsWith("Repository"))
               .WithService.DefaultInterface()
               .Configure(c => c.LifeStyle.PerWebRequest));                   
Jon
  • 38,814
  • 81
  • 233
  • 382
  • 6
    The Castle team is always looking for feedback to improve Windsor. Can you elaborate on what concretely did you find complicated about Windsor? – Mauricio Scheffer Jan 20 '11 at 18:10

2 Answers2

0

You need to import the namespace Ninject.Extensions.Conventions from https://github.com/ninject/ninject.extensions.conventions Then:

Kernel.Bind(x => x
            .FromThisAssembly()
            .SelectAllClasses().EndingWith("Repository")
            .BindDefaultInterface());
regisbsb
  • 3,664
  • 2
  • 35
  • 41