Skip to content

Export by key and generic #145

@xp-development

Description

@xp-development

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions