我有如下所示的具有依赖性的代码部分:AutoFac:PropertyWiringFlags.AllowCircularDependencies是做什么的?
public class MyPage : Page //ASPX WebForms page
{
public IPersonBl PersonBl { get; set; }
}
public class PersonBl : IPersonBl
{
public PersonBl(ISomeMagicBl magicBl){...}
}
public class SomeMagicBl : ISomeMagicBl
{
public IPersonBl PersonBl { get; set; }
public SomeMagicBl(/*Other dependencies*/) {...}
}
我的模块配置如下所示在我的课
...
builder.RegisterAssemblyTypes(ThisAssembly).Where(t => t.Name.EndsWith("BL")).AsImplementedInterfaces().PropertiesAutowired(PropertyWiringFlags.AllowCircularDependencies).InstancePerLifetimeScope();
...
可以看出,我有循环依赖我可以通过使用..PropertiesAutowired(PropertyWiringFlags.AllowCircularDependencies)..
来解决这个问题。
我的问题: 这个标志在幕后做了什么来解决这些循环依赖?
完美,thx。我认为你应用了这样的策略,只是想确保:) – Juri