MEF: Satisfy part on an Export using and Export from the composed part.
- by Pop Catalin
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