botbuilder-dialogs-adaptive
Version:
Rule system for the Microsoft BotBuilder dialog system.
50 lines • 1.92 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.DynamicBeginDialogDeserializer = void 0;
/**
* Internal serializer for `DynamicBeginDialog` which bind the x.dialog resourceId to the DynamicBeginDialog.dialog property.
*/
class DynamicBeginDialogDeserializer {
/**
* Intializes an instance of `DynamicBeginDialogDeserializer`.
*
* @param _resourceExplorer The `ResourceExplorer` used by the deserializer.
* @param _resourceId The resource id of the dynamic dialog.
*/
constructor(_resourceExplorer, _resourceId) {
this._resourceExplorer = _resourceExplorer;
this._resourceId = _resourceId;
}
/**
* The method that loads the configuration object to a `DynamicBeginDialog` object.
*
* @param config The configuration object to deserialize.
* @param type The object type that the configuration will be deserialized to.
* @returns A `DynamicBeginDialog` object created from the configuration.
*/
load(config, type) {
config.dialog = this._resourceExplorer.loadType(this._resourceId);
return Object.entries(config).reduce((instance, [key, value]) => {
let converter = instance.getConverter(key);
if (converter) {
if (typeof converter === 'function') {
converter = new converter(this._resourceExplorer);
}
instance[`${key}`] = converter.convert(value);
}
else {
instance[`${key}`] = value;
}
return instance;
}, new type());
}
}
exports.DynamicBeginDialogDeserializer = DynamicBeginDialogDeserializer;
//# sourceMappingURL=dynamicBeginDialogDeserializer.js.map