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 219<br />

WorkflowInstance instance =<br />

workflowRuntime.CreateWorkflow(typeof(SecondWorkflowApp.Workflow1),parameters);<br />

}<br />

}<br />

instance.Start();<br />

waitH<strong>and</strong>le.WaitOne();<br />

Now that you’re passing parameters to the workflow, the workflow has to know how<br />

to accept them—<strong>and</strong> it does this using the .<strong>NET</strong> property model. If you look at the preceding<br />

listing, you’ll see that a parameter called age is used. Thus, you’ll need to have a<br />

settable age property in your workflow. You can do this by adding some simple code to<br />

Workflow1.designer.cs:<br />

partial class Workflow1<br />

{<br />

}<br />

private int ageVal=0;<br />

public int age<br />

{<br />

set { ageVal = value; }<br />

}<br />

private CodeActivity codeActivity2;<br />

private IfElseBranchActivity ifElseBranchActivity2;<br />

private IfElseBranchActivity ifElseBranchActivity1;<br />

private IfElseActivity ifElseActivity1;<br />

private CodeActivity codeActivity1;<br />

This code has a private variable that is used to store the age, <strong>and</strong> a public settable<br />

one that maps whatever comes into the private variable.<br />

The next step is to add the workflow activities. For this application, you are going to<br />

implement an IfElse activity driven off a simple rule. If the entered age is over 100, you<br />

will go down one activity route; otherwise you will go down another.<br />

Drag an IfElse activity onto the design surface. The Designer should look like<br />

Figure 9-7.

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

Saved successfully!

Ooh no, something went wrong!