private void DocumentActivity(DocX body, ActivityWrapper childActivity)
 {
     body.DocumentLeafActivity(childActivity.Name);
     body.DocumentDescription(childActivity.GetDescription());
     body.DocumentPlaceholders("Placeholder for Workflow Snapshot");
     body.DocumentDependencies(childActivity.GetDependentList().ToCsv());
     body.DocumentPlaceholders("Placeholder for Code/UI Snapshot");
     body.DocumentDescription(childActivity.GetActivitySpecificDetails(_rulesExtractor.RuleDefinitions));
 }
/*
 *      private static string FormatUserData(System.Collections.IDictionary iDictionary)
 *      {
 *          var builder = new StringBuilder();
 *          foreach (var key in iDictionary.Keys)
 *          {
 *              builder.AppendFormat("Key: {0}    Value: {1}", key, iDictionary[key] ?? "-").AppendLine();
 *          }
 *          return builder.ToString();
 *      }
 */

        private static string Translate(ActivityWrapper activityWrapper, string inputFromTemplate)
        {
            var             regEx           = new Regex("[$](?<props>[a-zA-Z0-9]*)");
            MatchCollection matchCollection = regEx.Matches(inputFromTemplate);
            string          output          = inputFromTemplate;

            for (int matchCounter = 0; matchCounter < matchCollection.Count; matchCounter++)
            {
                Match match = matchCollection[matchCounter];
                if (match.Success) // has some keywords
                {
                    Group             group    = match.Groups["props"];
                    CaptureCollection captures = group.Captures;

                    for (int i = 0; i < captures.Count; i++)
                    {
                        string key = captures[i].Value;
                        switch (key)
                        {
                        case "name":
                            output = output.Replace("$name", activityWrapper.Name);
                            break;

                        case "dependents":
                            output = output.Replace("$dependents", activityWrapper.GetDependentList().ToCsv());
                            break;

                        default:
                            try
                            {
                                var value = activityWrapper.Current.GetPublicPropertValue <string>(key);
                                output = output.Replace("$" + key, key + ":" + value);
                            }
                            catch
                            {
                                try
                                {
                                    var value = activityWrapper.GetPublicPropertValue <string>(key);
                                    output = output.Replace("$" + key, key + ":" + value);
                                }
                                catch
                                {
                                    output = output.Replace("$" + key, key + ":" + "TBD");
                                }
                            }
                            break;
                        }
                    }
                }
            }

            return(output);
        }
        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);
                            }
                        }
                    }
                }
            }
        }