In a previous post we have seen the Application Explorer acting as a starting point for our software factory. To continue our journey, let's have a closer look at this Application Explorer. For example, where does it get the list of installed software factories from?
A quick look at GAC on our Rosario VPC reveals a few new assemblies that (based on their name?!) might have something to do with software factories. these are:
- Microsoft.VisualStudio.SoftwareFactories.Runtime.dll
- Microsoft.VisualStudio.SoftwareFactories.Runtime.VSHost.dll
- Microsoft.VisualStudio.SoftwareFactories.ApplicationExplorer.dll
The Application Explorer is obviously implemented in "Microsoft.VisualStudio.SoftwareFactories.ApplicationExplorer.dll". Currently, no (public) documentation is available so we have to use reflector to find out this assembly holds the "ApplicationExplorerPackage" (inherited from Microsoft.VisualStudio.Shell.Package) which is using the "FactoryManager" (more on that later). Besides the "ApplicationExplorerPackage" this assembly also implements the ApplicationExplorerToolwindow and the ApplicationExplorerControl which are representing the UI of the Application Explorer in Visual Studio.
Digging a little further, we can find out the "FactoryManager" (implemented in Microsoft.VisualStudio.SoftwareFactories.Runtime.dll) is using the "FactoryDescriptorsLoader" to search the Registry for installed software factories on the machine.
please note more classes are involved in this "discovery process" but I am only focussing on the high level to make this post not more confusing than it probably is already. I am sure you know how to use reflector yourself if you are interested in more details ;)
As we can see in the screenshot below the Registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\SoftwareFactories) in the Rosario VPC holds information about two installed software factories. By looking at the Service Factory node we can see the Registry contains the Name, Description, InstallDir, Version and SchemaFileName of the software factory.
SchemaFileName?! hmm....is this in anyway related to the "Software Factory Schema that is discussed in the "Software Factories" book? Below a screenshot of the Schema File for Service Factory that we can find in the "InstallDir" of Service Factory (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies). Pretty interesting to finally find concepts like "viewpoints" and "workproducts" related to software factory implementations.
Without going into too much detail, how does this all work?
It all starts in the "VSPackage" (inherited from Microsoft.VisualStudio.Shell.Package) that can be found in "Microsoft.VisualStudio.SoftwareFactories.Runtime.VSHost.dll". At some point a "FactoryManager" (Microsoft.VisualStudio.SoftwareFactories.Runtime) is instantiated. This "FactoryManager" is using a "FactoryDescriptorLoader" to read the Registry and to create (and cache) a collection of "FactoryDescriptor" classes. The information contained in the software factory Schema File eventually ends up as a "Factory" instance that holds the "FactorySchema" which is the root for the FactoryViewPoint, Command, WorkProducts, etc. The Application Explorer on its turn is using the "FactoryManager" to list the installed factories, the viewpoints it contains and enables us to (for example) execute the "Create Product" action that we discussed earlier.
Again, just the high level overview! There are a lot more interesting classes and concepts involved in this but it hopefully gives some basic understanding. In a next post we will try to understand the purpose of the "Commands", "Viewpoints" and "Workproducts" that we have seen in the software factory Schema File.
To be continued...