当前位置: 首页>>代码示例>>C#>>正文


C# Ninject.StandardKernel类代码示例

本文整理汇总了C#中Ninject.StandardKernel的典型用法代码示例。如果您正苦于以下问题:C# StandardKernel类的具体用法?C# StandardKernel怎么用?C# StandardKernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StandardKernel类属于Ninject命名空间,在下文中一共展示了StandardKernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_not_throw_exception_when_loading_multiple_inline_modules

        public void Should_not_throw_exception_when_loading_multiple_inline_modules()
        {
            IKernel kernel = new StandardKernel();

            kernel.Bind<IService>().To<ServiceImpl>();
            kernel.Bind<IService2>().To<Service2Impl>();
        }
开发者ID:siimv,项目名称:Arc,代码行数:7,代码来源:NinjectTests.cs

示例2: Index

        //
        // GET: /Management/
        public ActionResult Index()
        {
            IKernel kernel = new StandardKernel(new DataModelCreator());
            var users = kernel.Get<IRepository<User>>().GetAll().Where(u => u.Id != WebSecurity.CurrentUserId);

            return View(users);
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:9,代码来源:ManagementController.cs

示例3: ConnectInfoForm

        public ConnectInfoForm()
        {
            XmlConfigurator.Configure();

            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };

            this.mKernel = new StandardKernel(
                settings,
                new Log4NetModule(),
                new ReportServerRepositoryModule());

            //this.mKernel.Load<FuncModule>();

            this.mLoggerFactory = this.mKernel.Get<ILoggerFactory>();
            this.mFileSystem = this.mKernel.Get<IFileSystem>();
            this.mLogger = this.mLoggerFactory.GetCurrentClassLogger();

            InitializeComponent();

            this.LoadSettings();

            // Create the DebugForm and hide it if debug is False
            this.mDebugForm = new DebugForm();
            this.mDebugForm.Show();
            if (!this.mDebug)
                this.mDebugForm.Hide();
        }
开发者ID:jpann,项目名称:SSRSMigrate,代码行数:30,代码来源:ConnectInfoForm.cs

示例4: Main

		public static void Main (string[] args)
		{
		    var kernel = new StandardKernel();
		    Container = new Container(kernel);

		    Configure.With(Container)
                .UsingJsonStorage("JsonDB")
                .Initialize();

		    var commandCoordinator = ServiceLocator.Current.GetInstance<ICommandCoordinator>();

			var command = new CreatePerson(Guid.NewGuid(), "First", "Person");
			var result = commandCoordinator.Handle(command);
			if (!result.Success)
			{
				Console.WriteLine("Handling of command failed");
				Console.WriteLine("Exception : {0}\nStack Trace : {1}", result.Exception.Message, result.Exception.StackTrace);
			}

			var queries = Container.Get<IPersonView>();
			var persons = queries.GetAll();
			foreach (var person in persons)
			{
				Console.WriteLine("Person ({0}) - {1} {2}", person.Id, person.FirstName, person.LastName);
			}
		}
开发者ID:TormodHystad,项目名称:Bifrost,代码行数:26,代码来源:Main.cs

示例5: ShouldBeAbleToGetBusinessServiceFromNinject

 public void ShouldBeAbleToGetBusinessServiceFromNinject()
 {
     BusinessService actual;
     var kernel = new StandardKernel(new CoreModule());
     actual = kernel.Get<BusinessService>();
     Assert.IsNotNull(actual);
 }
开发者ID:mcknz,项目名称:moq-examples,代码行数:7,代码来源:NinjectTests.cs

示例6: GetRestClient

        private static IRestClient GetRestClient()
        {
            IKernel kernel = new StandardKernel();
            kernel.Load(Assembly.GetExecutingAssembly());

            return kernel.Get<IRestClient>();
        }
开发者ID:KennyBu,项目名称:RestApiDemo,代码行数:7,代码来源:Program.cs

