コード例 #1
0
        private static IKernel CreateNinjectKernel()
        {
            var kernel = new StandardKernel();

            kernel.Load(Assembly.GetExecutingAssembly());
            kernel.BindSharpRepository();
            return(kernel);
        }
コード例 #2
0
        private static StandardKernel CreateKernel()
        {
            var kernel = new StandardKernel();

            kernel.BindSharpRepository();

            RepositoryDependencyResolver.SetDependencyResolver(new NinjectDependencyResolver(kernel));

            var connectionString = ConfigurationManager.ConnectionStrings["SolutionTemplate"].ConnectionString;

            kernel.Bind <DbContext>()
            .To <SolutionTemplateContext>()
            .InRequestScope()
            .WithConstructorArgument("connectionString", connectionString);

            kernel.Bind <IWidgetService>().To <WidgetService>();

            return(kernel);
        }