MefContrib/MefContrib — Issue #24: Access to CompositionModelBinderProvider's global Container.
Author: JelleHissink
Created: 2011-10-09 00:08:34+00:00
State: open

Hello,

For a MVC application I need access to the global container that is used on application level at startup (I don't have a request yet)
.
For this I could replace the existing CompositionDependencyResolver with a custom implementation. But then I'm unable to reuse the CompositionModelBinderProvider because of a hard dependency.

I see a number of ways to solve this. But am uncertain wich you would like most.
- Can this dependency be abstracted to an interface?
- Or can the globalContainer of the CompositionModelBinderProvider be made public.
- Or can the Container property on CompositionModelBinderProvider be replaced with:
public CompositionContainer Container
{
get
{
IDictionary items = CurrentRequestContext.Items;
if (items == null)
{
return this.globalContainer;
}
if (!items.Contains(HttpContextKey))
{
items.Add(HttpContextKey,
new CompositionContainer(this.filteredCatalog, true, this.globalContainer));
}

return (CompositionContainer)items[HttpContextKey];
}
}

Regards,
Jelle