Silverlight TV Episode 5: Using Metadata with MEF

Sign in to queue

Description

Hamilton Verissimo, Program Manager working on MEF, makes a return visit to Silverlight TV to follow up his discussion of MEF. This time Hamilton discusses different ways metadata can be used with MEF and suggests some pros and cons for each. As usual, he dives right into the code samples and gives some great guidance on MEF.

Follow @SilverlightTV on Twitter for the latest updates.

Embed

Download

Download this episode

The Discussion

  • User profile image
    philcockfie​ld

    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?

     

    Gracias!

  • User profile image
    justncase80

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

  • User profile image
    mgraham

    Excellent work...  MEF looks amazing...

  • User profile image
    Dewy

    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?

     

    Cheers

  • User profile image
    jopapa

    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
    brandf

    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:

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

     

    or

     

    [ImportMany]
    [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
    haveriss

    Hi

    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
    brandf

    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
    gblock

    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: http://codepaste.net/ktdgoh

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

     

  • User profile image
    mgbecker

    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!

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.