本文整理汇总了C#中Autofac.ContainerBuilder.RegisterCodeSwitchEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.RegisterCodeSwitchEnabled方法的具体用法?C# ContainerBuilder.RegisterCodeSwitchEnabled怎么用?C# ContainerBuilder.RegisterCodeSwitchEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autofac.ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder.RegisterCodeSwitchEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_support_delegate_registration
public void Should_support_delegate_registration()
{
var builder = new ContainerBuilder();
builder.RegisterCodeSwitchEnabled<UseClassAv2>();
builder.RegisterSwitched<UseClassAv2, A>(context => new ClassA_V2(), context => new ClassA());
IContainer container = builder.Build();
var a = container.Resolve<A>();
Assert.IsInstanceOf<ClassA_V2>(a);
}
示例2: Should_use_the_new_methods
public void Should_use_the_new_methods()
{
var builder = new ContainerBuilder();
builder.RegisterCodeSwitchEnabled<UseNewMethod>();
builder.RegisterType<ConditionalClass>();
var container = builder.Build();
var conditionalClass = container.Resolve<ConditionalClass>();
Assert.AreEqual("V2: 42, Test", conditionalClass.FunctionCall(42, "Test"));
}
示例3: Should_return_new_registration_by_type
public void Should_return_new_registration_by_type()
{
var builder = new ContainerBuilder();
builder.RegisterCodeSwitchEnabled<UseClassAv2>();
builder.RegisterSwitchedType<UseClassAv2, A, ClassA_V2, ClassA>();
IContainer container = builder.Build();
var a = container.Resolve<A>();
Assert.IsInstanceOf<ClassA_V2>(a);
}
示例4: Should_return_as_specific
public void Should_return_as_specific()
{
var builder = new ContainerBuilder();
builder.CodeSwitchesDisabledbyDefault();
builder.RegisterCodeSwitchEnabled<Active>();
IContainer container = builder.Build();
var fooId = container.Resolve<ICodeSwitch<Active>>();
Assert.IsTrue(fooId.Enabled);
}