After finding out a cool trick that enables me to install a theme extension using Nuget, I realized that the monster I had created was a lot more powerful. There was no reason to limit to just theme extensions (Shell extensions work aswell, and hopefully I can research some other extensions soon too…), and there was no reason to limit the installation to just Nuget…
Give me a couple of minutes of your time to show you what I mean…
The theme extension really has two parts. One part is responsible for defining the theme (named: theme definition, contained partially in the Common and partially in the Client project), the other part is the actual implementation of the theme (Theme.xaml in my drawing above).
In the awful scheme above, you can see that the LightSwitch application, once the theme is installed and selected, really takes two major steps to load the theme.
- First, it uses MEF to find a class that is exported as an “ITheme”. Basically, it will find the class, and ask it where the implementation can be found.
- It will then load the implementation (ie: load the xaml and add it to the application’s resources).
LightSwitch + ExtensionsMadeEasy approach.
What the ExtensionsMadeEasy extension does, is only provide the “EasyTheme”: a theme extension with a definition but without an implementation.
To load a theme, there will be an extra step needed.
- First step remains unchanged, the LightSwitch application uses MEF to find a class that is exported as an “ITheme”. Basically, it will find the class, and ask it where the implementation can be found.
- Because the EasyTheme has no implementation itself, it will use MEF to find a class that is exported as an “IThemeExporter”. Basically, it will find this class, and ask it where the implementation can be found.
- The application loads the theme.
The advantages are numerous: when the implementation is in a Silverlight Class Library (or a Nuget package), a developer won’t need to reinstall the VSIX extension to see the latest progress of the designer (shell, theme, whatever!) / when you are creating an extension, you can use ExtensionsMadeEasy to debug your extensions with great ease / you can create a new theme / shell / … for your LightSwitch application without MS VS professional / …
Getting started yourself.
Why don’t you give it a go and start developing a theme that can later be used to create a Nuget package, or even your own Theme Extension (VSIX, bah!)?