我有以下工厂:
public class MyFactory : IMyFactory
{
private readonly IEnumerable<IMyService> myServices
public MyFactory(IEnumerable<IMyService> myServices)
{
this.myServices = myServices;
}
}
我正在注册我IEnumerable<IMyService>
的这样的:
container.Register<IMyFactory, MyFactory>();
container.RegisterAll<IMyService>(
from s in AppDomain.CurrentDomain.GetAssemblies()
from type in s.GetExportedTypes()
where !type.IsAbstract
where typeof(IMyService).IsAssignableFrom(type)
select type);
container.Verify();
然后我得到以下结果
// correctly resolves to count of my 4 implementations
// of IMyService
var myServices = container.GetAllInstances<IMyService>();
// incorrectly resolves IEnumerable<IMyService> to count
// of 0 IMyServices.
var myFactory = container.GetInstance<IMyFactory>();
为什么我的工厂无法解决代收服务?