Monday, March 03, 2008

In a previous post we mentioned the existence of a "Software Factory Schema" file for an installed factory in our Rosario CTP. We now know, at some point, a "Factory" instance is created from this file that holds all the information that is stored in this schema file. Let's have another look at the software factory schema file of Service Factory to see if we can learn something more from this.  

Schema  

One of the things to notice in this schema file is a viewpoint that is called "ServiceRootViewPoint". This viewpoint is the so called "root viewpoint" for this software factory. We can also see that there is another viewpoint within this root viewpoint that is called "ServiceContractDesignerViewpoint". As we can see, the root viewpoint holds a "Command" (ServiceRootCreationCommand) that contains a "CommandType" and a "CommandImplementationType. In this case both are implemented in the "Microsoft.Practices.ServiceFactory.Commands.dll" that we can find in the "InstallDir" (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies) of this factory.

So, where do we need this CommandType and CommandImplementationType for? In a previous post, we have seen that when we executed the "CreateProduct" in the Application Explorer  

ApplicationExplorer 

it popped up a dialog where we could select the software factory where wanted to create a product from. 

factory 

When we select a software factory in this window and hit OK, the ApplicationExplorer (and some helpers) retrieves the root viewpoint of the software factory and finds the Command that is associated with this. At that point the Command,implemented as a "FactoryCommand" is transformed into a more general "Command" that is implemented in "Microsoft.VisualStudio.ToolIntegration.Backplane.dll".

This is actually *very* interesting because this assembly implements a concept that is sometimes referred to as the "DesignerBus" (it is called Backplane at this moment) which hopefully makes it possible to, for example, implement references between models, references between models and designers, toolwindows, get a reference to a Service in VS.NET,etc.  It can actually be used to glue everything together ;) Anyone familiar with the DSL Tools knows that at this moment we only have DIS to create references between models and only in a very limited way. Maybe Backplane can help here! (More on this very exiting stuff in another post).

Let's continue with our Command... After the FactoryCommand is "converted" into a general command it gets executed. Below we can see a code snippet from the "Execute" method of the "ServiceRootCreateCommandImplementation" from the root viewpoint of Service Factory. The code might look funny to you but this is just because it is produced by reflector and not by me ;) You can see that "Backplane" is used here to get a reference to the "RecipeManager" and "DTE". Perfect! 

code 

What we can also see is that basically all that happens here is, get a reference to the a Guidance Package and unfold a template (model.vstempate) to set the initial structure of our Service Factory solution. Please note that "model.vstemplate" is just a normal  .vstemplate that is located in the source tree of Service Factory (C:\Program Files\Microsoft Service Factory V3). This means, in Rosario CTP we can create command, hook it up to the root viewpoint of our software factory and Application Explorer makes sure it gets executed to set, for example, the initial structure for the product we are building in our factory. From there on, all "normal" (old) Service Factory V3 recipes should work as expected! (Decide for yourself if that is good or bad news)

Below you can see what Application Explorer looks like after we executed the "Create Product" and selected the "Web Service Software Factory" in the "New Product" dialog. Also note the "ServiceContractDesignerViewPoint" folder that we have seen in the software factory schema above.  

AppExpl 

Solution Explorer looks like this. Note the .pdef files! (More on that later)

 SolutionExplorer 

 

To be continued...