Condividi tramite


Workflow 4.0 Templates - Beta1

As Visual Studio 2010 Beta1 is released, let’s take a quick walkthrough of the Workflow templates we are providing for the new Windows Workflow Foundation (WF) model provided in the System.Actvities.* namespace (for brevity, I'll use WF 4 to refer to workflows to refer to WF workflows from this namespace).

Opening Visual Studio and the New Project Dialog, click on the Workflow tab under Visual C# or Visual Basic. You would notice the following Project Templates for Workflow.

clip_image002

Lets take a quick look at each of them,

The Activity Designer Library provides a way for the user to create a custom activity designer. It is essentially a WPF User Control with the base class being WorkflowElementDesigner which is the base class for the activity designers. As you would see below, the designer shows the root/default activity designer provided through the WorkflowElementDesigner. Users creating the custom activity designer can start with this base template designer to create designers as needed.

clip_image004

Next, the Activity Library template provides a way for the users to create custom activities. It contains the root activity Xaml file where the users can drag drop existing activities on the canvas and compose them to create new custom activities – purely declaratively. Alternately the user can choose to create custom activities by providing its execution logic through imperative code. We provide a pre-built Item template ‘Workflow Element’ for creating a code based activity. The two Project and item Templates are as follows:

clip_image006

clip_image008

Moving on, the next two Project Templates are the Sequential Workflow Console Application and the Flowchart Workflow Console Application. As the name suggests they provide different workflow authoring styles wrapped within the root activity which can then run through the host provided in the Program.cs file.

In essence, there is no difference between the activities we created through the Activity Library and the Workflows we author through the Console Application. The root for both of them is <Activity>. So it is possible that you can take the Activity Library created activities and run them directly through the host provided in any of the console applications. The only reason we have provided the Sequential and Flowchart templates is because we think of them as the common modeling/authoring styles that users would adopt while creating their workflow applications. They have been created as Console applications so that we can provide users with a quick F5 experience for unit testing purposes. As any other project, Library and Console Applications can be switched to the other one through their Project Properties pages.

Now, lets talk a bit about the Item Templates. The users can add pre-existing templates as items to their projects through the Add new Item option available in the context menu for the project. The Item Templates under the Workflow node for Visual C# or Visual basic are:

clip_image010

Flowchart, Sequence and Activity and Activity Designer are self-explanatory. In addition, we also provide a few item templates for Workflow Services. They are the Declarative Flowchart Service and the Declarative Sequential Service. As the name suggests, they are the workflow services containing the messaging activities wrapped within the Sequence or a Flowchart. You would also notice that the extensions with these workflow service files is Xamlx. This is because when the services are deployed onto IIS, the right workflow specific httpHandlers can be invoked (WPF already registers Xaml as the extension, so we needed a new extension to invoke our HttpHandlers)

As you would notice below, the Xamlx file here contains the Receive and a SendReply activity configured for a simple message receive and reply back. Like the ASP.NET model, these files don’t need to be compiled and can be directly deployed onto the IIS/web server. For a seamless deploy/publish experience, we have also provided the equivalent Declarative Sequential Service Library and the Declarative Flowchart Service Library Project Templates. These templates are the Web templates with options to Package and Publish available for deploying the services. These options are exactly similar to the ASP.NET web services available.

clip_image012

One question that must be coming to your mind is what happened to the WF 3 workflows (workflows created using the System.Workflow.* namespace)? Can we still create workflows using them? The answer is Yes! To start your workflow applications using WF 3, in the New Project Dialog, change the Target Framework to 3.0/3.5 to see the Workflow 3.0/3.5 templates.

clip_image014

Selecting these templates would get you started with the WF 3 workflows.

clip_image016

The Item Template in this case would now be for WF 3 as well.

You can also create WF 3 projects with .NET Framework 4 using the Project Properties pages and changing the Target Framework Version.

That was a quick walkthrough of the project and item templates we’ve provided to you in Visual Studio 2010 Beta1. We’re very interested in hearing your feedback. Specifically, would you like more/less templates? Did the names of the templates make intuitive sense and helped you pick the right now? Were they discoverable on the New Project dialog?

Comments