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


C# StandardKernel.GetBindings方法代码示例

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


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

示例1: ModuleBinding

        public void ModuleBinding()
        {
            var kernel = new StandardKernel();
            kernel.Load(new VeggieModule());

            Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
        }
开发者ID:abalkany,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例2: CanRemoveBinding

 public void CanRemoveBinding()
 {
     var kernel = new StandardKernel();
     kernel.Bind<IVegetable>().To<Carrot>();
     kernel.Unbind<IVegetable>();
     Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(0));
 }
开发者ID:abalkany,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例3: AssemblyScanningByFileName

        public void AssemblyScanningByFileName()
        {
            var kernel = new StandardKernel();
            kernel.Load("NinjectExamples.dll");

            Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
        }
开发者ID:abalkany,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例4: AssemblyScanningByAssembly

        public void AssemblyScanningByAssembly()
        {
            var kernel = new StandardKernel();
            kernel.Load(Assembly.GetExecutingAssembly());

            Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
        }
开发者ID:abalkany,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例5: SingleBinding

        public void SingleBinding()
        {
            var kernel = new StandardKernel();
            kernel.Bind<IVegetable>().To<Carrot>();

            kernel.GetBindings(typeof (IVegetable)).Count().Equals(1);
        }
开发者ID:DavidBasarab,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例6: ModuleBinding

        public void ModuleBinding()
        {
            var kernel = new StandardKernel();
            kernel.Load(new VeggieModule());

            kernel.GetBindings(typeof(IVegetable)).Count().Equals(1);
        }
开发者ID:DavidBasarab,项目名称:Ninject-Examples,代码行数:7,代码来源:Chapter_01_Kernel_Registration.cs

示例7: ExportsBothInstancesAndTypes

            public void ExportsBothInstancesAndTypes()
            {
                var serviceLocator = new ServiceLocator();
                serviceLocator.AutomaticallyKeepContainersSynchronized = false;

                var ninjectContainer = new StandardKernel();

                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.RegisterInstance<ITestInterface>(new TestClass1());
                serviceLocator.RegisterType<INotifyPropertyChanged, TestClass1>();

                serviceLocator.RegisterExternalContainer(ninjectContainer);

                Assert.IsFalse(ninjectContainer.GetBindings(typeof(INotifyPropertyChanged)).Any());
                Assert.IsFalse(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
                Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());

                serviceLocator.ExportToExternalContainers();

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(INotifyPropertyChanged)).Any());
                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
                Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());
            }
开发者ID:pars87,项目名称:Catel,代码行数:23,代码来源:ServiceLocatorFacts.cs

示例8: ExportInstancesToExternalContainers_ExternalContainerHasNoInstanceRegistered

            public void ExportInstancesToExternalContainers_ExternalContainerHasNoInstanceRegistered()
            {
                var serviceLocator = new ServiceLocator();
                serviceLocator.AutomaticallyKeepContainersSynchronized = false;

                var ninjectContainer = new StandardKernel();

                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.RegisterInstance<ITestInterface>(new TestClass1());

                serviceLocator.RegisterExternalContainer(ninjectContainer);

                Assert.IsFalse(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
                Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());

                serviceLocator.ExportInstancesToExternalContainers();

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
                Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());
            }
开发者ID:pars87,项目名称:Catel,代码行数:20,代码来源:ServiceLocatorFacts.cs

示例9: AutomaticSynchronization_ResolveType

            public void AutomaticSynchronization_ResolveType()
            {
                var serviceLocator = new ServiceLocator();
                serviceLocator.AutomaticallyKeepContainersSynchronized = false;
                serviceLocator.RegisterType<ITestInterface, TestClass1>();
                var ninjectContainer = new StandardKernel();
                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.AutomaticallyKeepContainersSynchronized = true;
                serviceLocator.ResolveType<ITestInterface>();

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
            }
开发者ID:pars87,项目名称:Catel,代码行数:12,代码来源:ServiceLocatorFacts.cs

示例10: AutomaticSynchronization_RegisterIfTypeNotYetRegistered

            public void AutomaticSynchronization_RegisterIfTypeNotYetRegistered()
            {
                var serviceLocator = new ServiceLocator();
                var ninjectContainer = new StandardKernel();
                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.RegisterTypeIfNotYetRegistered<ITestInterface, TestClass1>();

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
            }
开发者ID:pars87,项目名称:Catel,代码行数:9,代码来源:ServiceLocatorFacts.cs

示例11: AutomaticSynchronization_RegisterInstance

            public void AutomaticSynchronization_RegisterInstance()
            {
                var serviceLocator = new ServiceLocator();
                var ninjectContainer = new StandardKernel();
                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.RegisterInstance<ITestInterface>(new TestClass1());

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
            }
开发者ID:pars87,项目名称:Catel,代码行数:9,代码来源:ServiceLocatorFacts.cs

示例12: RebindClearsAllBindingsForAType

        public void RebindClearsAllBindingsForAType()
        {
            var kernel = new StandardKernel();
            kernel.Bind<IVegetable>().To<Carrot>();
            kernel.Bind<IVegetable>().To<GreenBean>();

            Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(2));

            kernel.Rebind<IVegetable>().To<Peas>();

            Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
        }
开发者ID:abalkany,项目名称:Ninject-Examples,代码行数:12,代码来源:Chapter_01_Kernel_Registration.cs


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