Extension method to find root Parent Workflow of current activity

Below is an extension method  to find root Parent Workflow of current activity
  /// <summary>
  /// Get root Parent Workflow of current activity
  /// <param name="activity"></param>
  /// <returns></returns>
  public static Activity FindRootWorkflow(this Activity activity)
  {
   List<string> list = new List<string>();
   Activity act = activity;
   while (act != null)
   {
    if (act.Parent==null)
    {
     return act;
    }
    act = act.Parent;
   }
   return null;
  }
 
It was  asked in MS Connect Suggestion "Activity to access Parent workflow or Root Workflow"
 


 

posted @ Friday, July 23, 2010 6:01 PM
Print

Comments on this entry:

# re: Extension method to find root Parent Workflow of current activity

Left by Ryan at 7/23/2010 11:29 PM
Gravatar
Or in recursive form:

public static Activity FindRootWorkflow(this Activity activity)
{
var parent = activity.Parent;
return parent == null ? activity : FindRootWorkflow(parent);
}

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«May»
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789