JasperFx / lamar

Fast Inversion of Control Tool and Successor to StructureMap
https://jasperfx.github.io/lamar
MIT License
572 stars 119 forks source link

Injected instance not get resolve when multiple candidate rules #148

Closed jaksonlin closed 5 years ago

jaksonlin commented 5 years ago

Program.txt

In the Attach Program,

the Injected instance not get resolve when we put "this.Injectable()" in the first place when constructing the ServiceRegistry, and work as expected if we put at last:

 class RunTimeInjectServiceReg : ServiceRegistry
{
    public RunTimeInjectServiceReg()
    {
        this.Injectable<IMyTest>(); //wrong! not resolve
        For<IMyTest>().Use<MyTest>()
            .Ctor<string>("name").Is("alpha").Named("A");
        For<IMyTest>().Use<MyTest>()
           .Ctor<string>("name").Is("beta").Named("B");
        For<IMyTest>().Use<MyTest>()
            .Ctor<string>("name").Is("gamma").Named("G");
        //this.Injectable<IMyTest>(); // correct, work as expected
    }
}

Could you please help to take a look? and appreciate if you could help pointing out the line of code causing this behavior.

Thanks a lot.

jaksonlin commented 5 years ago

understood, close now.