Build Extensions using Container

Feb 15, 2008 at 3:27 PM
Is there a good reason why container extensions specified by configuration aren't built using the container itself?

I see this as very useful as some extensions will be based on dependencies of their own.

So in AddExtensionContainerConfigurationCommand.Configure, I'd propose something like:

public void Configure(IUnityContainer container)
{
  Guard.ArgumentNotNull(container, "container");
  container.AddExtension(container.Get(extensionType));
}

Which brings me to the point where I think extensions specified in the configuration should also be keyed on their name so that when built with the container, the appropriate name is also used as part of the key.
Feb 15, 2008 at 9:33 PM
That is a very interesting idea; to be honest, I hadn't even thought of it. It'd be pretty easy to do.
Mar 5, 2008 at 3:40 PM
What if ExtensionContext was automatically registered as a service and it was getting injected into the extension?

You could remove InitializeExtension(ExtensionContext context).
Mar 5, 2008 at 4:34 PM
I created a WI here: http://www.codeplex.com/unity/WorkItem/View.aspx?WorkItemId=1646
Mar 5, 2008 at 5:02 PM

francois_tanguay wrote:
What if ExtensionContext was automatically registered as a service and it was getting injected into the extension?

You could remove InitializeExtension(ExtensionContext context).


It's a neat idea, but I've got one issue here. ExtensionContext wouldn't ONLY get injected into extensions, it'd get injected into anything that asked for it. Which could result in some fun malicious hard-to-debug issues when resolving type Foo results in all your strategies being removed.

-Chris
Mar 5, 2008 at 5:35 PM
True, everybody would gain access to the ExtensionContext if they wanted to. They can already. Just add an extension that registers the context into the policy list and voilà!

There's plenty of other ways to be malicious. Add an extension and call policyList.Clear(), ...

Basically, I don't see this as being an issue.
Mar 5, 2008 at 5:54 PM
Let me ask a different question: What is the advantage of this change? What new scenarios does it enable?

Mar 26, 2008 at 12:33 AM
I totally forgot to come back on the fact that we could get rid of "extensionConfig" and inject our extensions configuration the same way we inject any other type.

What do you think?