Last week during my webinar, I wasn't sure how to use the EnumerateResources or EnumerateResourceIteration activities. I thought I'd tie up some loose ends and try to crack this case.
Thanks to Henrik and Nima, I was able to get the EnumerateResourcesActivity to work. Turns out that the Iteration activity will be removed from RTM.
Per Henrik's advice, EnumerateResources has the wrong designer, so when you add the activity to a custom workflow, you'll notice that it's closed and you can't add any children to it.

You can work around this by opening the Designer.cs file and adding a code activity to it manually. First, add a CodeActivity to the class:
private CodeActivity codeActivity1;
Next, add the code activity to EnumerateResources in InitializeComponent,
before the last line, "this.CanModifyActivities = false;".
#region Workaround
this.codeActivity1 = new System.Workflow.Activities.CodeActivity();
this.codeActivity1.Name = "codeActivity1";
this.codeActivity1.ExecuteCode += new System.EventHandler(this.logIteration);
this.enumerateResourcesActivity1.Activities.Add(this.codeActivity1);
#endregion
Then, create a "logIteration" method in your main class file, and call the GetCurrentIterationItem method from EnumerateResources:
private void logIteration(object sender, EventArgs e)
{
StringBuilder buffer = new StringBuilder();
buffer.AppendLine("TotalResultsCount : " +
enumerateResourcesActivity1.TotalResultsCount);
ResourceType currentItem = EnumerateResourcesActivity.GetCurrentIterationItem(
(CodeActivity)sender) as ResourceType;
if (currentItem != null)
{
foreach (KeyValuePair<string, ResourcePropertyInfo> property in currentItem.ResourceProperties)
{
buffer.Append(property.Key.PadRight(20));
buffer.Append(property.Value.Type.PadRight(20));
object val = currentItem[property.Key];
if (val != null)
{
buffer.AppendLine(val.ToString());
}
else
{
buffer.AppendLine();
}
}
}
string output = buffer.ToString();
}
That's it. Don't forget to bind the XPathFilter property on the EnumerateResourcesActivity. Perhaps I'll add an example to our activity library.
Enjoy!