_container = new CompositionContainer(catalog);
CompositionBatch batch = new CompositionBatch();
// We've put an Import on the MainWindow so that we can add this to the composition batch.
batch.AddPart(this);
_container.Compose(batch);
MainWindow.Show();
}
Now, all I do is drop in code into the Plugins directory and it just works. Really, that's what I want the tagline for MEF to be - It Just Works. Thanks guys, I appreciate the pain you've taken away. Now Goldlight quite happily moves task dialog and KTM code out from the main library into a services library.
--
Peter O'Hanlon
I am using the RIA Services/Silverlight 4 Exemplar I am working on and even though I am doing everything in the XAP (not loading XAPs dynamically), the hooking up of the models to the VM's to the Views is pretty awesome. For example:
[PartCreationPolicy(CreationPolicy.Shared)] // For singleton
[Export(typeof(IGamesModel))]
public class GamesModel : IGamesModel
{
// ...
[Export(typeof(IGameEditorViewModel))]
public class GameEditorViewModel : MyViewModelBase, IGameEditorViewModel
{
private IGamesModel _model;
[ImportingConstructor]
public GameEditorViewModel(IGamesModel theModel)
{
_model = theModel
// ...
public partial class GameListView : UserControl
{
public GameListView()
{
InitializeComponent();
// Use MEF To load the View Model
PartInitializer.SatisfyImports(this);
}
[Import(typeof(IGameListViewModel))]
public IGameListViewModel ViewModel
{
set
{
DataContext = value;
}
}
// ...
Who needs documentation when you can have Glenn’s personal MSN account (I will send you his contact info against a small payment ;))
Just kidding. I agree that lack of doc needs to be solved to see a wide adoption. Hope the team has some time for that soon J
Laurent
From:
wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On
Behalf Of Peter O'Hanlon
Sent: Sunday, December 20, 2009 3:47 PM
To: wpf-di...@googlegroups.com
Subject: Re: [WPF Disciples] MEF
Glenn
Why use a static class? Are you calling it multiple times in the app?
-Corrado
On Mon Dec 21 04:04:20 CST 2009, Glenn Block