Monday, January 22, 2007

As it looks like now, 2007 will be the year where software factories get a lot of exposure and attention. We have seen quite a lot of activity in this space in the second half of 2006 but there is definitely more to come! This also means that there will be a lot of new people entering the software factory space in the next coming months. For those of you who are not that experienced yet with software factories I decided to create a short list with some interesting links to existing software factories, forums, blogs, etc. Hopefully, this overview gives you a head start in entering the exiting world of software factories.  

Available software factories

If you are a practical guy (or girl) and like to get your hands dirty as soon as possible you might want to get yourself an existing software factory and start experimenting with it right away. In that case, check out the following offerings from Microsoft P&P. Clicking the links below will bring you to the MSDN landing page for each of the factories were you will find detailed information, links to the community and links to the download pages.

  1. Web Service Software Factory
  2. Web Client Software Factory
  3. Smart Client Software Factory
  4. Mobile Client Software Factory

You may also want to subscribe to the blogs of some of the P&P Product Managers: Don Smith, Tom Hollander and Eugenio Pace to keep you up to date with the latest news and future directives of the P&P factories. If you are interested in an indication of the "release dates" of the (future) P&P deliverables, check out their brand new "Upcoming Releases" page. 

Software Factories Tools

After experimenting with these existing factories for some time you might want to modify them (to make them better suite your requirements), extend them with some Domain Specific Languages or completely build your own factories from scratch. In that case you have to check out the technologies that drive the current wave of software factories.

First of all, we have the Guidance Automation Toolkit which you can use to create “packages” that can be installed in Visual Studio.NET and basically represents software factories as we see them today. You can download it from here and you can ask your questions about it (which you will definitely have ;)) here.

Second, we have the DSL Tools that you can use to create Domain Specific Languages that you can include in your software factories. You can download the DSL Tools from here and ask your questions about it here.

If you are interested in the combination of the Guidance Automation Toolkit and the DSL Tools you might want to read this article that describes some of the possible integration scenarios. (the library that is used in this article isn’t available yet, but will be soon!).

If you plan to start building your own factories, based on the above mentioned technologies, you also might be interested in the Clarius Software Factories Toolkit. This toolkit adds some extra features to the existing technologies to make it easier to develop your own factories. 

Background information, theory and concepts

Of course, there are also people who are really interested in the theory and the concepts behind the software factories strategy. If that’s you, go get yourself the Software Factories book written by Jack Greenfield and Keith Short. Once you have read this book you realize that we are still at the very early beginning with software factories and there is a lot of improvement to be made in the coming years. Some time ago I have written a post myself about some of the limitations in the first wave of software factories. As you can read there today’s software factories lack a model, schema and a lots of other stuff.

If you are interested in the jargon that is often used in the software factories space, check out this “Software Factories ABC” that I co-authored with Jezz. You better subscribe to his blog if you are interested in software factories because Jezz is an active factory blogger and has some really interesting posts about models, schema and tools. If you are still hungry for more information you can also check the software factories landing page on MSDN for more information.

So, we are done with the list. Of course there is a lot more interesting information about software factories but I am sure you will find them when you start your journey by experimenting with the currently available factories and reading the information I linked too in this post. Hopefully this list can be off any help to "software factories newbies" to get familiar with this very interesting technology as soon as possible.

Happy factories!

Update: also check out the Software Factories Swicki as the online search enigne for all factory related stuff!

posted on 1/22/2007 8:17:49 AM UTC  #    Comments [1]
 Wednesday, January 10, 2007

Service Factory V2, is there!  This release provides some great guidance for building service for WCF and ASP.NET (ASMX). Get it here and make sure to post any feedback and/or questions on the Service Factory community site!

posted on 1/10/2007 7:46:39 AM UTC  #    Comments [2]
 Thursday, January 04, 2007

