MEF: Satisfy part on an Export using and Export from the composed part.
Posted
by Pop Catalin
on Stack Overflow
See other posts from Stack Overflow
or by Pop Catalin
Published on 2010-06-17T12:52:56Z
Indexed on
2010/06/18
8:53 UTC
Read the original article
Hit count: 208
Hi,
I have the following scenario in Silverlight 4:
I have a notifications service
Snippet
[InheritedExport]
public interface INotificationsService : IObservable<ReceivedNotification>
{
void IssueNotifications(IEnumerable<ClientIssuedNotification> notifications);
}
and and implementation of this service Snippet
[PartCreationPolicy(CreationPolicy.NonShared)]
public class ClientNotificationService : INotificationsService
{
[Import]
IPlugin Plugin { get; set; }
...
}
How can I say to MEF that the Plugin property of the ClientNotificationService must be provided by the importing class that imports the INotificationsService.
For example:
Snippet
public class Client
{
[Export]
IPlugin Current { get; set; }
[Import]
INotificationService NotificationService;
}
How can I say that I want MEF to satisfy the ClientNotificationService.Plugin part with the exported IPlugin by the Client class.
Basically I want the NotificationService, to receive a Unique ID provided by the importing class, whenever it is created and composed to a new class, or if there's and alternative method, like using meta data to do this I'd appreciate any insights. I've been struggling with this for a while.
Thanks
© Stack Overflow or respective owner