示例7: RegisterDependencyResolver

        private static void RegisterDependencyResolver()
        {
            var kernel = new StandardKernel();
            kernel.Bind<ICalendarService>().To<CalendarService>();

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
开发者ID:detroitpro,项目名称:RemindMe,代码行数:7,代码来源:Global.asax.cs

示例8: Initialize

        private void Initialize()
        {
            if (_kernel != null) return;
            _kernel = new StandardKernel();
            _kernel.Bind<Func<Type, NotifyableEntity>>().ToMethod(context => t => context.Kernel.Get(t) as NotifyableEntity);
            _kernel.Bind<PhoneApplicationFrame>().ToConstant(new PhoneApplicationFrame());
            _kernel.Bind<INavigationService>().To<NavigationService>().InSingletonScope();
            _kernel.Bind<IStorage>().To<IsolatedStorage>().InSingletonScope();
            _kernel.Bind<ISerializer<byte[]>>().To<BinarySerializer>().InSingletonScope();
            _kernel.Bind<IDataContext>().To<DataContext>().InSingletonScope();
            _kernel.Bind<IGoogleMapsClient>().To<GoogleMapsClientMock>().InSingletonScope();
            _kernel.Bind<IConfigurationContext>().To<ConfigurationContext>().InSingletonScope();

            ApplicationContext.Initialize(_kernel);
            var place1 = ApplicationContext.Data.AddNewPlace(new Location
            {
                Latitude = 9.1540930,
                Longitude = -1.39166990
            });
            var place2 = ApplicationContext.Data.AddNewPlace(new Location
            {
                Latitude = 9.1540930,
                Longitude = -1.39166990
            });
            ApplicationContext.Data.GetRoute(null, null, default(TravelMode), default(RouteMethod), r =>
            {
                r.Result.ArrivalPlaceId = place1.Id;
                r.Result.DeparturePlaceId = place2.Id;
            });
            ApplicationContext.Data.ToolbarAlignment.Value = HorizontalAlignment.Left;
        }
开发者ID:soleon,项目名称:Travlexer,代码行数:31,代码来源:DesignTime.cs

示例9: CreateKernel

 /// <summary>
 /// Creates the kernel that will manage your application.
 /// </summary>
 /// <returns>The created kernel.</returns>
 protected override IKernel CreateKernel()
 {
     var kernel = new StandardKernel();
     kernel.Bind<IHomeControllerModel>().To<HomeControllerModel>();
     kernel.Bind<ILog>().ToMethod(ctx => LogManager.GetLogger("xxx"));
     return kernel;
 }
开发者ID:nectide,项目名称:ninject.web.mvc,代码行数:11,代码来源:Global.asax.cs

示例10: CreateKernel

        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var documentStore = new EmbeddableDocumentStore
                {
                    UseEmbeddedHttpServer = true,
                    DataDirectory = "App_Data",
                    Configuration =
                        {
                            Port = 12345,
                        },
                    Conventions =
                        {
                            CustomizeJsonSerializer = MvcApplication.SetupSerializer
                        }
                };
            documentStore.Initialize();
            var manager = new SubscriptionManager(documentStore);

            var kernel = new StandardKernel();
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
            kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
            kernel.Bind<IDocumentStore>()
                  .ToMethod(context => documentStore)
                  .InSingletonScope();
            RegisterServices(kernel);
            kernel.Bind<SubscriptionManager>().ToMethod(context => manager).InSingletonScope();
            return kernel;
        }
开发者ID:AndrewSwerlick,项目名称:DocumentEditor,代码行数:32,代码来源:NinjectWebCommon.cs

示例11: Init

 public void Init()
 {
     var container = new StandardKernel();
     container.Bind<ISessionRepository>().ToConstant(MoqSessionRepositoryFactory.GetSessionRepositoryMock());
     _sessionRepository = container.Get<ISessionRepository>();
     _sessionRepository.Clear();
 }
开发者ID:xximjasonxx,项目名称:Codemash,代码行数:7,代码来源:UnloadedSessionRepositoryTests.cs

示例12: BindingExtensionsTest

 public BindingExtensionsTest()
 {
     this.eventAggregator = new Mock<IEventAggregator>();
     
     this.kernel = new StandardKernel(new NinjectSettings { LoadExtensions = false });
     this.kernel.Bind<IEventAggregator>().ToConstant(this.eventAggregator.Object);
 }
开发者ID:xyicheng,项目名称:StockTicker,代码行数:7,代码来源:BindingExtensionsTest.cs

示例13: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Setup Ninject Kernel and wire up services using convention based binding in Ninject 3.0
            var kernel = new StandardKernel();
            kernel.Bind(x => x
                .FromAssembliesMatching("*")
                .SelectAllClasses()
                .BindDefaultInterface());
            //Or bind each class using the following syntax:
            //kernel.Bind<IStupidLittleService>().To<StupidLittleService>().InRequestScope();

            //Setup DR for MVC Controllers
            NinjectDependencyResolver resolver = new NinjectDependencyResolver(kernel);
            DependencyResolver.SetResolver(resolver);

            //Setup DR for Web API Controllers
            NinjectWebApiDependencyResolver webApiDependencyResolver = new NinjectWebApiDependencyResolver(kernel);
            GlobalConfiguration.Configuration.DependencyResolver = webApiDependencyResolver;
        }
开发者ID:elylucas,项目名称:MvcBootStrap,代码行数:25,代码来源:Global.asax.cs

示例14: Main

        private static void Main()
        {
            XmlConfigurator.Configure(new FileInfo("patientOrderService.log4net.xml"));

            HostFactory.Run(
                c =>
                    {
                        c.SetServiceName("SampleSOAPatientOrderService");
                        c.SetDisplayName("Sample SOA Patient Order Service");
                        c.SetDescription("A sample SOA service for handling Patient Orders.");

                        c.RunAsNetworkService();

                        StandardKernel kernel = new StandardKernel();
                        PatientOrderServiceRegistry module = new PatientOrderServiceRegistry();
                        kernel.Load(module);

                        c.Service<PatientOrderService>(
                            s =>
                                {
                                    s.ConstructUsing(builder => kernel.Get<PatientOrderService>());
                                    s.WhenStarted(o => o.Start());
                                    s.WhenStopped(o => o.Stop());
                                });
                    });
        }
开发者ID:Bolt54,项目名称:Slides,代码行数:26,代码来源:Program.cs

示例15: CreateKernel

 private static StandardKernel CreateKernel()
 {
     var kernel = new StandardKernel();
     kernel.Load(Assembly.GetExecutingAssembly());
     RegisterMappings(kernel);
     return kernel;
 }
开发者ID:resnick1223,项目名称:Web-Services-and-Cloud,代码行数:7,代码来源:Startup.cs


注:本文中的Ninject.StandardKernel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。