0

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 で同じ目標を達成する方法を教えてください。

4

1 に答える 1

1

ProcessModel メソッドを次のように書き直すことで、この問題を解決しました。

public void ProcessModel(IKernel kernel, ComponentModel model)
    {
            model.LifestyleType = LifestyleType.Scoped;
            model.ExtendedProperties[Constants.ScopeAccessorType] = typeof(WcfOperationScopeAccessor);
    }
于 2014-10-13T13:46:58.530 に答える