Given an interface
public interface ISomething<TA, TB>
where TA : class
where TB : class, ISomeOtherInterface
{
object SomeMethod(TSource source, TDestination destination);
}
And a class implementing it
public class Something<TA, TB> : ISomething<TA, TB>
where TA : class
where TB : class, ISomeOtherInterface
{
public object SomeMethod(TA source, TB destination)
{
// lots of really important code.
}
}
I've tried registering the implementation both via For().Use() and ConnectImplementationsToTypesClosing()
var container = new Container();
container.Configure(config => {
config.For(typeof(ISomething<,>))
.Use(typeof( Something<,>));
config.Scan(_ => {
_.AssemblyContainingType(typeof(Something<,>));
_.ConnectImplementationsToTypesClosing(typeof(ISomething<,>));
});
});
But to no avail; every call to container.GetInstance<ISomething<Foo, Bar>>() fails with a StructureMapConfigurationException:
No default Instance is registered and cannot be automatically determined for type 'ISomething<Foo, Bar>'
There is no configuration specified for ISomething<Foo, Bar>
1.) Container.GetInstance(ISomething<Foo, Bar>)
Calling container.WhatDoIHave() on the very same container yields
ISomething<TA, TB> My.Project.Namespace Transient Something<TA, TB> (Default)
though. Also, calling container.GetInstance<Something<Foo, Bar>>() (referencing the implementation as opposed to the interface) works just fine.
What am I missing?