Inheritance: ServiceLocatorImplBase
Exemple #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            GlobalConfiguration.Configuration.MessageHandlers.Add(new OAuth2Handler());

            IKernel kernel = new StandardKernel();
            // Repos
            kernel.Bind<IClientRepository>().To<InMemoryClientRepository>();
            kernel.Bind<ITokenRepository>().To<ShamTokenRepo>();

            // Services
            kernel.Bind<IClientService>().To<ClientService>();
            kernel.Bind<ITokenService>().To<TokenService>();
            kernel.Bind<IResourceOwnerService>().To<ResourceOwnerService>();
            kernel.Bind<IAuthorizationGrantService>().To<AuthorizationGrantService>();
            kernel.Bind<IServiceFactory>().To<ServiceFactory>();

            //Providers 
            kernel.Bind<IResourceProvider>().To<ResourceProvider>();

            // Resource Endpoint Processors
            //TODO: Build Mac Processor
            kernel.Bind<ContextProcessor<IResourceContext>>().To<BearerProcessor>();
            
            kernel.Bind<IAccessTokenValidator>().To<AccessTokenValidator>();
            NinjectServiceLocator adapter = new NinjectServiceLocator(kernel);

            ServiceLocator.SetLocatorProvider(() => adapter);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var kernel = new StandardKernel();
              kernel.Bind<IContextDataProvider>()
            .To<UsernameContextDataProvider>();
              var sl = new NinjectServiceLocator(kernel);
              ServiceLocator.SetLocatorProvider(() => sl);

              var namingStrategy = new NamingStrategy();
              var auditColumnSource = new CtxAuditColumnSource();
              var cfg = new Configuration().Configure();
              new TriggerAuditing(cfg, namingStrategy,
            auditColumnSource).Configure();

              var sessionFaculty = cfg.BuildSessionFactory();

              var se = new NHibernate.Tool.hbm2ddl.SchemaExport(cfg);
              se.Execute(true, true, false);

              var padlock = new Product()
              {
            Name = "Padlock",
            Description = "Secure, weather resistant",
            UnitPrice = 8.36M
              };
              Guid padlockId;

              using (var session = sessionFaculty.OpenSession())
              {
            using (var tx = session.BeginTransaction())
            {
              padlockId = (Guid)session.Save(padlock);
              tx.Commit();
            }
              }

              using (var session = sessionFaculty.OpenSession())
              {
            using (var tx = session.BeginTransaction())
            {
              padlock = session.Get<Product>(padlockId);
              padlock.UnitPrice = 0.10M;
              padlock.Description = "Not so secure, actually.";
              session.SaveOrUpdate(padlock);
              tx.Commit();
            }
              }

              using (var session = sessionFaculty.OpenSession())
              {
            using (var tx = session.BeginTransaction())
            {
              padlock = session.Load<Product>(padlockId);
              session.Delete(padlock);
              tx.Commit();
            }
              }
        }
 private void Setup()
 {
     // 这里使用我本机的Connection String。连接其它数据库服务器需要相应修改。
     const string connString =
         @"Data Source=TOMTUNG-THINK\SQLEXPRESS;Initial Catalog=HW_PAS;Integrated Security=True";
     IKernel kernel = new StandardKernel(new DefaultNinjectModule(connString));
     var serviceLocator = new NinjectServiceLocator(kernel);
     ServiceLocator.SetLocatorProvider(() => serviceLocator);
 }
Exemple #4
0
 static App()
 {
     Kernel = new StandardKernel(
         new InfrastructureModule()
         );
     var locator = new NinjectServiceLocator(Kernel);
     ServiceLocator.SetLocatorProvider(() => locator);
     Kernel.Bind<IServiceLocator>().ToConstant(locator);
 }
 private static void PrepareKernel()
 {
     Configuration webconfig =
         WebConfigurationManager.OpenWebConfiguration("/");
     ConnectionStringSettings connString =
         webconfig.ConnectionStrings.ConnectionStrings["ApplicationServices"];
     IKernel kernel = new StandardKernel(new DefaultNinjectModule(connString.ConnectionString));
     var serviceLocator = new NinjectServiceLocator(kernel);
     ServiceLocator.SetLocatorProvider(() => serviceLocator);
 }
Exemple #6
0
        protected override void OnApplicationStarted()
        {
            var serviceLocator = new NinjectServiceLocator(Kernel);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);

            RegisterAllControllersIn("Forge.Web");

            var bootstrapper = Kernel.Get<Bootstrapper>();

            bootstrapper.SetUpViewEngine();
            bootstrapper.RegisterRoutes();
        }
