/// <summary> /// Recursively walks the stages through the children to write the scenario. /// </summary> /// <param name="containerNode">The HTML container to render into.</param> /// <param name="stage">The scenario stage.</param> private static void RecurseTargetScenarioStage(HtmlNode containerNode, TargetScenarioStage stage) { switch (stage.MessagingObject.Type) { case MessagingObjectType.Endpoint: RenderTargetScenarioEndpoint(containerNode, (Endpoint)stage.MessagingObject); break; case MessagingObjectType.Intermediary: RenderTargetScenarioIntermediary(containerNode, (Intermediary)stage.MessagingObject); break; case MessagingObjectType.Channel: RenderTargetScenarioChannel(containerNode, (Channel)stage.MessagingObject); break; } stage.FollowingStages.ToList().ForEach(s => RecurseTargetScenarioStage(containerNode, s)); }
/// <summary> /// Recursively checks the output refs for the stage and creates links to following intermediaries and stages. /// </summary> /// <param name="stage">The current stage being walked.</param> /// <param name="target">The entire target model.</param> /// <param name="allRefs">The list of references already processed, to prevent circular scenario walks.</param> private static void RecurseScenarioStage(TargetScenarioStage stage, AzureIntegrationServicesMigrationTarget target, List <string> allRefs) { // The list of subsequent stages referenced by the current stage. var outputRefs = new List <string>(); switch (stage.MessagingObject.Type) { case MessagingObjectType.Endpoint: // The endpoint has a single output. outputRefs.Add(((Endpoint)stage.MessagingObject).OutputChannelKeyRef); break; case MessagingObjectType.Channel: var channel = (Channel)stage.MessagingObject; // Only add the channel if its a routing channel. if (channel.Properties.ContainsKey(ModelConstants.RouteLabel)) { // The next stage is keyed off the channel. outputRefs.Add(((Channel)stage.MessagingObject).Key); } break; case MessagingObjectType.Intermediary: // An intermediary can have multiple outputs. outputRefs.AddRange(((Intermediary)stage.MessagingObject).OutputChannelKeyRefs); break; } outputRefs.ForEach((o) => { if (!allRefs.Contains(o)) { var mo = target.FindMessagingObject(o, stage.MessagingObject.Type); if (mo != null) { stage.FollowingStages.Add(mo.CreateScenarioStage()); } allRefs.Add(o); } }); stage.FollowingStages.ToList().ForEach(s => RecurseScenarioStage(s, target, allRefs)); }