public AdaptiveBot(ResourceExplorer resourceExplorer) { this.resourceExplorer = resourceExplorer; void LoadRootDialog() { // user scoped //var root = this.resourceExplorer.GetResource("userScoped.dialog"); //this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load<AdaptiveDialog>(root, resourceExplorer, DebugSupport.SourceMap)); // conversation scoped //var root = this.resourceExplorer.GetResource("conversationScoped.dialog"); //this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load<AdaptiveDialog>(root, resourceExplorer, DebugSupport.SourceMap)); // dialog scoped //var child = this.resourceExplorer.GetResource("dialogScoped-child.dialog"); //DeclarativeTypeLoader.Load<AdaptiveDialog>(child, resourceExplorer, DebugSupport.SourceMap); //var root = this.resourceExplorer.GetResource("dialogScoped-parent.dialog"); //this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load<AdaptiveDialog>(root, resourceExplorer, DebugSupport.SourceMap)); // turn scoped var root = this.resourceExplorer.GetResource("turnScoped.dialog"); this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load <AdaptiveDialog>(root, resourceExplorer, DebugSupport.SourceMap)); } LoadRootDialog(); }
/// <summary> /// Register ILanguageGenerator as default langugage generator. /// </summary> /// <param name="botAdapter">botAdapter to add services to.</param> /// <param name="resourceExplorer">resourceExporer to provide to LanguageGenerator.</param> /// <param name="languageGenerator">LanguageGenerator to use.</param> /// <returns>botAdapter.</returns> public static BotAdapter UseLanguageGeneration(this BotAdapter botAdapter, ResourceExplorer resourceExplorer, ILanguageGenerator languageGenerator) { DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); botAdapter.Use(new RegisterClassMiddleware <LanguageGeneratorManager>(new LanguageGeneratorManager(resourceExplorer ?? throw new ArgumentNullException(nameof(resourceExplorer))))); botAdapter.Use(new RegisterClassMiddleware <ILanguageGenerator>(languageGenerator ?? throw new ArgumentNullException(nameof(languageGenerator)))); return(botAdapter); }
public AdaptiveBot(ResourceExplorer resourceExplorer) { this.resourceExplorer = resourceExplorer; var resource = this.resourceExplorer.GetResource("main.dialog"); this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceMap)); }
public static async Task RunTestScript(string resourceId = null, [CallerMemberName] string testName = null, IConfiguration configuration = null) { TestScript script; // TODO: For now, serialize type loading because config is static and is used by LUIS type loader. lock (RootFolder) { if (configuration == null) { configuration = DefaultConfiguration; } if (configuration != TypeFactory.Configuration) { TypeFactory.Configuration = configuration; DeclarativeTypeLoader.Reset(); TypeFactory.Configuration = configuration ?? new ConfigurationBuilder().AddInMemoryCollection().Build(); DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); DeclarativeTypeLoader.AddComponent(new MockLuisComponentRegistration()); } script = TestUtils.ResourceExplorer.LoadType <TestScript>(resourceId ?? $"{testName}.test.dialog"); } script.Description = script.Description ?? resourceId; await script.ExecuteAsync(testName : testName, configuration : configuration, resourceExplorer : ResourceExplorer).ConfigureAwait(false); }
private void LoadRootDialogAsync() { var rootFile = resourceExplorer.GetResource(rootDialogFile); rootDialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(rootFile, resourceExplorer, sourceMap); this.dialogManager = new DialogManager(rootDialog); }
public static void ClassInitialize(TestContext context) { TypeFactory.Configuration = new ConfigurationBuilder().AddInMemoryCollection().Build(); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); resourceExplorer = ResourceExplorer.LoadProject(GetProjectFolder()); }
public RootDialog(UserState userState) : base("root") { _userState = userState; AddDialog(new UserProfileDialog(userState)); // The initial child Dialog to run. InitialDialogId = "waterfall"; // Get Folder of dialogs. var resourceExplorer = new ResourceExplorer().AddFolder("Dialogs"); // find the main composer dialog to start with var composerDialog = resourceExplorer.GetResource("Main.dialog"); // hyrdate an Adaptive Dialogue AdaptiveDialog myComposerDialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(composerDialog, resourceExplorer, DebugSupport.SourceMap); myComposerDialog.Id = "Main.dialog"; // setup lanaguage generation for the dialogue myComposerDialog.Generator = new TemplateEngineLanguageGenerator(new TemplateEngine().AddFile(@"C:\Users\Jamie\source\repos\composer-adaptive-regular-hybrid\Dialogs\ComposerDialogs\Main\Main.lg")); // add to the ComponentDialog which Root dialogue inherits from AddDialog(myComposerDialog); AddDialog(new WaterfallDialog("waterfall", new WaterfallStep[] { StartDialogAsync, BeginComposerAdaptiveDialog })); }
private TestFlow BuildTestFlow(string folderPath, bool sendTrace = false) { TypeFactory.Configuration = new ConfigurationBuilder().Build(); var storage = new MemoryStorage(); var convoState = new ConversationState(storage); var userState = new UserState(storage); var adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName), sendTrace); var resourceExplorer = new ResourceExplorer(); resourceExplorer.AddFolder(folderPath); adapter .UseStorage(storage) .UseState(userState, convoState) .UseAdaptiveDialogs() .UseLanguageGeneration(resourceExplorer, "common.lg") .UseResourceExplorer(resourceExplorer) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); var resource = resourceExplorer.GetResource("Main.dialog"); var dialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceMap); DialogManager dm = new DialogManager(dialog); return(new TestFlow(adapter, async(turnContext, cancellationToken) => { if (dialog is AdaptiveDialog planningDialog) { await dm.OnTurnAsync(turnContext, cancellationToken).ConfigureAwait(false); } })); }
private void LoadDialogs() { System.Diagnostics.Trace.TraceInformation("Loading resources..."); var rootDialog = new AdaptiveDialog() { AutoEndDialog = false, }; var choiceInput = new ChoiceInput() { Prompt = new ActivityTemplate("What declarative sample 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>() }; foreach (var resource in this.resourceExplorer.GetResources(".dialog").Where(r => r.Id.EndsWith(".main.dialog"))) { try { var name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(resource.Id)); choiceInput.Choices.Value.Add(new Choice(name)); var dialog = DeclarativeTypeLoader.Load <Dialog>(resource, this.resourceExplorer, DebugSupport.SourceMap); 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); } } choiceInput.Style = ListStyle.Auto; rootDialog.Triggers.Add(new OnBeginDialog() { Actions = new List <Dialog>() { choiceInput, new SendActivity("# Running @{conversation.dialogChoice}.main.dialog"), handleChoice, new RepeatDialog() } }); this.dialogManager = new DialogManager(rootDialog); System.Diagnostics.Trace.TraceInformation("Done loading resources."); }
public AdaptiveBot(ConversationState conversationState, ResourceExplorer resourceExplorer) { this.dialogStateAccessor = conversationState.CreateProperty <DialogState>("RootDialogState"); this.resourceExplorer = resourceExplorer; var resource = this.resourceExplorer.GetResource("main.dialog"); this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceMap)); }
private void LoadDialogs() { System.Diagnostics.Trace.TraceInformation("Loading resources..."); var resource = this.resourceExplorer.GetResource("main.dialog"); this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceRegistry)); System.Diagnostics.Trace.TraceInformation("Done loading resources."); }
public static void ClassInitialize(TestContext context) { TypeFactory.Configuration = new ConfigurationBuilder().AddInMemoryCollection().Build(); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); TypeFactory.Register("Microsoft.RuleRecognizer", typeof(RuleRecognizer)); string projPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, PathUtils.NormalizePath($@"..\..\..\..\..\tests\Microsoft.Bot.Builder.TestBot.Json\Microsoft.Bot.Builder.TestBot.Json.csproj"))); resourceExplorer = ResourceExplorer.LoadProject(projPath); }
private void LoadDialogs() { System.Diagnostics.Trace.TraceInformation("Loading resources..."); var resource = this.resourceExplorer.GetResource("EchoDialogSteps.dialog"); //var resource = this.resourceExplorer.GetResource("EchoDialogRule.dialog"); rootDialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceRegistry); System.Diagnostics.Trace.TraceInformation("Done loading resources."); }
private TestFlow BuildQnAMakerTestFlow() { var adapter = InitializeAdapter() .Use(new RegisterClassMiddleware <IQnAMakerClient>(new MockQnAMakerClient())); var resource = resourceExplorer.GetResource("QnAMakerBot.main.dialog"); var dialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceMap); var qnaMakerDialog = (QnAMakerDialog2)dialog.Triggers[0].Actions[0]; dialog.Triggers[0].Actions[0] = qnaMakerDialog; return(GetTestAdapter(dialog, adapter)); }
public ComposerBot(string rootDialogFile, ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, ISourceMap sourceMap, IBotTelemetryClient telemetryClient) { this.conversationState = conversationState; this.userState = userState; this.dialogState = conversationState.CreateProperty <DialogState>("DialogState"); this.sourceMap = sourceMap; this.resourceExplorer = resourceExplorer; this.rootDialogFile = rootDialogFile; this.telemetryClient = telemetryClient; DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); LoadRootDialogAsync(); }
public AdaptiveBot(ResourceExplorer resourceExplorer) { this.resourceExplorer = resourceExplorer; void LoadRootDialog() { var root = this.resourceExplorer.GetResource("regexRecognizerDemo.dialog"); this.dialogManager = new DialogManager(DeclarativeTypeLoader.Load <AdaptiveDialog>(root, resourceExplorer, DebugSupport.SourceMap)); } LoadRootDialog(); }
public async Task TestDialogInjectionDeclarative() { await CreateFlow("en-us", async (turnContext, cancellationToken) => { var resource = resourceExplorer.GetResource("test.dialog"); var dialog = (AdaptiveDialog)DeclarativeTypeLoader.Load <Dialog>(resource, resourceExplorer, DebugSupport.SourceMap); DialogManager dm = new DialogManager(dialog); await dm.OnTurnAsync(turnContext, cancellationToken: cancellationToken).ConfigureAwait(false); }) .Send("hello") .AssertReply("root") .AssertReply("overriden") .StartTestAsync(); }
public static void AssemblyInit(TestContext context) { lock (rootFolder) { if (ResourceExplorer == null) { ResourceExplorer = new ResourceExplorer().AddFolder(rootFolder); TypeFactory.Configuration = new ConfigurationBuilder().AddInMemoryCollection().Build(); DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); } } }
private AdaptiveDialog CreateChoiceInputForAllMainDialogs() { var dialogChoices = new List <Choice>(); var dialogCases = new List <Case>(); foreach (var resource in this.resourceExplorer.GetResources(".dialog").Where(r => r.Id.EndsWith(".main.dialog"))) { var name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(resource.Id)); dialogChoices.Add(new Choice(name)); var subDialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(resource, resourceExplorer, DebugSupport.SourceMap); dialogCases.Add(new Case($"{name}", new List <Dialog>() { subDialog })); } var dialog = new AdaptiveDialog() { AutoEndDialog = false, Triggers = new List <OnCondition>() { new OnBeginDialog() { Actions = new List <Dialog>() { new ChoiceInput() { Prompt = new ActivityTemplate("What declarative sample do you want to run?"), Property = "conversation.dialogChoice", AlwaysPrompt = true, Style = ListStyle.List, Choices = new ChoiceSet(dialogChoices) }, new SendActivity("# Running {conversation.dialogChoice}.main.dialog"), new SwitchCondition() { Condition = "conversation.dialogChoice", Cases = dialogCases }, new RepeatDialog() } } } }; return(dialog); }
/// <summary> /// Register ILanguageGenerator as default langugage generator. /// </summary> /// <param name="botAdapter">botAdapter to add services to.</param> /// <param name="resourceExplorer">resourceExporer to provide to LanguageGenerator.</param> /// <param name="languageGenerator">LanguageGenerator to use.</param> /// <returns>botAdapter.</returns> public static BotAdapter UseLanguageGeneration(this BotAdapter botAdapter, ResourceExplorer resourceExplorer, ILanguageGenerator languageGenerator) { DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); lock (languageGeneratorManagers) { if (!languageGeneratorManagers.TryGetValue(resourceExplorer ?? throw new ArgumentNullException(nameof(resourceExplorer)), out var lgm)) { lgm = new LanguageGeneratorManager(resourceExplorer); languageGeneratorManagers[resourceExplorer] = lgm; } botAdapter.Use(new RegisterClassMiddleware <LanguageGeneratorManager>(lgm)); botAdapter.Use(new RegisterClassMiddleware <ILanguageGenerator>(languageGenerator ?? throw new ArgumentNullException(nameof(languageGenerator)))); return(botAdapter); } }
public ComposerBot(string rootDialogFile, ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, ISourceMap sourceMap) { this.conversationState = conversationState; this.userState = userState; this.dialogState = conversationState.CreateProperty <DialogState>("DialogState"); this.sourceMap = sourceMap; this.resourceExplorer = resourceExplorer; this.rootDialogFile = rootDialogFile; DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); // auto reload dialogs when file changes this.resourceExplorer.Changed += (resources) => { if (resources.Any(resource => resource.Id == ".dialog")) { Task.Run(() => this.LoadRootDialogAsync()); } }; LoadRootDialogAsync(); }
private void LoadDialogs() { System.Diagnostics.Trace.TraceInformation("Loading resources..."); this.rootDialog = new AdaptiveDialog() { AutoEndDialog = false, Steps = new List <IDialog>() }; var choiceInput = new ChoiceInput() { Prompt = new ActivityTemplate("What declarative sample do you want to run?"), OutputBinding = "conversation.dialogChoice", AlwaysPrompt = true, Choices = new List <Choice>() }; var handleChoice = new SwitchCondition() { Condition = "conversation.dialogChoice", Cases = new List <Case>() }; foreach (var resource in this.resourceExplorer.GetResources(".dialog").Where(r => r.Id.EndsWith(".main.dialog"))) { var name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(resource.Id)); choiceInput.Choices.Add(new Choice(name)); var dialog = DeclarativeTypeLoader.Load <IDialog>(resource, this.resourceExplorer, DebugSupport.SourceRegistry); handleChoice.Cases.Add(new Case($"'{name}'", new List <IDialog>() { dialog })); } choiceInput.Style = ListStyle.Auto; this.rootDialog.Steps.Add(choiceInput); this.rootDialog.Steps.Add(new SendActivity("# Running {conversation.dialogChoice}.main.dialog")); this.rootDialog.Steps.Add(handleChoice); this.rootDialog.Steps.Add(new RepeatDialog()); System.Diagnostics.Trace.TraceInformation("Done loading resources."); }
private AdaptiveDialog CreateChoiceInputForAllMainDialogs() { var dialog = new AdaptiveDialog() { AutoEndDialog = false, Steps = new List <IDialog>() }; var choiceInput = new ChoiceInput() { Prompt = new ActivityTemplate("What declarative sample do you want to run?"), Property = "conversation.dialogChoice", AlwaysPrompt = true, Choices = new List <Choice>(), }; var handleChoice = new SwitchCondition() { Condition = "conversation.dialogChoice", Cases = new List <Case>() }; foreach (var resource in this.resourceExplorer.GetResources(".dialog").Where(r => r.Id.EndsWith(".main.dialog"))) { var name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(resource.Id)); choiceInput.Choices.Add(new Choice(name)); var subDialog = DeclarativeTypeLoader.Load <IDialog>(resource, this.resourceExplorer, DebugSupport.SourceRegistry); handleChoice.Cases.Add(new Case($"{name}", new List <IDialog>() { subDialog })); } choiceInput.Style = ListStyle.List; dialog.Steps.Add(choiceInput); dialog.Steps.Add(new SendActivity("# Running {conversation.dialogChoice}.main.dialog")); dialog.Steps.Add(handleChoice); dialog.Steps.Add(new RepeatDialog()); return(dialog); }
public RootDialog(UserState userState) : base("root") { _userState = userState; // Get Folder of dialogs. var resourceExplorer = new ResourceExplorer().AddFolder(@"Dialogs"); // find the main composer dialog to start with var composerDialog = resourceExplorer.GetResource("Main.dialog"); // hyrdate an Adaptive Dialogue AdaptiveDialog myComposerDialog = DeclarativeTypeLoader.Load <AdaptiveDialog>(composerDialog, resourceExplorer, DebugSupport.SourceMap); myComposerDialog.Id = "Main.dialog"; // setup lanaguage generation for the dialogue myComposerDialog.Generator = new TemplateEngineLanguageGenerator(new TemplateEngine().AddFile(@"Dialogs\ComposerDialogs\Main\Main.lg")); // add to the ComponentDialog which Root dialogue inherits from AddDialog(myComposerDialog); // create a waterfall dialogue and begin our adaptive dialogue AddDialog(new WaterfallDialog("waterfall", new WaterfallStep[] { BeginComposerAdaptiveDialog })); }
/// <summary> /// Register QnAMaker types. /// </summary> /// <param name="botAdapter">BotAdapter to add middleware to.</param> /// <returns>The bot adapter.</returns> public static BotAdapter UseQnAMaker(this BotAdapter botAdapter) { DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); return(botAdapter); }
private Dialog FetchDialogFromResource(string resourceName) { var resource = resourceExplorer.GetResource(resourceName); return(DeclarativeTypeLoader.Load <Dialog>(resource, resourceExplorer, DebugSupport.SourceMap)); }
public static void Main(string[] args) { var secret = "profile"; string luis = null; var iterations = 1; if (args.Length == 0) { Help(); } for (var i = 0; i < args.Length; ++i) { var arg = args[i]; if (arg.StartsWith("-")) { if (arg == "-secret") { if (++i < args.Length) { secret = args[i]; } else { throw new System.ArgumentException("Missing -secret value"); } } else if (arg == "-luis") { if (++i < args.Length) { luis = args[i]; } else { throw new System.ArgumentException("Missing -luis value"); } } else if (arg == "-n") { if (++i < args.Length) { iterations = int.Parse(args[i]); } else { throw new System.ArgumentException("Missing -n value"); } } else { Console.Error.WriteLine($"Unknown arg {arg}"); Help(); } } else { var cd = Directory.GetCurrentDirectory(); var dir = Path.GetDirectoryName(arg); var name = Path.GetFileName(arg); var config = new ConfigurationBuilder() .AddInMemoryCollection() .UseLuisSettings(luis ?? dir, secret) .Build(); var explorer = new ResourceExplorer().AddFolder(dir); DeclarativeTypeLoader.Reset(); TypeFactory.Configuration = config; DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); DeclarativeTypeLoader.AddComponent(new MockLuisComponentRegistration()); var script = explorer.LoadType <TestScript>(name); var timer = new System.Diagnostics.Stopwatch(); Console.WriteLine($"Executing {arg} for {iterations} iterations"); timer.Start(); var adapter = script.DefaultTestAdapter(testName: name, resourceExplorer: explorer, configuration: config); timer.Stop(); var loading = timer.ElapsedMilliseconds; Console.WriteLine($" loading took {loading} ms"); var iterationTime = 0L; var firstTime = 0l; for (var iter = 0; iter < iterations; ++iter) { timer.Restart(); script.ExecuteAsync(adapter: adapter).Wait(); timer.Stop(); if (firstTime > 0) { iterationTime += timer.ElapsedMilliseconds; } else { firstTime = timer.ElapsedMilliseconds; } Console.WriteLine($" {iter}: {timer.ElapsedMilliseconds} ms"); } Console.Write($" Total time={loading + firstTime + iterationTime} ms"); if (iterations > 1) { Console.WriteLine($", per iteration after 1st={iterationTime / ((float)iterations - 1)} ms"); } } } }
/// <summary> /// Register MessageActivityGeneration. /// </summary> /// <param name="botAdapter">botAdapter to add services to.</param> /// <param name="messageGenerator">(OPTIONAL) Default is TextMessageActivityGenerator(). </param> /// <returns>botAdapter.</returns> public static BotAdapter UseMessageActivityGeneration(this BotAdapter botAdapter, IActivityGenerator messageGenerator = null) { DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); botAdapter.Use(new RegisterClassMiddleware <IActivityGenerator>(messageGenerator ?? new ActivityGenerator())); return(botAdapter); }
/// <summary> /// Create Type from resource. /// </summary> /// <typeparam name="T">type to create.</typeparam> /// <param name="resource">resource to bind to.</param> /// <returns>created type.</returns> public T LoadType <T>(IResource resource) { return(DeclarativeTypeLoader.Load <T>(resource, this, DebugSupport.SourceMap)); }
public static void Main(string[] args) { var secret = "profile"; string luis = null; if (args.Length == 0) { Help(); } for (var i = 0; i < args.Length; ++i) { var arg = args[i]; if (arg.StartsWith("-")) { if (arg == "-secret") { if (++i < args.Length) { secret = args[i]; } else { throw new System.ArgumentException("Missing --secret value"); } } else if (arg == "-luis") { if (++i < args.Length) { luis = args[i]; } else { throw new System.ArgumentException("Missing --luis value"); } } else { Console.Error.WriteLine($"Unknown arg {arg}"); Help(); } } else { var cd = Directory.GetCurrentDirectory(); var dir = Path.GetDirectoryName(arg); var name = Path.GetFileName(arg); var config = new ConfigurationBuilder() .AddInMemoryCollection() .UseLuisSettings(luis ?? dir, secret) .Build(); var explorer = new ResourceExplorer().AddFolder(dir); DeclarativeTypeLoader.Reset(); TypeFactory.Configuration = config; DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); DeclarativeTypeLoader.AddComponent(new MockLuisComponentRegistration()); var script = explorer.LoadType <TestScript>(name); var timer = new System.Diagnostics.Stopwatch(); Console.Write($"Executing {arg}"); timer.Start(); script.ExecuteAsync(testName: name, configuration: config, resourceExplorer: explorer).Wait(); timer.Stop(); Console.WriteLine($" took {timer.ElapsedMilliseconds} ms"); } } }