botbuilder-dialogs-adaptive
Version:
Rule system for the Microsoft BotBuilder dialog system.
53 lines • 1.88 kB
JavaScript
;
/**
* @module botbuilder-dialogs-adaptive
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DialogSetConverter = void 0;
const botbuilder_dialogs_1 = require("botbuilder-dialogs");
/**
* DialogSet converter that implements [Converter](xref:botbuilder-dialogs-declarative.Converter).
*/
class DialogSetConverter {
/**
* Initializes a new instance of the [DialogSetConverter](xref:botbuilder-dialogs-adaptive.DialogSetConverter) class.
*
* @param _resourceExplorer Resource explorer to use for resolving references.
*/
constructor(_resourceExplorer) {
this._resourceExplorer = _resourceExplorer;
}
/**
* Converts an array of dialog or dialog name to a [DialogSet](xref:botbuilder-dialogs.DialogSet) instance.
*
* @param value An array of dialog or dialog name.
* @returns A new [DialogSet](xref:botbuilder-dialogs.DialogSet) instance.
*/
convert(value) {
if (value instanceof botbuilder_dialogs_1.DialogSet) {
return value;
}
const result = new botbuilder_dialogs_1.DialogSet();
value.forEach((item) => {
if (item instanceof botbuilder_dialogs_1.Dialog) {
result.add(item);
}
else {
let resource = this._resourceExplorer.getResource(item);
if (!resource) {
resource = this._resourceExplorer.getResource(`${item}.dialog`);
}
if (resource) {
result.add(this._resourceExplorer.loadType(resource));
}
}
});
return result;
}
}
exports.DialogSetConverter = DialogSetConverter;
//# sourceMappingURL=dialogSetConverter.js.map