Ok, I have been tagged by Erwyn so here is my list of 5 things you might not know about me.

  1. When I got my first job back in 1995 I started programming in Microsoft Visual Foxpro 3.0. At that time I found it SO much better than all the other languages (dBbase III+, Pascal and even Cobol) I programmed in before and was really happy with this decision of my employer to use this. Visual Foxpro was a data centric, object-oriented environment and I continued programming in ( newer versions of) Visual Foxpro till the moment the first CTP of .NET came out. From that moment I started programming C# and never went back. When I had my first look at LINQ I was very surprised to see the “Visual Foxpro data centric approach” being integrated in .NET.
  2. I am a KOI keeper! I spend a lot of my spare time on taking care of my 10 beautiful KOI. Because KOI require an excellent water quality I am using several filtration units, millions of Nitrosomonas, UV light and air pumps to keep my pond clear. (some examples of these beauties, unfortunately not mine)
  3. I am married for almost 5 years now with my wife Miranda. I live in the Netherlands in a small town named Hoorn and together with my wife I have a beautiful daughter, named Emily, of almost 2 years old. 
  4. In the evenings, when I am not busy with my KOI or family, I spend most of my time with my laptop on the    couch. I do not watch TV a lot (only some movies) and don't like to sit behind a desk when I am not at work.  So, all my blog reading, sending mail, MSN, etc. is done from my very comfortable couch.
  5. At the age of 17 I started with fitness. Unfortunately I got really addicted to this and fitness slowly became bodybuilding! In that period I was in the gym 7 days a week, ate 3 kilos of cooked potatoes, 300 gram steamed vegetables, a grilled chicken breast fillet, 2 pieces of fruit, some protein shakes a day. At the top of my "bodybuilding carrier" I weight 84 kilogram (184.8 lbs) which is pretty my for a small guy (approximate 5 feet 6 inches) like me. After some years, when I got my first job at a large Dutch Bank, I was aked to wear suits at work. So, I went to the store to buy some new suits. It was at that moment, when I noticed I couldn't buy "normal suits" anymore, I finally realized my body wasn't in normal proportions any more. From that moment I started thinking about quitting fitness (bodybuilding) and luckily after some time I did. (I decided not to post any pictures to make this story not even more embarrassing ;-))

I tag Jezz, Rene, Dennis, Carlo, Christian, Mark

 

posted on 1/4/2007 10:14:32 AM UTC  #    Comments [3]
 Tuesday, December 26, 2006

One of the things that always "bothered" me is the default look of the shapes in a new DSL created with the DSL Tools. Have a look at the first screenshot which I took from a shape in a DSL that is based on the "minimal language template" and compare that to the second screenshot of a shape in the DSL designer of the DSL Tools itself.  

 

 I really don't like the first shape but DO like the way the shape in the second screenshot looks. As you can see in the screenshot below (from another DSL!) it is possible, just by changing a few of the shapes properties, to make the shape look like the shapes in the DSL designer.

Still there is one thing missing! It isn't possible to display icons for the compartment items by just setting some properties for the shape. Luckily, we can do this by writing some custom code in the "GetCompartmentMappings" method that is available in the "shapes.cs" file (GeneratedCode folder in the DSL project). 

In the "GetCompartmentMappings" method for your compartmentshape you will find a piece of code that looks like this (of course with on your own language and shape name!).

mappings[localCompartmentMappingsOffset+0] = new DslDiagrams::ElementListCompartmentMapping("DataMembers",                                     global::MyCompany.DataContractLanguage.DataMember.NameDomainPropertyId,

            global::MyCompany.DataContractLanguage.DataMember.DomainClassId,

            GetElementsFromDataContractForDataMembers,

            null, null, null);

 

We can replace the last "null" value with a reference to a "DisplayImageGetter Delegate". This might look something like this.

 

Microsoft.VisualStudio.Modeling.Diagrams.DisplayImageGetter displayImageGetter = new Microsoft.VisualStudio.Modeling.Diagrams.DisplayImageGetter(CompartmentImageProvider);

                            

                            

mappings[localCompartmentMappingsOffset+0] = new DslDiagrams::ElementListCompartmentMapping("DataMembers",                                     global::MyCompany.DataContractLanguage.DataMember.NameDomainPropertyId,

            global::MyCompany.DataContractLanguage.DataMember.DomainClassId,

            GetElementsFromDataContractForDataMembers,

            null, null, displayImageGetter);

 

