我在代码中从ServiceBase类创建了类。
public class ControlSystemServiceBase: ServiceBase
{
public ControlSystemServiceBase() : base()
{
this.AutoLog = true;
}
}
之后,我将该课程注册为
container.RegisterType<ControlSystemServiceBase, ServiceAlarmAccess>("AlarmAccessService", IocLifetime.SingleInstance);
container.RegisterType<ControlSystemServiceBase, ServiceDataAccess>("DataAccessService", IocLifetime.SingleInstance);
好的。现在,我想接收此ControlSystemServiceBase类型的所有对象。 但是我不能。
var servicesToRun = container.ResolveAll(typeof(ControlSystemServiceBase));
servicesToRun始终为0。但是如果我将注册从ControlSystemServiceBase更改为ServiceBase,并将我的类注册为
container.RegisterType<ServiceBase, ServiceAlarmAccess>("AlarmAccessService", IocLifetime.SingleInstance);
container.RegisterType<ServiceBase, ServiceDataAccess>("DataAccessService", IocLifetime.SingleInstance);
我可以接收所有2个对象。为什么?