IfElse With Rules

This topic applies to Windows Workflow Foundation 4 (WF4).

This sample shows the use of a rule condition with an IfElseActivity activity.

The sample passes in an OrderValue parameter from the host. The value of the parameter is used in a rule condition on the first branch of the IfElseActivity activity. If the value is less than 10,000, the first branch executes, and the CodeActivity activity in the first branch prints Get Manager Approval to the console. If the value is greater than 10,000, the CodeActivity activity in the second branch executes and prints Get VP Approval.

To build the sample

  1. Open the solution in Visual Studio 2010.

  2. Build the solution by pressing CTRL+SHIFT+B.

  3. Run the solution without debugging by pressing CTRL+F5.

To run the sample

  • In the SDK Command Prompt window, run the .exe file in the IfElseWithRules\bin\debug folder (or the IfElseWithRules\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.
Ee960224.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing:

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory:

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Rules\IfElseWithRules

See Also

Reference

System.Workflow.Activities.Rules
IfElseActivity
CodeActivity
RuleDefinitions

Other Resources

CodeDOM Types Supported by Windows Workflow Foundation
Using Conditions in Workflows
Using Rule Conditions in Workflows
Using Conditions through Code
Rules and Conditions Samples