Finally we can implement the "CompartmentImageProvider" method that is used in the delegate to get the image we need for our compartment item. In this demo implementation we stored the images in a resource file called "CompartmentImages" and assumed this resource file holds an image with the name “[shape name]Image”. Of course all of this can be changed; this is just for demoing purposes.

public System.Drawing.Image CompartmentImageProvider(Microsoft.VisualStudio.Modeling.ModelElement element)

{

      return (System.Drawing.Image)CompartmentImages.ResourceManager.GetObject(string.Format("{0}{1}", element.GetType().Name, "Image"));

}

Another thing to remember is that all manual changes in the "shapes.cs" will be lost after a "Transform all Templates" action so we either have to implement these changes in the shapes.tt template or use partial classes.

As you can see in the above screenshot, the end result of the above changes is a shape with icons on the left side of the compartment items, a shape that looks just like the shapes in the DSL designer, just the way I like it!

posted on 12/26/2006 1:05:13 AM UTC  #    Comments [0]
 Wednesday, December 20, 2006

Some time ago I started building a new Domain Specific Language for modeling message and data contracts. Building the DSL was pretty straight forward so it didn't take me too much time to build the beauty. However, during the debugging and testing phase of that DSL I noticed that the user experience of the DSL wasn't too good. For example, this particular DSL lets you model a data contract. Each data contract has a relation with one or more data members (implemented as compartment items) and for each data member you have to set its name, type, order and required properties. So, to add a data member to a data contract in my DSL I first had to do two right mouse clicks, after that I had to type the name of the data member, after that I had to switch to the properties windows and type the various values of the data members properties. This just didn't feel too good, especially when modeling a number of message and data contracts in a row. At that time I decided not to use the DSL, simply because of the, in my opinion, poor user experience.

