0

我有一个接口和两个实现它的类。其中之一在其构造函数中有一个参数。我已在我的 app.config 中将它们都注册为服务。不幸的是,我无法在我的代码中解决这两个问题:没有返回带有构造函数的类。

例如:

interface ITest
{
}

class Test : ITest
{
    private string a;

    public Test(string a)        
    {
        this.a = a;
    }
}

class Test2 : ITest
{
}

这是我的配置:

<castle>
    <components>
        <component id="Test" type="XYZ.Test, XYZ" service="XYZ.ITest, XYZ"/>                
        <component id="Test2" type="XYZ.Test2, XYZ" service="XYZ.ITest, XYZ"/>
    </components>
</castle>

以下是我尝试在代码中获取服务的方法:

ITest[] resolveAll = container.ResolveAll<ITest>(new {a ="aText" });

数组“resolveAll”只包含“Test2”,但没有“Test”的踪迹。我该怎么做才能获得这两个课程?

我注意到,如果我用 id "Test" 解决:

object resolve = container.Resolve("Test", new { sessionId = "sessionId" });

我获得了我的“测试”课程。

我究竟做错了什么 ?

4

1 回答 1

0

实际上,我在旧版的温莎城堡上。在上一个版本(3.1)上,这有效。

于 2012-08-09T12:42:04.017 回答