Reputation: 2008
I was wondering, how to get an Id for a simple activity. For example:
Sequence s = new Sequence();
string id = s.Id;
The id is always null and as it has a private Setter I cannot set this value.
Under which circumstances will this value be filled with an Id and by whom?
Thanks a lot for your answers.
Upvotes: 0
Views: 440
Reputation: 101
You may use WorkflowInspectionServices to list activities from the root activity. When using WorkflowInspectionServices, the ids are set.
With a recursive function like this one :
void WriteActivities(Activity p_activity, int p_offset)
{
Console.WriteLine("{2}Activity : {0}, {3} ({1})", p_activity.Id, p_activity.GetType().Name, new String('-', p_offset), p_activity.DisplayName);
IEnumerable<Activity> l_activities = WorkflowInspectionServices.GetActivities(p_activity);
foreach (Activity l_childActivity in l_activities)
{
WriteActivities(l_childActivity, p_offset + 1);
}
}
Upvotes: 0
Reputation: 27632
The ID is set when you use the WorkflowDesigner or at runtime. But even then it can be tricky to work with because it can take on a different form in the WorkflowDesigner depending on how you load the workflow.
Upvotes: 2