//This method updates the clone of currentFlowElement to reference cloned FlowElements. void UpdateCloneReferences(FlowNode currentFlowElement, Dictionary <FlowNode, FlowNode> clonedFlowElements) { if (typeof(FlowStep).IsAssignableFrom(currentFlowElement.GetType())) { FlowStep currentFlowStep = (FlowStep)currentFlowElement; FlowStep clonedFlowStep = (FlowStep)clonedFlowElements[currentFlowElement]; FlowNode nextFlowElement = currentFlowStep.Next; if (nextFlowElement != null && clonedFlowElements.ContainsKey(nextFlowElement)) { clonedFlowStep.Next = clonedFlowElements[nextFlowElement]; } else { clonedFlowStep.Next = null; } } else if (typeof(FlowDecision).IsAssignableFrom(currentFlowElement.GetType())) { FlowDecision currentFlowDecision = (FlowDecision)currentFlowElement; FlowDecision clonedFlowDecision = (FlowDecision)clonedFlowElements[currentFlowElement]; FlowNode trueElement = currentFlowDecision.True; FlowNode falseElement = currentFlowDecision.False; if (trueElement != null && clonedFlowElements.ContainsKey(trueElement)) { clonedFlowDecision.True = clonedFlowElements[trueElement]; } else { clonedFlowDecision.True = null; } if (falseElement != null && clonedFlowElements.ContainsKey(falseElement)) { clonedFlowDecision.False = clonedFlowElements[falseElement]; } else { clonedFlowDecision.False = null; } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(currentFlowElement.GetType())) { GenericFlowSwitchHelper.Copy(currentFlowElement.GetType().GetGenericArguments()[0], currentFlowElement, clonedFlowElements); } else { Debug.Fail("Unknown FlowNode"); } }