Sep 9, 2008 at 4:02 PM
Hi, I'm just taking a first look at Unity, with the hope that I can use it to load plugins. e.g. All types that support something like ISoundEffectPlugin, some of which might be 3rd party created.

I know I can do this:

IEnumerable<ISoundEffectPlugin> plugins = myContainer.ResolveAll<ISoundEffectPlugin>();

But what if I want to filter the list by other criteria before I go ahead and create real instances? Maybe I want to let the user pick from a list, and only bother to create an instance of the one they selected.

Sure, I can get the list of matching types like this:

IEnumerable<Type> pluginTypes = myContainer.ResolveAll<ISoundEffectPlugin>().Select(plugin => plugin.GetType());

But what if resolving every installed plugin (along with their graphs of dependencies) might be expensive?

I'd really prefer something like this, which avoids doing the actual resolving:

IEnumerable<Type> pluginTypes = myContainer.ResolveAllTypes<ISoundEffectPlugin>();

Is there something equivalent to that?
Sep 9, 2008 at 10:42 PM
There's nothing built in. You could add something like it using an extension.

You might want to consider looking at MEF - it's explicitly designed around managing addins and delay loading stuff.