How to export and import applications using MEF?

I am working with MEF right now, but the answer I'm looking for is probably not related to MEF - it's all dependency injection - I just use the MEF terminology as an example here.

A Brief History, I read this article on MSDN with a focus on composite applications

This figure shows three things: the shell, application services, and modules. So a composite application.

alt text
(source: microsoft.com )

What I do not fully understand is part of the application service. What kind of service does it look like? How do you provide a service through a module and how do you use a service from another module?

, , -, , ( ).

+5
2

, MEF, . , , .

, . IService ( [ImportMany] ), .

, , . , , , :

public interface IDataRepostory
{
     public IList<MyType> MyTypes { get; }
}

:

[Export(typeof(IDataRepository))]
public class Repository: IDataRepostory
{
    // implement interface for this specific "service"
}

. , , , . , :

public class CustomersViewModel
{
     [Import]
     public IDataRepository
     {
         get; set;
     }

     // ...
}

, .

"Application Service", - - , , .

+3

, . , IPersonBuilder, . MyPersonBuilder . IPersonBuilder , MEF CreatePerson() MyPersonBuilder .

0

All Articles