src/GiveCRM.Web/App_Start/NinjectMVC3.cs
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
Load your modules or register your services here!
Load your modules or register your services here!
private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<ILogService>().To<LogService>();
            kernel.Bind<ITenantCodeProvider>().To<DomainNameTenantCodeProvider>();
            kernel.Bind<LogService>().ToSelf().InSingletonScope();
            kernel.Bind<HttpRequest>().ToMethod(_ => HttpContext.Current.Request).InRequestScope();
            kernel.Bind<IHttpRequest>().To<ThinHttpRequest>().InRequestScope();
            string databaseProviderTypeName = ConfigurationManager.AppSettings.Get("DatabaseProviderType");
            if (string.IsNullOrWhiteSpace(databaseProviderTypeName))
            {
                kernel.Bind<IDatabaseProvider>().To<SingleTenantDatabaseProvider>().InSingletonScope();
            }
            else
            {
                Type databaseProviderType = Type.GetType(databaseProviderTypeName);
                kernel.Bind<IDatabaseProvider>().To(databaseProviderType).InSingletonScope();
            }
            kernel.Scan(a =>
                            {
                                a.FromCallingAssembly();
                                a.FromAssembliesMatching("GiveCRM.*.dll");
                                a.Excluding(typeof(LogService));
                                a.Excluding<IDatabaseProvider>();
                                a.BindWithDefaultConventions();
                                a.BindWith(new RegexBindingGenerator("(I)(?<name>.+)(Repository)"));
                                a.BindWith(new GenericBindingGenerator(typeof(IRepository<>)));
                                a.InRequestScope();
                            });
        }
private static void RegisterServices ( IKernel kernel ) { kernel . Bind < ILogService > ( ) . To < LogService > ( ) ; kernel . Bind < ITenantCodeProvider > ( ) . To < DomainNameTenantCodeProvider > ( ) ; kernel . Bind < LogService > ( ) . ToSelf ( ) . InSingletonScope ( ) ; kernel . Bind < HttpRequest > ( ) . ToMethod ( _ => HttpContext . Current . Request ) . InRequestScope ( ) ; kernel . Bind < IHttpRequest > ( ) . To < ThinHttpRequest > ( ) . InRequestScope ( ) ; string databaseProviderTypeName = ConfigurationManager . AppSettings . Get ( " " ) ; if ( string . IsNullOrWhiteSpace ( databaseProviderTypeName ) ) { kernel . Bind < IDatabaseProvider > ( ) . To < SingleTenantDatabaseProvider > ( ) . InSingletonScope ( ) ; } else { Type databaseProviderType = Type . GetType ( databaseProviderTypeName ) ; kernel . Bind < IDatabaseProvider > ( ) . To ( databaseProviderType ) . InSingletonScope ( ) ; } kernel . Scan ( a => { a . FromCallingAssembly ( ) ; a . FromAssembliesMatching ( " " ) ; a . Excluding ( typeof ( LogService ) ) ; a . Excluding < IDatabaseProvider > ( ) ; a . BindWithDefaultConventions ( ) ; a . BindWith ( new RegexBindingGenerator ( " " ) ) ; a . BindWith ( new GenericBindingGenerator ( typeof ( IRepository < > ) ) ) ; a . InRequestScope ( ) ; } ) ; }
Load your modules or register your services here!
Load your modules or register your services here!
kernel
IKernel
None