本文整理汇总了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));
}
示例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));
}
示例3: AssemblyScanningByFileName
public void AssemblyScanningByFileName()
{
var kernel = new StandardKernel();
kernel.Load("NinjectExamples.dll");
Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
}
示例4: AssemblyScanningByAssembly
public void AssemblyScanningByAssembly()
{
var kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());
Assert.That(kernel.GetBindings(typeof(IVegetable)).Count(), Is.EqualTo(1));
}
示例5: SingleBinding
public void SingleBinding()
{
var kernel = new StandardKernel();
kernel.Bind<IVegetable>().To<Carrot>();
kernel.GetBindings(typeof (IVegetable)).Count().Equals(1);
}
示例6: ModuleBinding
public void ModuleBinding()
{
var kernel = new StandardKernel();
kernel.Load(new VeggieModule());
kernel.GetBindings(typeof(IVegetable)).Count().Equals(1);
}
示例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>());
}
示例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>());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}