Freigeben über


Rules and Conditions Overview

Windows Workflow Foundation can implement business logic as either rules or conditions. Conditions are used by IfElseBranchActivity, ConditionedActivityGroup, WhileActivity, and ReplicatorActivity activities to control activity execution. Conditions can be expressed as declarative, or defined in code. Declarative conditions are created as code DOM statements in the rules' XML file. Code-based conditions reference a method in the workflow's code file that returns its result through the Result property.

Rules, like conditions, are expressed as code DOM statements, and are collected in the rules XML file. Rules include a condition statement and collections of actions that are performed based on the result of the condition. Rules are collected into rule sets, which support both simple sequential execution of rules, and sophisticated forward-chaining of rules. Rule sets are executed by the PolicyActivity activity.

A key advantage of defining your logic with rules and declarative conditions is that they can be modified at run time by doing dynamic updates using workflow changes. In addition, rules let you separate your business logic from a workflow in order to share those rules with other workflows. Finally, defining business logic in rules allows for advanced tools, such as dependency visualization and impact analysis tools, to be built on top of the object model.

For more information about conditions, see Using Conditions in Workflows; for information about rules, see Using RuleSets in Workflows.

See Also

Concepts

How to: Use Conditions Through Code
Using the PolicyActivity Activity

Other Resources

Windows Workflow Foundation