Silverlight TV Episode 5: Using Metadata with MEF

Sign in to queue

The Discussion

  • User profile image

    Very helpful distillation of the stages of declaring and consuming Export MetaData.  Thanks!

    As a quick-start reference, any chance your could post those 4 sample cs files?



  • User profile image

    I have to watch this video because the guy on the left looks like Dwight Shrute.

  • User profile image

    Excellent work...  MEF looks amazing...

  • User profile image

    I love the pace of the videos and the walk throughs. I do enjoy screen casts, but some can be painful to watch because of their speed.


    I do have one request:

    I reliase that I will get no sypathy for this, but I usually watch screen casts on full screen and I have a 27" monitor, when doing this, the video of the visual studio screens is very poor. Can you not move to using Smooth Streaming and HD?



  • User profile image

    Dewy - We (Channel 9) are working on some changes to help make the entire experience even better. Unfortunately this does not help you right now, but we are looking into some improvements.


    Thanks for watching!

  • User profile image

    Why do you need to write any code at all to filter on metadata?  Why not have an 'ImportMetadataAttribute' that causes MEF to do the filtering for me?  The most common case is an 'equals' match against the metadata key/values, I would think there would be a simple way to do this without all this Lazy buisness..  Something like this:

    [ImportMetadata("IsSecure", true)]
    public IEmailSender Sender {get; set; }




    [ImportMetadata("IsSecure", true)]
    public IEnumerable<IEmailSender> Senders {get; set; }

    It would also be nice to say 'I only want one, and I dont care which one' using an 'ImportAnyAttribute'.

  • User profile image


    The reason we didnt do this is because it's easy to get caught on complicated situations. What would happen if you want to build an expression (X) AND (Y) OR (W)? What's the semantic when more than one attribute is present (OR or AND)? and this kind of things. Hence imperative code would be prefered.


    Thanks for the feedback

  • User profile image

    I'm not suggesting you remove the imperative way to handle these more complicated cases.  I just seems like overkill for what I would imagine is the common case.

    It would be intersting to look at how Export Metadata is used in VS 2010 as a case study for how common these more complicated cases are.  My gut feeling is that equality comparison on a single piece of metadata (or AND'ed for multiple ImportMetadatas) is the common case.

    This would make it more pay-for-play...

  • User profile image

    Hi Brandf

    Thanks for the feedback. We've been looking into ideas such as ImportMetadata for a while and are exploring several options. One alternative approach to having it on the import side is to have an adapter part which sits in the middle and provides the filtering the importer needs without requiring the importer to know. A different approach is to have a custom collection (which MEF supports) which does the adaptation. That you can do today, for example:

    Regardless, we appreciate the feedback and are looking into better ways to handle this problem going forward.


  • User profile image

    Has the code for this episode been published anywhere?  There seems to be some very good stuff that I'd like to get my hands on!

Add Your 2 Cents