08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 9 ■ .<strong>NET</strong> 3.0: WINDOWS WORKFLOW FOUNDATION 221<br />

Adding a code condition allows you to specify a function that will fire off to evaluate<br />

the condition, <strong>and</strong> a declarative rule allows you to specify a simple rule. In our case, we’re<br />

just using a very simple rule, so choose this option. Next, notice that the ConditionName<br />

is given a red alert because it isn’t yet set. Change this field to a good name for the rule,<br />

such as ageOver100.<br />

Once you’ve done this, notice that the alert moves to the ConditionExpression field,<br />

as you haven’t yet defined it. Click the ellipsis button (. . .) <strong>and</strong> the Rule Condition Editor<br />

will open (see Figure 9-9).<br />

Figure 9-9. Adding the rule condition with the editor<br />

Enter the rule this.ageVal > 100, as shown in Figure 9-9. You’ll notice that you have<br />

full IntelliSense, which is a nice touch.<br />

Click OK <strong>and</strong> the Rule Condition Editor will close, entering the rule into the<br />

Expression property. You’ll also notice that the IfElse node on the Designer now has<br />

no alerts, so it is configured correctly.<br />

Drag a Code activity to the left branch of the IfElse. This is the path that the sequence<br />

will follow if the rule is met (i.e., if the age is over 100). Use the procedures you followed<br />

earlier to add an ExecuteCode function to it, <strong>and</strong> put this code in that function:<br />

private void codeActivity1_ExecuteCode(object sender, EventArgs e)<br />

{<br />

Console.WriteLine("You say you are " + this.ageVal<br />

+ " years old I don't believe you!");<br />

Console.ReadLine();<br />

}<br />

Repeat this process for the right-h<strong>and</strong> branch of the IfElse activity. When you get to<br />

the Properties dialog, wire up the ExecuteCode function as before <strong>and</strong> then add the following<br />

code to it:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!