Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All
I am following Steven Sanderson's Pro MVC2 book and have a question about using Ninject.
Following is the Code
C#
public class NinjectControllerFactory : DefaultControllerFactory

{
    //A Ninject "kernet" is the thing that can supply object instances
    private IKernel kernel = new StandardKernel(new SportsStoreServices());


    protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
    {
        return (IController)kernel.Get(controllerType);
    }

    private class SportsStoreServices : NinjectModule
    {
        public string QString = null;
        public override void Load()
        {

            Bind<IProductsRepository>().To<SqlProductsRepository>()
                .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString);


        }
    }

}


Where I am trying to make

C#
private class SportsStoreServices : NinjectModule
{

}

But it is showing error that I can't make Private, Public Class explecitely
So what should I do Please Advise

Thanks to All
Posted
Updated 27-Oct-13 20:18pm
v2

1 solution

Set aside syntax and understanding of compilation error message. Use just simple logic. Can you understand that, unlike a private type member, a private top-level class is total absurd?

If some member of a type is private, it is private in the context of this type. It means that it cannot be accessed from anywhere except the code if the declaring class. And what would be a context of a private top-level class? It would mean that the class is not accessible from anywhere.

The question "what should I do" also makes little to no sense. It depends on what you want achieve. You should do whatever you want, but not violating anything, especially common sense.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900