Printing collection items
In this task, we will customize an activity that can print all collection items to Console Application.
How to do it
Create a Workflow Console Application:
Create a new Workflow Console Application and name it
PrintingCollectionItems
.Create an Activity that can print collection items to the Windows Console:
Add a new Code Activity to the project and name it
CollectionPrinter.cs
. Refer to the following screenshot:Open the
CollectionPrinter.cs
file and alter the code as follows:using System; using System.Collections.Generic; using System.Activities; namespace PrintingCollectionItems { public sealed class CollectionPrinter<T> : CodeActivity { public InArgument<ICollection<T>> CollectionInArg { get; set; } protected override void Execute(CodeActivityContext context) { ICollection<T> collection = CollectionInArg. Get<ICollection<T>>(context); if (collection.Count > 0) { Console.WriteLine("---Print Collection Start--...