我有父类动物和两个子类狗和猫。我正在使用 Autofac 进行依赖注入。我想根据配置文件中指定的条件注册 Dog 和 Cat。
我想在我的模块类中使用以下代码。
If Dog mentioned in Config file then
builder.RegisterType<Dog>().As<Animal>().PropertiesAutowired().SingleInstance();
If cat mentioned in Config file then
builder.RegisterType<Cat>().As<Animal>().PropertiesAutowired().SingleInstance();
请建议相同。