Exemple #7
0
        public static IKernel Start()
        {
            _container.Load(new INinjectModule[]
              {
            new WebAppServices(),
            new ApplicationServices()
              });

              var adapter = new NinjectServiceLocator(_container);
              ServiceLocator.SetLocatorProvider(() => adapter);

              return _container;
        }
Exemple #8
0
        static void Main(string[] args)
        {
            try
            {
                //move maybe?
                var kernel =new StandardKernel(new GameModule(),new StarMeleeModule());

                NinjectServiceLocator locator = new NinjectServiceLocator(kernel);
                ServiceLocator.SetLocatorProvider(() => (IServiceLocator)locator);
                //end move?

                Game = new BaseGame.BaseGame(new Director());
                Game.Run();
            }
            finally
            {
                Game.Dispose();
            }
        }
Exemple #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            IKernel kernel = new StandardKernel();
            // Repos
            kernel.Bind<IClientRepository>().To<InMemoryClientRepository>();
            kernel.Bind<ITokenRepository>().To<InMemoryTokenRepository>();

            // Services
            kernel.Bind<IClientService>().To<ClientService>();
            kernel.Bind<ITokenService>().To<TokenService>();
            kernel.Bind<IResourceOwnerService>().To<ResourceOwnerService>();
            kernel.Bind<IAuthorizationGrantService>().To<AuthorizationGrantService>();
            kernel.Bind<IServiceFactory>().To<ServiceFactory>();

            // Providers
            kernel.Bind<IAuthorizationProvider>().To<AuthorizationProvider>();
            kernel.Bind<ITokenProvider>().To<TokenProvider>();
            kernel.Bind<IResourceProvider>().To<ResourceProvider>();

            
            // Token Endpoint Processors
            kernel.Bind<ContextProcessor<ITokenContext>>().To<AuthenticationCodeProcessor>();
            kernel.Bind<ContextProcessor<ITokenContext>>().To<ResourceOwnerPasswordCredentialProcessor>();
            kernel.Bind<ContextProcessor<ITokenContext>>().To<ClientCredentialsProcessor>();
            kernel.Bind<ContextProcessor<ITokenContext>>().To<RefreshTokenProcessor>();

            // Resource Endpoint Processors
            //TODO: Build Mac Processor
            kernel.Bind<ContextProcessor<IResourceContext>>().To<BearerProcessor>();

            // Authorization Endpoint Processors
            kernel.Rebind<ContextProcessor<IAuthorizationContext>>().To<AuthorizationCodeProcessor>();
            kernel.Bind<ContextProcessor<IAuthorizationContext>>().To<ImplicitFlowProcessor>();
    
            NinjectServiceLocator adapter = new NinjectServiceLocator(kernel);

            ServiceLocator.SetLocatorProvider(() => adapter);

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
Exemple #10
0
        protected override IKernel CreateKernel()
        {
            ModelBinders.Binders.AddFor<Product>();

            var kernel = new StandardKernel(
                new ConfigurationModule(),
                new AzureConfigurationModule(),
                new InfrastructureModule(),
                new DomainModule()
            );

            var locator = new NinjectServiceLocator(kernel);
            ServiceLocator.SetLocatorProvider(()=>locator);
            kernel.Bind<IServiceLocator>().ToConstant(locator);

            ConfigureEntityContext(kernel);

            return kernel;
        }
Exemple #11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IKernel ninject = new StandardKernel();
            var locator = new NinjectServiceLocator(ninject);
            ServiceLocator.SetLocatorProvider(() => locator);

            var kernel = ServiceLocator.Current.GetInstance<IKernel>();
            kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
            kernel.Bind<IMessageBoxService>().To<FancyMessageBoxService>();
            kernel.Bind<IIViewProvider>().To<TabbedViewProvider>();
            kernel.Bind<IAsyncService>().To<AsyncService>();
            kernel.Bind<IDataService<Person>>().To<PeopleDataService>();
            kernel.Bind<IDataService<Person>>().To<PeopleDataService2>();
            kernel.Bind<IDataService<Company>>().To<CompanyDataService>();

            //Application.Run(kernel.Get<Shell>());
            Application.Run(ServiceLocator.Current.GetInstance<Shell>());
        }
 public void Configure()
 {
     var kernel = BuildKernel();
       var sl = new NinjectServiceLocator(kernel);
       ServiceLocator.SetLocatorProvider(() => sl);
 }