开发者

Specifying One of Many Constructor Parameters With StructureMap

If I have a class like so:

public SomeClass : ISomeClass
{
    public SomeClass(IInjectedDependency dependency, bool someArbitraryValue) {}
}

How can I set this up with SM to inject the dependency but specify the arbitrary value?

I've tried the following but it doesn't work (I get "There is no argument of type System.Boolean for concrete type IInjectedDependency"):

ObjectFactory.Initialize(x =>
    {
        x.For<IInjectedDependency>().Use<ConcreteDependency>();
        x.For<ISomeClass>().Use<SomeClass>().Ctor<bool>("someArbitraryValue").Is(false);
    });

I think this is only for a constructor with one parameter and thats why it doesn't work with multiple开发者_高级运维 (I've used it for one param constructors and it works fine).

TIA!

m


Works like it should. Problem on my end.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