What is the best method to iterate through each "path" on a flowchart? (I used this post to start:
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/0218a527-4487-4745-801b-c02eadc20a27/#97ccdead-6833-440d-8401-4c7384cbab91)For example I have several nodes on the FlowChart, including FlowDecisions and FlowSwitches, and I want to ensure that every path ends on a "ICompletionActivity" (interface implemented by me and attached to a custom activity which completes all the database commits, deletes etc).
So far I have tried the following (passing in the FlowChart itself as a modelItem):
public IList<ValidationErrorInfo> CheckForCompletionActivity(ModelItem modelItem)
{
IList<ValidationErrorInfo> validationErrors = new List<ValidationErrorInfo>();
if (modelItem.View != null)
{
ModelItemCollection flowChartNodes = modelItem.Properties["Nodes"].Collection;
ModelItem lastNode = flowChartNodes.Last();
if (!CheckLastActivityIsCompletionType(lastNode))
{
ValidationErrorInfo error = new ValidationErrorInfo("No completion activity found on " + modelItem.ToString() + " activity.");
validationErrors.Add(error);
}
}
ShowValidationErrors(validationErrors);
return validationErrors;
}
private bool CheckLastActivityIsCompletionType(ModelItem modelItem)
{
if (modelItem != null)
{
return modelItem.ItemType == typeof(ICompletionActivity);
}
return false;
}
I starting by using flowChartNodes.Last() to get the last activity, but I assume that will give me the last activity added to the designer canvas?