Related Activities


Several activities rely on conditions and/or rules to function properly. This section discusses each out-of-the-box activity included in Windows Workflow Foundation.

The IfElse, While, Replicator, and ConditionedActivityGroup Activities

The IfElse, While, Replicator, and ConditionedActivityGroup activities can use code conditions or declarative rules to specify their conditional expressions. The IfElse and While activities have a property called Condition; the Replicator and ConditionedActivityGroup activities have a property called UntilCondition. Both of these properties are of the type ActivityCondition. Although this class is abstract, it has two derived classes that you can use to specify a condition: CodeCondition and RuleConditionReference.

As discussed earlier in this chapter, CodeCondition is a pointer to a method that sets a value in the ConditionalEventArgs instance passed to the method. RuleConditionReference is also a pointer, but to a declarative rule stored in the workflow’s .rules file.

When you’re setting the conditional properties in Visual Studio, you must first choose which condition class to use. Then, depending on your choice, you must specify the conditional expression.

If you choose CodeCondition, you must set its Condition property to an already-defined method with the signature void Condition(object sender, ConditionalEventArgs e).

If you use RuleConditionReference to specify a conditional expression, Visual Studio provides a UI to select or create a new declarative rule in the workflow’s rules store. To use this UI, select Declarative Rule Condition from the activity’s conditional property. The ConditionName property becomes available and exposes an ellipsis button. Click this button to display the dialog box shown in Figure 9-1. From here, you can select an existing declarative rule or create a new one by clicking the New Condition button. As you can see, this dialog box displays all declarative rules that have already been defined in the workflow’s .rules file.

image from book
Figure 9-1

Creating a new declarative rule or editing an existing rule displays the dialog box shown in Figure 9-2. This dialog box enables you to define the IF portion of a rule using the same syntax described earlier in this chapter.

image from book
Figure 9-2

The advantage of using rules over code conditions is that you can modify declarative rules during runtime, which you cannot do with code conditions.

Policy

The Policy activity harnesses the power of rule sets. This activity pertains to conditions as well as the actions associated with each rule. You place a Policy activity within a workflow to point to a rule set reference (see Figure 9-3). When the activity is executed, it evaluates each rule in the set while executing the appropriate actions.

image from book
Figure 9-3



Professional Windows Workflow Foundation
Professional Windows Workflow Foundation
ISBN: 0470053860
EAN: 2147483647
Year: 2004
Pages: 118
Authors: Todd Kitta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net