/// <summary>
        /// Initializes a new instance of the <see cref="AdaptiveDialogBot"/> class.
        /// </summary>
        /// <param name="adaptiveDialogId">The id of the <see cref="AdaptiveDialog"/> to load from the <see cref="ResourceExplorer"/>.</param>
        /// <param name="languageGeneratorId">The id of the <see cref="LanguageGenerator"/> to load from the <see cref="ResourceExplorer"/>.</param>
        /// <param name="resourceExplorer">The Bot Builder <see cref="ResourceExplorer"/> to load the <see cref="Dialog"/> from.</param>
        /// <param name="conversationState">A <see cref="ConversationState"/> implementation.</param>
        /// <param name="userState">A <see cref="UserState"/> implementation.</param>
        /// <param name="skillConversationIdFactoryBase">A <see cref="SkillConversationIdFactoryBase"/> implementation.</param>
        /// <param name="languagePolicy">A <see cref="LanguagePolicy"/> to use.</param>
        /// <param name="botFrameworkAuthentication">A <see cref="BotFrameworkAuthentication"/> used to obtain a client for making calls to Bot Builder Skills.</param>
        /// <param name="telemetryClient">A <see cref="IBotTelemetryClient"/> used to log bot telemetry events.</param>
        /// <param name="scopes">Custom <see cref="MemoryScope"/> implementations that extend the memory system.</param>
        /// <param name="pathResolvers">Custom <see cref="IPathResolver"/> that add new resolvers path shortcuts to memory scopes.</param>
        /// <param name="dialogs">Custom <see cref="Dialog"/> that will be added to the root DialogSet.</param>
        /// <param name="logger">An <see cref="ILogger"/> instance.</param>
        public AdaptiveDialogBot(
            string adaptiveDialogId,
            string languageGeneratorId,
            ResourceExplorer resourceExplorer,
            ConversationState conversationState,
            UserState userState,
            SkillConversationIdFactoryBase skillConversationIdFactoryBase,
            LanguagePolicy languagePolicy,
            BotFrameworkAuthentication botFrameworkAuthentication,
            IBotTelemetryClient telemetryClient,
            IEnumerable <MemoryScope> scopes          = default,
            IEnumerable <IPathResolver> pathResolvers = default,
            IEnumerable <Dialog> dialogs = default,
            ILogger logger = null)
        {
            _resourceExplorer               = resourceExplorer ?? throw new ArgumentNullException(nameof(resourceExplorer));
            _adaptiveDialogId               = adaptiveDialogId ?? throw new ArgumentNullException(nameof(adaptiveDialogId));
            _languageGeneratorId            = languageGeneratorId ?? throw new ArgumentNullException(nameof(languageGeneratorId));
            _conversationState              = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _userState                      = userState ?? throw new ArgumentNullException(nameof(userState));
            _skillConversationIdFactoryBase = skillConversationIdFactoryBase ?? throw new ArgumentNullException(nameof(skillConversationIdFactoryBase));
            _languagePolicy                 = languagePolicy ?? throw new ArgumentNullException(nameof(languagePolicy));
            _botFrameworkAuthentication     = botFrameworkAuthentication ?? throw new ArgumentNullException(nameof(botFrameworkAuthentication));
            _telemetryClient                = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _memoryScopes                   = scopes ?? Enumerable.Empty <MemoryScope>();
            _pathResolvers                  = pathResolvers ?? Enumerable.Empty <IPathResolver>();
            _dialogs = dialogs ?? Enumerable.Empty <Dialog>();
            _logger  = logger ?? NullLogger <AdaptiveDialogBot> .Instance;

            _lazyRootDialog               = new Lazy <Task <Dialog> >(CreateDialogAsync);
            _lazyLanguageGenerator        = new Lazy <LanguageGenerator>(CreateLanguageGenerator);
            _lazyLanguageGeneratorManager = new Lazy <LanguageGeneratorManager>(CreateLanguageGeneratorManager);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleMultiLangGenerator"/> class.
        /// </summary>
        /// <param name="localeLGFiles">A dictionary of locale and LG file.</param>
        public SimpleMultiLangGenerator(Dictionary <string, string> localeLGFiles)
        {
            lgFilesPerLocale       = new Dictionary <string, LGFile>(StringComparer.OrdinalIgnoreCase);
            languageFallbackPolicy = new LanguagePolicy();

            if (localeLGFiles == null)
            {
                throw new ArgumentNullException(nameof(localeLGFiles));
            }

            foreach (var filesPerLocale in localeLGFiles)
            {
                lgFilesPerLocale[filesPerLocale.Key] = LGParser.ParseFile(filesPerLocale.Value);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Register language policy as default policy.
 /// </summary>
 /// <param name="dialogManager">botAdapter to add services to.</param>
 /// <param name="policy">policy to use.</param>
 /// <returns>botAdapter.</returns>
 public static DialogManager UseLanguagePolicy(this DialogManager dialogManager, LanguagePolicy policy)
 {
     dialogManager.TurnState.Add <LanguagePolicy>(policy);
     return(dialogManager);
 }