本文整理汇总了C#中Autofac.ContainerBuilder.EnableCodeSwitchTracking方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.EnableCodeSwitchTracking方法的具体用法?C# ContainerBuilder.EnableCodeSwitchTracking怎么用?C# ContainerBuilder.EnableCodeSwitchTracking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autofac.ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder.EnableCodeSwitchTracking方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_be_able_to_toggle_a_switch
public void Should_be_able_to_toggle_a_switch()
{
var builder = new ContainerBuilder();
builder.RegisterCodeSwitchToggle<UseNewMethod>();
builder.EnableCodeSwitchTracking();
var container = builder.Build();
using (var scope = container.BeginLifetimeScope())
{
Assert.IsFalse(scope.Resolve<ICodeSwitch<UseNewMethod>>().Enabled);
Assert.AreEqual(1, scope.GetEvaluatedCodeSwitches().Count());
}
container.Resolve<IToggleCodeSwitch<UseNewMethod>>().Enable();
using (var scope = container.BeginLifetimeScope())
{
Assert.IsTrue(scope.Resolve<ICodeSwitch<UseNewMethod>>().Enabled);
Assert.AreEqual(1, scope.GetEvaluatedCodeSwitches().Count());
}
}
示例2: Setup
public void Setup()
{
var builder = new ContainerBuilder();
builder.RegisterCodeSwitchToggle<UseNewCodePath>();
builder.RegisterCodeSwitchToggle<UseNewClass>();
builder.EnableCodeSwitchTracking();
builder.RegisterType<Logger>()
.As<ILogger>();
builder.RegisterSwitchedType<UseNewClass, IClass, TestClassV2, TestClass>();
builder.RegisterType<TestClass>();
_container = builder.Build();
}
示例3: Setup
public void Setup()
{
var builder = new ContainerBuilder();
builder.RegisterModule<ConfigurationCodeFeatureCacheModule>();
builder.RegisterModule<ConfigurationContextFeatureCacheModule<UserContext, UserContextKeyProvider>>();
builder.RegisterCodeSwitch<DbEnabled>();
builder.RegisterContextCodeSwitch<UseNewCodePath, UserContext>(true);
builder.EnableCodeSwitchTracking();
builder.RegisterType<Repository>();
_container = builder.Build();
}