Reputation: 11
I am using Prism 4.0 with MEF. My application uses the [ImportingConstructor] attribute on its classes to construct objects. I need to gain access to the objects constructed. I believe Prism has a list of all the objects it created. Help me find the SomeObjectListSomewhere as shown below.
Example:
public class Foo
{
private readonly INoob _noob;
[ImportingConstructor]
public Foo(INoob noob)
{
_noob = noob
}
}
public class NotNoob
{
public GoAction()
{
// I need Access to all INoob constructed objects here
foreach (INoob noob in SomeObjectListSomewhere)
{
noob.DoSomething();
}
}
}
Upvotes: 1
Views: 98
Reputation: 26362
Maybe you could do something simple like
[ImportMany]
IEnumerable<INoob> Noobs { get; set; }
Then use the Noobs
collection and simply loop through the list like you do in GoAction()
.
Upvotes: 1