ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Export by key and generic #145

Closed xp-development closed 6 years ago

xp-development commented 6 years ago

Cannot locate object by key and generic.

[Fact]
public void KeyedWithGeneric()
{
    var container = new DependencyInjectionContainer();

    container.Configure(c =>
    {
        c.Export(typeof(ImportGenericService<>)).AsKeyed(typeof(IImportGenericService<>), "A");
        c.Export<BasicService>().As<IBasicService>();
    });

    var service = container.Locate<IImportGenericService<IBasicService>>(withKey: "A");

    Assert.NotNull(service);
    Assert.NotNull(service.Value);
    Assert.IsType<BasicService>(service.Value);
}
ipjohnson commented 6 years ago

Sorry about that, I've committed a fix to the dev branch for this and will look to do a release in the coming days.

ipjohnson commented 6 years ago

This is released in 6.3.1