Prism and Circular Dependence
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 开发者_如何学Gocombine.
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!
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?
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!
精彩评论