"Translation Exercises" Windows Workflow Foundation Program Development-Chapter 03

Source: Internet
Author: User

1.2.2.Visual Studio 2005 Expansion pack

Microsoft also provides visual Studio 2005 expansion packs for Windows Workflow developers. The expansion pack integrates many features into Visual Studio, including a visual designer for working with workflows. Here is a screenshot of the visual designer.

The window style of this designer is consistent with the Windows and Web Form designers that we are familiar with. the Toolbox window lists all the activities that you can drag and drop onto the designer table. We can also add custom activities to the Toolbox . Once an activity is placed on the designer table, theProperties window lists the activity's configurable properties and the handling events. is the Toolbox window .

1.2.2.1. Windows Workflow and XAML

The WF Designer is able to represent our workflow with its generated C # and Visual Basic code. This designer is also able to read and write Extensible Application Markup Language (abbreviated as XAML, read as Zammel). XAML files are legitimate XML files. XAML is a declarative programming model that is brought to Windows workflow. Here is the XAML markup code generated by the designer for the workflow we saw earlier:

<sequentialworkflowactivityxmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/workflow"x:class= "Helloworld.hellowworldworkflow"   >   <CodeActivityx:name= "CodeActivity1"Executecode= "Codeactivity1_executecode_1" /></sequentialworkflowactivity> 

Our workflow is simple and contains only one activity-a codeactivity activity. When the workflow engine executes this codeactivity activity, CodeActivity invokes a method specified in the Executecode property. Special XML namespace directives are also included in our XML markup code. The 2nd chapter describes the XAML and these namespaces.

XAML is not a specialized technology for Windows workflow. As a "extensible application" markup Language, XAML is also used in Microsoft's rendering framework--windows Presentation Foundation (WPF). In WPF, XAML builds a rich user interface declaratively, which includes not only buttons and labels, but also animated storyboards and data templates.

One of the key capabilities of declarative XAML is the ability to define a partial class (partial classes) together with imperative code. The partial class is a new feature provided by. NET 2.0, which can be used in Visual Basic and C #. Partial classes allow a class to be defined in multiple files. The above XAML markup code will be converted to a partial class named Helloworldworkflow. We control the name of this class with the x:name attribute in the root node of the XAML markup code. We can add members to this class in C # code, provided that the class defined in C # is also called Helloworldworkflow, and the partial keyword is used.

 Public Partial class helloworldworkflow:sequentialworkflowactivity{    privatevoid codeactivity1_ Executecode_1 (object  sender, EventArgs e)    {          //  ...     }}

In this example, we add a new member to the Class (Helloworldworkflow) defined by the XAML markup code: the Codeactivity1_executecode_1 method.

1.2.2.2. WF Validation and debugging

Another feature of the Workflow designer is the validation of each activity in the workflow and the display of the results to the developer. Each activity can define its design-time and run-time validation. If validation of an activity fails, the designer displays a dot with a red exclamation point on the activity. For example, for a codeactivity activity, suppose we do not assign a value to the Executecode property, it will always display a red exclamation point. If no method is called during execution, this codeactivity activity is a device, fortunately validation can find the problem for us as soon as possible and give obvious hints.

The Workflow Designer also provides debugging capabilities for developers. We can set breakpoints in the designer for an activity. When the workflow pauses execution at the breakpoint, we can view the activities that have been performed in the workflow instance in the Call Stack window. Debugger commands:stepin (statement-by-sentence),stepout (jump out) and stepover (procedure-by-process) operate in an intuitive manner, for example, when performing to a composite activity, use the step in command, it goes inside the activity and is ready to execute its first child activity, and when the Step over command is used, the entire composite activity is executed and ready to execute the next activity immediately thereafter.

1.2.2.3. Designer Skins

The Workflow Designer allows us to customize its design countertops with the theme (themes). A theme contains definitions of background color, font, gridlines, and border styles for the design countertop. We can even choose a color and border style for a specific type of activity. With Visual Studio, we can create a new theme or modify an existing theme.

However, all of these look-and-feel customizations don't just make the designer look beautiful. The WF Designer is a component that we can host in our own application software development. This ability to load designers gives us a great deal of room to play. First, we can host the designer so that non-developers (that is, business people) can design and modify the workflow. Second, by customizing activities, we can build workflows in a way that business people are easy to understand (this is called "domain-specific language"). Also, by customizing the theme, we can keep the designer's appearance consistent with the entire application.

Chapter Links:

"Translation exercises" development of Windows Workflow Foundation program

"Translation exercises" development of Windows Workflow Foundation Program-Preface


"Translation Exercises" Windows Workflow Foundation Program Development-Chapter 01

"Translation Exercises" Windows Workflow Foundation Program Development-Chapter 02

"Translation Exercises" Windows Workflow Foundation Program Development-Chapter 03

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.