using StructureMap 4, and me new to C#, i wonder why i get a compilation error:
var di = new Container(_ =>
{
// (1) compile error: CS1503: Argument 1: cannot convert from 'StructureMap.IContext' to '...ITest'
_.For<Func<ITest, ITestRunner>>().Use( arg => new TestRunner(arg) );
// (2) compiles OK
Func<ITest, ITestRunner> f1 = arg => new TestRunner(arg);
_.For<Func<ITest, ITestRunner>>().Use( f1 );
// (3) with cast compiles ok
_.For<Func<ITest, ITestRunner>>().Use( (Func<ITest, ITestRunner>)( arg => new TestRunner(arg)));
});
Is there a compact syntax, were i don't need the f1
variable (2) and without the cast repeating the types (3) ?