private void BuildActivities(DocX body, List<ActivityWrapper> rootActivities) { for (int i = 0; i < rootActivities.Count; i++) { ActivityWrapper wrapper = rootActivities[i]; if (wrapper.IsRoot) body.DocumentRootActivity(wrapper.Name); else body.DocumentCompositeActivity(wrapper.Name); var activityDetails = wrapper.GetActivitySpecificDetails(_rulesExtractor.RuleDefinitions); body.DocumentDescription(wrapper.GetDescription()); body.DocumentPlaceholders("Placeholder for Workflow Snapshot"); body.DocumentDependencies(wrapper.GetDependentList().ToCsv()); body.DocumentPlaceholders("Placeholder for Code/UI Snapshot"); body.DocumentDescription(activityDetails); if (wrapper.Children.Count > 0) // has some child activities { // composite activity with children for (int childCount = 0; childCount < wrapper.Children.Count; childCount++) { ActivityWrapper childActivity = wrapper.Children[childCount]; if (LevelToBeCaptured == -1) { DocumentActivity(body, childActivity); BuildActivities(body, childActivity.Children); } else // check for level { if (childActivity.Children.Count > 0 && childActivity.Path.Split('.').Length <= LevelToBeCaptured) { DocumentActivity(body, childActivity); BuildActivities(body, childActivity.Children); // composite activity with children } else if (childActivity.Children.Count > 0 && childActivity.Path.Split('.').Length > LevelToBeCaptured) // gone till 3rd level, so just document this { DocumentActivity(body, childActivity); } } } } } }