private void LoadDialogs()

in experimental/generation/runbot/RunBot.cs [54:132]


        private void LoadDialogs()
        {
            System.Diagnostics.Trace.TraceInformation("Loading resources...");

            var rootDialog = new AdaptiveDialog()
            {
                AutoEndDialog = false,
            };
            var choiceInput = new ChoiceInput()
            {
                Prompt = new ActivityTemplate("What dialog do you want to run?"),
                Property = "conversation.dialogChoice",
                AlwaysPrompt = true,
                Choices = new ChoiceSet(new List<Choice>())
            };

            var handleChoice = new SwitchCondition()
            {
                Condition = "conversation.dialogChoice",
                Cases = new List<Case>()
            };

            Dialog lastDialog = null;
            var choices = new ChoiceSet();
            var dialogName = _configuration["dialog"];

            foreach (var resource in _resourceExplorer.GetResources(".dialog").Where(r => dialogName != null ? r.Id == dialogName : r.Id.Count(c => c == '.') == 1))
            {
                try
                {
                    var name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(resource.Id));
                    choices.Add(new Choice(name));
                    var dialog = _resourceExplorer.LoadType<Dialog>(resource);
                    lastDialog = dialog;
                    handleChoice.Cases.Add(new Case($"{name}", new List<Dialog>() { dialog }));
                }
                catch (SyntaxErrorException err)
                {
                    Trace.TraceError($"{err.Source}: Error: {err.Message}");
                }
                catch (Exception err)
                {
                    Trace.TraceError(err.Message);
                }
            }

            if (handleChoice.Cases.Count() == 1)
            {
                rootDialog.Triggers.Add(new OnBeginDialog
                {
                    Actions = new List<Dialog>
                    {
                        lastDialog,
                        new RepeatDialog()
                    }
                });
            }
            else
            {
                choiceInput.Choices = choices;
                choiceInput.Style = ListStyle.Auto;
                rootDialog.Triggers.Add(new OnBeginDialog()
                {
                    Actions = new List<Dialog>()
                {
                    choiceInput,
                    new SendActivity("# Running ${conversation.dialogChoice}.dialog"),
                    handleChoice,
                    new RepeatDialog()
                }
                });
            }

            _dialogManager = new DialogManager(rootDialog)
                .UseResourceExplorer(_resourceExplorer)
                .UseLanguageGeneration();

            Trace.TraceInformation("Done loading resources.");
        }