コード例 #1
0
        public async Task ResourceExplorer_LoadType_VerifyTokenRangeAndIdHonored()
        {
            var          path            = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, PathUtils.NormalizePath(@"..\..\..")));
            const string resourcesFolder = "resources";
            const string resourceId      = "testWithId.dialog";

            using (var explorer = new ResourceExplorer())
            {
                explorer.AddResourceProvider(new FolderResourceProvider(explorer, path));

                // Load file using resource explorer
                var resource = explorer.GetResource(resourceId);
                var dialog   = await explorer.LoadTypeAsync <Dialog>(resource).ConfigureAwait(false);

                // Verify correct range
                var expectedRange = new SourceRange
                {
                    StartPoint = new SourcePoint(1, 1),
                    EndPoint   = new SourcePoint(14, 1),
                    Path       = Path.Join(Path.Join(path, resourcesFolder), resourceId)
                };

                Assert.Equal(expectedRange, dialog.Source);

                // Verify that the correct id was set
                Assert.Equal("explicit-id", dialog.Id);
            }
        }
コード例 #2
0
        public async Task ResourceExplorer_LoadType_VerifyAdaptiveDialogIdAssigned()
        {
            var          path       = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, PathUtils.NormalizePath(@"..\..\..")));
            const string resourceId = "test.dialog";

            using (var explorer = new ResourceExplorer())
            {
                explorer.AddResourceProvider(new FolderResourceProvider(explorer, path));

                // Load file using resource explorer
                var resource = explorer.GetResource(resourceId);
                var dialog   = await explorer.LoadTypeAsync <AdaptiveDialog>(resource).ConfigureAwait(false);

                // Verify that the correct id was assigned
                Assert.Equal(resourceId, dialog.Id);
            }
        }
コード例 #3
0
        private async Task <Dialog> CreateDialogAsync()
        {
            if (!_resourceExplorer.TryGetResource(_adaptiveDialogId, out var adaptiveDialogResource))
            {
                var msg = $"The ResourceExplorer could not find a resource with id '{_adaptiveDialogId}'";
                _logger.LogError(msg);
                throw new InvalidOperationException(msg);
            }

            var adaptiveDialog = await _resourceExplorer.LoadTypeAsync <AdaptiveDialog>(adaptiveDialogResource, CancellationToken.None).ConfigureAwait(false);

            // if we were passed any Dialogs then add them to the AdaptiveDialog's DialogSet so they can be invoked from any other Dialog
            foreach (var dialog in _dialogs)
            {
                adaptiveDialog.Dialogs.Add(dialog);
            }

            return(adaptiveDialog);
        }