FromNewComponentSibling 然后重用

FromNewComponentSibling and then reuse

Container.Bind<ICompanion>()
    .To<RouMainMenuPresenterCompanion>()
    .FromNewComponentSibling()
    .WhenInjectedInto<MainMenuPresenter>();

Container.Bind<RouMainMenuPresenterCompanion>()
    .FromResolve();

我希望将 RouMainMenuPresenterCompanion 的同一个实例作为 ICompanion (FromNewComponentSibling) 注入到 MainMenuPresenter 中,并在将来将此创建的实例作为 RouMainMenuPresenterCompanion 重用于任何解析器

上面的例子导致了循环依赖。我该如何解决我的问题?

我可能理解不正确,你能改成这样吗?

Container.Bind(typeof(ICompanion), typeof(RouMainMenuPresenterCompanion))
    .To<RouMainMenuPresenterCompanion>()
    .FromNewComponentSibling()
    .WhenInjectedInto<MainMenuPresenter>();

编辑:这可能是您要找的更多内容:

Container.Bind<RouMainMenuPresenterCompanion>()
    .FromNewComponentSibling()
    .WhenInjectedInto<MainMenuPresenter>();

Container.Bind<ICompanion>()
    .To<RouMainMenuPresenterCompanion>()
    .FromResolveGetter<MainMenuPresenter>(p => p.Companion)