Simple Policy

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

This sample shows how to use a PolicyActivity activity in a workflow.

The sequential workflow in this sample is created by using a PolicyActivity activity. The workflow defines orderValue, customerType, and discount fields that are used to define a product discount workflow. The rules defined in the rules file set a discount value that is based on the orderValue and customerType. The orderValue and customerType are set in the SimplePolicyWorkflow class definition and can be changed to alter the behavior. The resulting discount is written to the console in the WorkflowCompleted event handler that is defined in the SimplePolicyWorkflow class.

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 SimplePolicy\bin\debug folder (or the SimplePolicy\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.
Ee960218.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\Policy\SimplePolicy

See Also

Reference

RuleSet
PolicyActivity

Other Resources

Advanced Policy
Using the PolicyActivity Activity
Using Conditions in Workflows
Tutorial: Use Rules and Conditions
Activities Samples
Windows Workflow Foundation Samples