// These properties map to the names within the Dictionary object.
public string ErrorMessage { get; set; }
public int NameLength { get; set; }
private void GetAndValidateUserName(object sender, ConditionalEventArgs e)
{
Console.Write("Please enter name, which much be less than {0} chars: ",
NameLength);
UserName = Console.ReadLine();
// See if name is correct length, and set the result.
e.Result = (UserName.Length >= NameLength);
}
private void NameNotValid(object sender, EventArgs e)
{
Console.WriteLine(ErrorMessage);
}
...
}
Beyond the fact that you have added two new automatic properties, notice that the
GetAndValidateUserName() method is now checking for the length specified by the NameLength prop-
erty, while the error message prints out the value found within the ErrorMessage property. In both
cases, these values are determined via the Dictionary object passed in at the time the workflow
instance was created. Figure 26-10 shows some possible output for this modified example.
Figure 26-10.
The workflow in action, now with custom parameters
Do'stlaringiz bilan baham: |