Just recently, during some other Domain Specific Language related work I noticed again that I had some trouble getting the user experience right for modeling "relations" between model elements. Again, it was the same number of mouse clicks that bothered me (maybe it's just me?!). So, it was about time to try and find a solution for this "problem". I soon decided to build my own custom tool window specifically for my DSL but didn't know yet how to represent the "relational data" in that tool window. Luckily, in one of my talks with Jezz he came up with this brilliant idea to use the "VirtualTreeControl" (Microsoft.VisualStudio.VirtualTreeGrid.dll) for this purpose. He already used this control in the EFx Factory as you can see here. I have to be honest, this control is a real bitch to figure out, it isn't documented and I don't even know if it is officially supported but with some help of Jezz and a wrapper he built for it specifically for DSL relations, I got this working for my message-/data contracts DSL.

With this control you can show hierarchical domain relationships, and each row can have child rows, and you can display whatever columns of data you want from the relationships and domain classes.

As you can see in the picture below I can now maintain my "relational data", for my data contracts (in this case data members) in my custom tool window ("Data Contract Editor". I can easily add new data members and set their properties without having to switch between the mouse and keyboard over and over again. I think this control really rocks and I absolutely love its user experience.

The control is especially useful for exposing domain relations and domain classes which don’t have shapes or connectors on the diagram. For example, children of domain classes displayed in compartments. Therefore the control reduces shape ‘clutter’ on the diagram.

I like to consider tool windows and/or editing controls like this as "out of the box" features for future releases of the DSL Tools! In my opinion, it will dramatically improve the usage scenarios of DSL build with the DSL Tools.

posted on 12/20/2006 12:08:19 PM UTC  #    Comments [5]
 Thursday, October 19, 2006

For my current assignment, which is related to integrating existing and developing new Software Factories in our software development process, I decided to have a look at project GlidePath. According to the GlidePath website this project will deliver guidance on how to build software for Vista.  It delivers a web based repository of software factories that can loaded into the Visual Studio environment.  One of the very interesting features of GlidePath is the possibility to update the Software Factories over an RSS feed. It’s actually this feature that made me investigate GlidePath to see if we can use this or a similar approach in our own development process.

Once installed, you can use the Glidepath guidance package to create a Visual Studio solution structure. Instead of generating a full blown solution structure, like for example Service Factory does, Glidepath provides you with a rather empty solution.  At that moment the solution doesn’t reflect the actual product at all but rather provides you with the possibility to decide what factory to use in this solution structure (and thus what product to build?).  In this release of Glidepath you can only select one factory (MicrosISV factory) but I assume this will change in the future. Once I had added the MicroISV factory to my Glidepath solution I was surprised to see a lot of viewpoints popup in my solution structure (at this moment represented as .txt files).  From what I understood from Glidepath the idea behind these viewpoints is that you can select and configure them to specify how to build your product in the factory.  Glidepath will create new projects or enable packages (factories) in your current solution based on the viewpoints you configure for your product. Currently, Glidepath populates the MicroISV factory with viewpoints like “DataAccess”, “Deployment “, “Blogging”, “Legal”, etc.

Figure 1. Glidepath solution structure

After playing with Glidepath for a while I suddenly realized that I didn’t had a clue what kind of product I was actually building in my factory. I could see that my solution was populated with a project for “blogging” and project for “CSharp-WinForms-UX” because I selected these viewpoints for this solution.  However, from looking at the solution structure I wasn’t able to tell whether I was building a “blogging service”, a “blogging site” a “windows client for my blogging service” or whatever. Of course I understand this is related to this very early release of Glidepath and therefore lack of implemented packages, but I realized this was caused by the fact that the Glidepath factory doesn’t  have any notice (yet) about the product itself and therefore couldn’t tell me either what product I was building.

I was interested by this and tried to understand what this would mean for me if I had to implement (build a guidance package) one of the viewpoints for MicroISV. How would I know about the underlying product my viewpoint will be used on? Is it even necessary to have knowledge about that or can we generalize viewpoint implementations so they can be used on all products we are building? To be honest, I don’t have the answers for that at this moment.  My current thinking is that it would be helpful to have a formal description of the product I am implementing my viewpoint for but as said, I don’t have the answers yet.

A related question that interests me is: “what comes first?” Let’s say I was asked to build a factory for product X. Would I start with defining the viewpoints for my factory (security, deployment, etc.) or would I start by describing the basics of product X first? Or would I do this simultaneously?

Logically I would say, I first need a full picture of the product (product X) I am building the factory for.  Ideally, I would describe this product at a conceptual level (product model) in a way that makes this knowledge easily accessible and understandable for other people.  Once I know what I am talking about, and thus have understanding of the problem domain, I can decide what viewpoints are important, how to provide automated guidance for that, etc.

If we have captured the knowledge about the product we cannot only use this to author the factory but also to guide the factory user through the product at runtime. The factory can use the product model to communicate with the factory user in terms that make sense to the factory user and are related to the problem domain he is developing software for.

Currently Jezz and I are working on an experimental software factory authoring approach using a tool called the Factory Product Model (FPM).  I will not explain this approach or tool in detail in this post but if you are interested in more details you can read this, this, this and this post.

In this experiment, we are trying to validate whether a formal description (model) of the product the factory is building is a valid starting point for defining the factory and what it builds.

As far as I understand now, viewpoints will definitely play an important part in factory authoring and usage but what I am trying to find out is what impact they have and how they possibly relate to something like FPM.

I think specifying viewpoints is all about (some of) the requirements of the product we are building in the factory and therefore impact the type of guidance that is needed in the factory.

After all a viewpoint is what you get when you associate a work product, to an assets and a set of activities. Therefore viewpoints and work products are tightly related. It is just a question of which one do you define first?

I would be very interested in any ideas about this topic. What do you think? Do we need a product first approach (an FPM)? How does this relate to the Glidepath viewpoints approach I described? Do we need both? Do we need them in a specific order?

Let me know!

 

posted on 10/19/2006 6:26:06 PM UTC  #    Comments [0]
 Friday, October 13, 2006

Two days ago, my colleague Rene and I gave a presentation on an internal (Dutch) LogicaCMG event for developers about Software Factories. In this session we first covered some general Software Factory stuff and after that focused on Service Factory to demonstrate the power of this, what I call, first wave of software factories from Microsoft P&P.

 

In our timeslot we had to compete with three other sessions but we managed to get 160 developers/architects to attend our session. It turned out that, at least on paper; we had the most popular session! I am still not sure about the reason for that. Hopefully this is because the Software Factory topic is hot. Another possible reason for this is that we might have fooled people with the title of our presentation. We choose “Software Factories, how to get a SOA in one hour” as the title for our presentation. In Dutch SOA means “Sexueel Overdraagbare Aandoening” which corresponds to “Sexual Transmitted Disease” in English. (However, I can’t believe that people really think you need an hour to get yourself a “SOA”.)

 

Besides a little typo in the demo (which of course caused a compile error) the presentation went quite well. Luckily, we had a complete (working) solution prepared so we didn’t have to spend anytime during the presentation on trying to find the typo.

 

During our presentation we demonstrated how to write a service from scratch (within one hour) by using Service Factory. In our demo we also showed how to use this domain specific language integrated with Service Factory to overcome some of the “limitations” of the wizard based approach in Service Factory.

 

Based on the feedback I got after the presentation it turns out that people are really enthusiastic about Software Factories, Service Factory and the accompanying Microsoft tooling (GAT and DSL Tools). Hopefully, we managed to get people interested enough in this technology to make them download Service Factory today!

 

Below some pictures. As you can see we were wearing our cool "P&P shirts Don gave us at the last Service Factory workshop :-) 

 

 

posted on 10/13/2006 12:03:34 PM UTC  #    Comments [0]
 Tuesday, August 22, 2006

In a previous post I explained that Jezz and I are working together to prototype a different “approach” for authoring software factories.

In this experiment we are trying to validate this new approach based upon design ideas refined in the implementation of the EFX factory, and verifying that against the publicly available release of p&p Service Factory.

Basically, we think that we need to be able to let the factory author describe the ‘Product’ that is built by their factory at a higher abstraction level than we do now. We suspect that this approach will greatly help in improving the factory authoring experience and the factory user experience, which therefore simplifies software development as a whole.

Part of this experimental approach is describing the important concepts of the factory product in a so called “Factory Product Model (FPM)”. Below you can see a first attempt to model the Service Factory ‘Product’ in an experimental version of the FPM designer.

To make the example a little more realistic we introduced a few new concepts and made some assumptions.

For example we assumed it is possible to develop different type of services (entity services and process services) in Service Factory (there could well be others too). We did this to illustrate the concept of ‘Product Variants’. Which are basically one type of product the factory creates. Since a factory can create several variants of the product in its product line.

[Think of a ‘Product Variant’ as a very similar product but different in architectural definition, rather than something different in instance values of the concepts.]

Another assumption we made was that the difference between these services only reflects in the “service implementation” part. This is probably not completely true but we are only using these assumptions to simulate the situation where the factory enables us to build different family members of the service product line.

Figure 1. Factory Product Model for Service Factory 

The picture of the FPM for Service Factory shows us that we identified a “Product Variant” for each service type that is supported in (our imaginary) Service Factory. Also we identified the “System” product variant that makes it possible to group together any number of these services. We could have gone with one product variant for all types of services, but we wanted to define some that are different to validate the approach.

You can imagine then, that each product variant would be represented to the factory user as a separate solution template offered to them when they create a new solution using this factory. (In this case we would have 3 solution templates: ‘Entity Service’, ‘Process Service’ and ‘System’.

Looking at the concepts in the model, one interesting thing is the “Service Contract” concept; the (green) concept we are using, reflects that we will be using a custom Domain Specific Language for modelling Service Contracts in our factory. This custom DSL for modelling service contracts is responsible for modelling all the concepts that are defined within the “Service Contract” shape in the Service Factory FPM. This kind of model is called a Work Product Model (WPM), since it defines work products of the FPM. The child concepts of the ‘Service Contract’ concept will be refined in this WPM, and are represented here for logical structure.

The other concepts in the Service Factory FPM reflect common terms used in the Service domain that are therefore part of Service Factory. The concepts in this FPM will be represented to the factory user as a mechanism to “drive’” the factory. This view provides the user with a higher level abstraction than the current “Solution Explorer” view that is used in today’s factories. So instead of being confronted with all the technical details he can develop his services by using concepts that make sense to the service domain.

Figure 2. Example of the Service Factory Product Explorer

To make all of this happen, the next step would be mapping each concept in the FPM to physical solution structure, projects, and project items of Service Factory. Once that is complete, we define the assets (recipes, templates, designers, etc.) that will be used to create and configure these physical artefacts. Once configured correctly, the FPM is then used as a starting point for populating the factory schema for this factory. It already contains the definitions of all the work products, their assets.

Another idea we would like to validate in this experiment is the speculation that we can use the concepts modelled in the FPM to use as reusable parts in other factories. It would be great if we could find a way to just “query” this FPM (and/or factory schema) of a factory, and select the available concepts that we want to use to compose other factories from. You could imagine in this case that the ‘ServiceContract’ concept is self-contained enough to be reused in another factory (complete with DSL model and definitions).

posted on 8/22/2006 8:20:40 AM UTC  #    Comments [3]
 Tuesday, August 15, 2006

Interested in Software Factories and trying to understand the common terms uses in this pace? Have a look at this Software Factory ABC at Jezz's blog. Please leave a comment if you have anything to add/change and we will be happy to update the list!

posted on 8/15/2006 8:28:54 AM UTC  #    Comments [0]
 Thursday, August 10, 2006

In an earlier post I promised to share some more details about integrating DSL Tools with GAT. I am using some of the “techniques” in this post to experiment with integrating our Service Description Language with Service Factory.

 

As far as I know there are two possible approaches for integrating DSL Tools with GAT. In the first approach we simply execute GAT recipes from with the DSL Tools and pass the necessary arguments (we collect from the DSL model) to the recipe in the “execute call”. In the second approach we create “value providers” that are able to read the DSL model (selected shape, model root, etc.) and can be used directly in the recipe definition (“ValueProvider” tag) in GAT. It’s obvious that the second approach offers a more solid solution. For my experiment I tried both approaches. To be honest I don’t expect that I need my “experimental code” for too long. I can’t believe that Microsoft isn’t going to make something available to support this “out of the box”. This post of Mauro indicates that I might be rightJ.

 

Let’s have a look at the first approach and execute the “GenerateASMXDataContractFromSchemas” recipe from the “ASMXGuidancePackage” from the DSL message shape to generate the datatypes for all DataContracts modelled in the message shape of the DSL. The screenshot from this example can be found in this post.

 

Experimental hive

Before we start we have to make sure that the DSL isn’t using the “Exp hive”. GAT is registered in the “main hive” so we have to use the same hive both the DSL Tools and GAT for our integration experiment.

 

I did this by changing the .csproj files for the “DSL” project and the “DSLPackage” project.

 

In the “Dsl.csproj” file I deleted the “/rootsuffix Exp” from the <StartArguments> tag


 

                <StartArguments>/rootsuffix Exp /DesignTimeRun "..\..\..\Debugging\Debugging.sln"</StartArguments>

 

 

In the “DslPackage.csproj” I did the same action and also deleted “Exp” from the “<TargetRegistryRoot>”

 

 

         <TargetRegistryRoot>Software\Microsoft\VisualStudio\8.0Exp</TargetRegistryRoot>

 

 

Service Factory Guidance Packages

Of course we need to debug the new code for calling recipes in our DSL. To make sure the GAT packages are enabled for the “DSL debugging solution” I created a new solution based on the “ASMX Service” template of the “Web Service Software Factory” package. After that I changed the “debugging solution” for the DSL by replacing “Debugging\Debugging.sln” in the “<StartArguments>” tag in both project files with the correct path and name of the new solution based on the “ASMX Service” template.

 

After making the above described changes, the newly created Service Factory solution opens up as the debugging solution (in a new VS2005 instance) for our DSL. So, now we are ready to write some code to actually call the GAT recipes from the DSL.

 

 

Reference RecipeFramework dll’s

To make the code compile we need to reference the “Microsoft.Practices.RecipeFramework.dll” and the “Microsoft.Practices.RecipeFramework.Extension.dll” from the DslPackage project. The “Extension” dll is part of Service Factory and doesn’t have a strong name. To solve this issue we can open the “ASMX Guidance Package.sln” located in “C:\Program Files\Microsoft Service Factory” (default location), sign the extension project and compile it.

 

  

Code

To make the code work we need the following using statements:

 

using Microsoft.Practices.RecipeFramework.Services;

using Microsoft.Practices.RecipeFramework.Extensions.CommonHelpers;

 

I assume the code stated below is coded in the “OnMenu…” method for a custom command for one of the shapes in the DSL. Please not that the code example is just demo code!

 

 

EnvDTE.Project dataTypeProject = null;

Hashtable arguments = new Hashtable();

           

EnvDTE.DTE dte = this.CurrentDocData.Store.GetService(typeof(EnvDTE._DTE)) as EnvDTE.DTE;

 

IRecipeManagerService recipeManager = (IRecipeManagerService)this.ServiceProvider.GetService(typeof(IRecipeManagerService));

 

GuidancePackage serviceFactory = recipeManager.GetPackage("CustomASMXGuidancePackage");

          

EnvDTE.Project serviceProject = DteHelperEx.FindProjectByName(dte, "Service", false);

 

foreach (ProjectItem project in serviceProject.ProjectItems)

{

    if (project.Name.Contains("DataTypes"))

    {

        dataTypeProject = (EnvDTE.Project)project.SubProject;

    }

}

 

In this first code snippet we can see that get a reference to the Visual Studio infrastructure. After that we get a reference to the “RecipeManager”. We will use this reference to instantiate the Service Factory Guidance Package. On my machine this is called “CustomASMXGuidancePackage”. This is because I already made some other modifications in the package.

 

The recipe that I am using in this example needs a reference to the Service Factory “DataType” project to execute correctly. We can use the “DteHelperEx” class located in “Microsoft.Practices.RecipeFramework.Extension.dll” to help with that. Unfortunately I wasn’t able to get a reference to this “DataType” project directly. This is probably because the project is located under the “Service” solution folder in the Service Factory solution structure. I didn’t take the time to investigate this any further so I took another approach for this demo code.

 

First I get a reference to the “Service” Solution folder which of type EnvDTE.Project. After that, I iterate over the ProjectItems in the “Service” solution folder to get a reference to the “DataTypes” project.

 

 

// Add DSL DataContract's to Service Factory DataType Project

Message message = ((MessageShape)this.SingleSelection).ModelElement as Message;

 

if (message != null)

{

    foreach (DataContract dataContract in message.DataContracts)

    {

        if (DteHelperEx.FindItemByName(dataTypeProject.ProjectItems, Path.GetFileName(dataContract.SchemaLocation), true) == null)

        {

            dataTypeProject.ProjectItems.AddFromFileCopy(dataContract.SchemaLocation);

        }

    }

 

}

                      

arguments.Add("DataContractsProject", dataTypeProject);

 

serviceFactory.Execute("GenerateASMXDataContractFromSchemas", arguments);

 

In the second code snippet we can see that we get a reference to the selected message shape in the model, iterate over all the data contracts in the message to add the XSD files that describe the datacontract to the “DataType” project (if not already added). The XSD files are referenced in a “SchemaLocation” property for the DataContract in the DSL.

After that we add the reference to the “DataType” project, needed as an argument for the recipe, to the Hashtable named “arguments”. You can find the necessary arguments for the recipe in the xml file that the recipe is defined in. In this case “GenerateASMXDataContractFromSchemas.xml” (located in “C:\Program Files\Microsoft Service Factory\Guidance Packages\ASMX Guidance Package\ASMX Guidance Package\Recipes\ASMX”). The last line of the code snippet finally executes the recipes on the instance of the guidance package.

 

Of course in this very simple example we are only sending one argument to a recipe that doesn’t have a “wizard form” attached to collect the values for the arguments. But the same approach can be used for recipes that do include wizard forms. However in that case it might not make sense to just display the values that are passed from the DSL to the recipe wizard form and ask the user to press the “Next” button on the wizard form.

 

For that situation it might be better to modify the recipe and/or write a value provider that can be used to read the DSL model values directly from the recipe. In a next post we will have a look how we can change a Service Factory recipe to make use of a custom build value provider that reads the DSL model.

 

[Update: added missing link]

posted on 8/10/2006 7:51:38 PM UTC  #    Comments [1]