Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Silverlight TV Episode 5: Using Metadata with MEF

Download

Right click “Save as…”

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.

Tags:

Follow the Discussion

  • 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!

  • justncase80justncase80 Carpe Noctem

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

  • Mike Grahammgraham Mike Graham

    Excellent work...  MEF looks amazing...

  • 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

  • John Papajopapa Development Shaker

    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!

  • 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'.

  • 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

  • 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...

  • 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.

     

  • 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!

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.