/// <summary>
 /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
 /// </summary>
 /// <param name="translator">Translator implementation to be used for text translation.</param>
 /// <param name="languageStateProperty">State property for current language.</param>
 public TranslationMiddleware(MicrosoftTranslator translator, ConversationState conversationState, IConfiguration configuration)
 {
     _translator        = translator ?? throw new ArgumentNullException(nameof(translator));
     _conversationState = conversationState;
     _configuration     = configuration;
     // Set the static ConversationState for use in QnAMakerBaseDialog
     Util.ConversationState = conversationState;
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
        /// </summary>
        /// <param name="translator">Translator implementation to be used for text translation.</param>
        /// <param name="userState">The UserState that contains the target language.</param>
        public TranslationMiddleware(MicrosoftTranslator translator, UserState userState, MessageActivityTranslator activityTranslator)
        {
            if (userState == null)
            {
                throw new ArgumentNullException(nameof(userState));
            }

            _languageStateProperty     = userState.CreateProperty <string>("LanguagePreference");
            _messageActivityTranslator = activityTranslator ?? throw new ArgumentNullException(nameof(activityTranslator));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
        /// </summary>
        /// <param name="translator">Translator implementation to be used for text translation.</param>
        /// <param name="languageStateProperty">State property for current language.</param>
        public TranslationMiddleware(MicrosoftTranslator translator, UserState userState)
        {
            _translator = translator ?? throw new ArgumentNullException(nameof(translator));
            if (userState == null)
            {
                throw new ArgumentNullException(nameof(userState));
            }

            _userState        = userState;
            _previousLanguage = userState.CreateProperty <string>("LanguagePreference");
        }
Beispiel #4
0
 public MessageActivityTranslator(MicrosoftTranslator translator)
 {
     _translator = translator ?? throw new ArgumentNullException(nameof(translator));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
 /// </summary>
 /// <param name="translator">Translator implementation to be used for text translation.</param>
 /// <param name="languageStateProperty">State property for current language.</param>
 public TranslationMiddleware(MicrosoftTranslator translator, IStatePropertyAccessor <string> languageStateProperty)
 {
     _translator            = translator ?? throw new ArgumentNullException(nameof(translator));
     _languageStateProperty = languageStateProperty ?? throw new ArgumentNullException(nameof(languageStateProperty));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
 /// </summary>
 /// <param name="translator">Translator implementation to be used for text translation.</param>
 /// <param name="languageStateProperty">State property for current language.</param>
 public TranslationMiddleware(MicrosoftTranslator translator, ConversationState conversationState, IConfiguration configuration)
 {
     _translator        = translator ?? throw new ArgumentNullException(nameof(translator));
     _conversationState = conversationState;
     _configuration     = configuration;
 }