Jul 1, 2012 at 8:43 PM
Edited Jul 1, 2012 at 8:45 PM
I have been investigating the use of the MEF ConventionBuilder for convention based discovery of pages for a MVVM framework I am developing (NB: ConventionBuilder is the equivalent to RegistrationBuilder when using the version of MEF
for Win8 Metro-style apps). What I would like to achieve is to apply a specific export to all types that end "Page". This can be done by,
conventionBuilder.ForTypesMatching(type => type.Name.EndsWith("Page"))
.Export((builder) => builder.AsContractType<object>()
However rather than exporting all the types with the page name set as "Home" I would like to use the start of the type name (i.e. a type called "AboutPage" with the page name attribute set as "About"). Unfortunately the Export
extension method does not supply any overrides that provide the type name.
Is there any way I can achieve my aim or am I approaching this from the wrong angle?
NB: In contrast I could add this to part metadata with the following code...
.AddPartMetadata("PageName", type => type.Name.Substring(0, type.Name.Length - 4))