imageWorkshop: Specifying a Contract

The previous workshop demonstrated how you could make use of a “part” without the need to “new it up.” However, it provided no benefit over simply “newing it up.” You may as well have simply done this in the MainPage class's constructor, like this:

MyImportedPersonPart = new PersonPart();

The MainPage class is still tightly coupled to the PersonPart class. The benefits of MEF are realized only when you make use of a contract to decouple them, exporting the part according to an interface instead of its concrete implementation. By taking a contract-based approach, you can then swap in alternative parts to the PersonPart ...

Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.