棱柱和圆相关性

发布于 2024-10-16 06:06:43 字数 268 浏览 3 评论 0原文

我必须棱镜模块,它们都依赖于对方提供的服务。有没有办法以安全的方式呈现相互依赖?我曾考虑过将它们组合成一个模块,但它们确实没有逻辑上组合。

顺便说一句,我知道 MEF 可以做到这一点;我知道MEF很棒!我爱MEF。我无法切换到该技术,因为它需要对框架和 IDE 进行升级,而我现在(时间方面)负担不起。

如果您遇到和我一样的问题,请查看 MEF。对我来说已经太晚了;救救你们自己吧!

I have to prism modules that are both dependent on services the other offers. Is there a way to present interdependence in a way that is safe? I've thought about combining them into a single module, but they really don't logically combine.

BTW, I know MEF can do this; I know MEF is awesome! I love MEF. I can't switch to that technology because it would require an upgrade in the framework and IDE that I can't afford (time wise) right now.

If you are having the same trouble as me go check out MEF. Its to late for me; save yourselves!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

潦草背影 2024-10-23 06:06:43

在我看来,逻辑解决方案是将这两个模块之间共享的服务提取到第三个模块中。然后,您的两个当前模块都可以安全地依赖于共享模块,您没有循环依赖关系和良好分离的项目结构。

有什么理由不能这样做吗?

It seems to me that the logical solution is that the services which are shared between these two modules get extracted into a third module. Your two current modules can then both safely depend on the shared module, you have no circular dependencies and a nicely separated project structure.

Any reason this can't be done?

雨落□心尘 2024-10-23 06:06:43

我知道该怎么做了。演示服务在初始化时不需要超时服务,因此我在惰性属性中解决了它。

    public ITimeout Timeout
    {
        get
        {
            if (_timeout == null)
                _timeout = _serviceLocator.GetInstance<ITimeout>();

            return _timeout;
        }
    }

由于超时服务是在其模块初始化时注册的,因此该属性在需要时可用。它并不理想,但它有效。这个故事的寓意是与 MEF 一致。

叹息!

I figured out what to do. The timeout service is not needed by the presentation service at initialization, so I resolved it inside a lazy property.

    public ITimeout Timeout
    {
        get
        {
            if (_timeout == null)
                _timeout = _serviceLocator.GetInstance<ITimeout>();

            return _timeout;
        }
    }

As the timeout service is registered at initialization of its module, this property is available when it is needed. Its not ideal, but it works. The moral of the story is go with MEF.

Sigh!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文