Hello, I was wondering if there was an alternate way to describe Menu hierarchy by using something else than the actual contract name. I noticed that you defined classes and sub classes for you menu architecture and was wondering if it would have been possible to use metadata instead. My concern is really about creating sometimes empty classes decorated with export attribute to achieve the menu parent-child relationships. Could you please tell me what led you to this design instead of considering putting menu hierarchy in an external plugin manifest file for instance, for simplicity? Thank you

asked 15 Aug '11, 12:36

zaladane's gravatar image

zaladane
21114
accept rate: 0%

edited 22 Aug '11, 22:35


I originally had just used string contract names. I then moved them to constants in a static class hierarchy at the suggestion of Glenn Block.

The menu hierarchy is just a hierarchy of extensions extending extension points, so there's nothing really unique about Menus. The same rules apply to, for instance, startup commands. I didn't think menus deserved their own separate subsystem.

My "plugin design" is really just a thin wrapper over MEF, and this is one of the common ways to do it in MEF. That's about it.

link

answered 15 Aug '11, 13:39

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%

Though SoapBox Core and its demo plug-ins do not use a manifest, taking such an approach is still possible (and sometimes cleaner) with MEF in SoapBox Core. There are all sorts of ways to achieve DI with MEF. For example, instead of only using contract names for building menu items you can create a custom ExportProvider that is capable of converting something like XML or XAML to whatever menu hierarchy you desire. Here is an interesting example of exactly that. Also, here is another excellent link that talks about another use for custom ExportProviders.

I think that SoapBox is an excellent place to start with MEF and I don't think it was ever meant to be an exhaustive demo for all the amazingly cool things you can do with MEF.

link

answered 22 Aug '11, 22:33

KarlB's gravatar image

KarlB
576202136
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7
×2

Asked: 15 Aug '11, 12:36

Seen: 2,525 times

Last updated: 22 Aug '11, 22:35

powered by OSQA