在 Windsor 2.1 中,当代码在 wcf 上下文中执行时,我有以下代码将所有服务的生活方式更改为 PerWcfOperation:
container.Kernel.ComponentModelBuilder.AddContributor(
new CustomLifestyleLevelingContributeComponentModelConstruction(typeof (PerWcfOperationLifestyle))
其中 CustomLifestyleLevelingContributeComponentModelConstruction 是:
public class CustomLifestyleLevelingContributeComponentModelConstruction : IContributeComponentModelConstruction
{
private readonly Type customLifestyleType;
private readonly List<LifestyleType> ignoredLifetyles;
public CustomLifestyleLevelingContributeComponentModelConstruction(Type customLifestyleType)
{
this.customLifestyleType = customLifestyleType;
}
public void ProcessModel(IKernel kernel, ComponentModel model)
{
model.LifestyleType = LifestyleType.Custom;
model.CustomLifestyle = customLifestyleType;
}
}
我的问题是PerWcfOperationLifestyle类已从 Windsor 3.0 中删除。谁能告诉我如何使用 Windsor 3.x 实现相同的目标?