本文整理汇总了C#中WindsorContainer.GetHandlersFor方法的典型用法代码示例。如果您正苦于以下问题:C# WindsorContainer.GetHandlersFor方法的具体用法?C# WindsorContainer.GetHandlersFor怎么用?C# WindsorContainer.GetHandlersFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindsorContainer
的用法示例。
在下文中一共展示了WindsorContainer.GetHandlersFor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install_RegisterAllControllersAsTransient
public void Install_RegisterAllControllersAsTransient()
{
IWindsorContainer containerWithControllers = new WindsorContainer().Install(new ControllersInstaller());
var nonTransientControllers = containerWithControllers.GetHandlersFor(typeof(IController))
.Where(controller => controller.ComponentModel.LifestyleType != LifestyleType.Transient)
.ToArray();
Assert.AreEqual(0, nonTransientControllers.Length);
}
示例2: Install_OnlyRegisterComponentsOfTypeOfIControllers
public void Install_OnlyRegisterComponentsOfTypeOfIControllers()
{
IWindsorContainer containerWithControllers = new WindsorContainer().Install(new ControllersInstaller());
var allHandlers = containerWithControllers.GetAllHandlers();
Assert.AreNotEqual(0, allHandlers.Length);
var controllerHandlers = containerWithControllers.GetHandlersFor(typeof(IController));
CollectionAssert.AreEquivalent(allHandlers, controllerHandlers);
}
示例3: Install_AllControllersExposeThemselvesAsService
public void Install_AllControllersExposeThemselvesAsService()
{
IWindsorContainer containerWithControllers = new WindsorContainer().Install(new ControllersInstaller());
var controllersWithWrongName = containerWithControllers.GetHandlersFor(typeof(IController))
.Where(controller => controller.Service != controller.ComponentModel.Implementation)
.ToArray();
Assert.AreEqual(0, controllersWithWrongName.Length);
}
示例4: WindsorContainer
public void GivenRegistrationsInstalled_AndRequestingComponentIsServiceOfferingController_WhenResolve_ThenReturnServiceOfferingFileProcessor()
{
Container = new WindsorContainer();
Container.Kernel.ComponentModelBuilder.AddContributor(new TransientEqualizer());
Container.Install(Target);
Container.Register(Component.For<IBlobClient>().Instance(MockRepository.GenerateMock<IBlobClient>()));
Container.Register(Component.For<IRepositoryContainer>().Instance(MockRepository.GenerateMock<IRepositoryContainer>()));
Container.Register(Component.For<IPermissionFactory>().Instance(MockRepository.GenerateMock<IPermissionFactory>()));
var handler = Container.GetHandlersFor(typeof(IFileProcessor)).Single();
var context = new CreationContext(handler, new LifecycledComponentsReleasePolicy(Container.Kernel), typeof(IFileProcessor), null, null, null);
handler.ComponentModel.Name = typeof(ServiceOfferingController).FullName;
var actual = handler.Resolve(context);
Assert.IsInstanceOfType(actual, typeof(ServiceOfferingFileProcessor));
}
示例5: Install_RegisterComponentsWithTheSameNameThatItsTypes
public void Install_RegisterComponentsWithTheSameNameThatItsTypes()
{
IWindsorContainer containerWithControllers = new WindsorContainer().Install(new ControllersInstaller());
var controllersWithWrongName = containerWithControllers.GetHandlersFor(typeof(IController))
.Where(controller => controller.ComponentModel.Name != controller.ComponentModel.Implementation.Name)
.ToArray();
Assert.AreEqual(0, controllersWithWrongName.Length);
}
示例6: GivenRegistrationsInstalled_AndRequestingComponentIsUnknown_WhenResolve_ThenReturnNullYieldsException
public void GivenRegistrationsInstalled_AndRequestingComponentIsUnknown_WhenResolve_ThenReturnNullYieldsException()
{
Container = new WindsorContainer();
Container.Kernel.ComponentModelBuilder.AddContributor(new TransientEqualizer());
Container.Install(Target);
Container.Register(Component.For<IBlobClient>().Instance(MockRepository.GenerateMock<IBlobClient>()));
Container.Register(Component.For<IRepositoryContainer>().Instance(MockRepository.GenerateMock<IRepositoryContainer>()));
Container.Register(Component.For<IPermissionFactory>().Instance(MockRepository.GenerateMock<IPermissionFactory>()));
var handler = Container.GetHandlersFor(typeof(IFileProcessor)).Single();
var context = new CreationContext(handler, new LifecycledComponentsReleasePolicy(Container.Kernel), typeof(IFileProcessor), null, null, null);
Target.ExpectException<ComponentActivatorException>(() => handler.Resolve(context));
}