/// <summary> /// Returns the full path of incoming activities. /// </summary> public static IEnumerable <string> GetInboundActivityPath(this WorkflowModel workflowModel, string activityId) { var inspectedActivityIds = new HashSet <string>(); return(workflowModel.GetInboundActivityPathInternal(activityId, inspectedActivityIds) .Distinct().ToList()); }
private static IEnumerable <string> GetInboundActivityPathInternal(this WorkflowModel workflowModel, string activityId, HashSet <string> inspectedActivityIds) { foreach (var connection in workflowModel.GetInboundConnections(activityId)) { // Circuit breaker: Detect workflows that implement repeating flows to prevent an infinite loop here. if (inspectedActivityIds.Contains(connection.SourceId)) { yield break; } yield return(connection.SourceId); foreach (var parentActivityId in workflowModel.GetInboundActivityPathInternal(connection.SourceId, inspectedActivityIds).Distinct()) { inspectedActivityIds.Add(parentActivityId); yield return(parentActivityId); } } }