/// <summary>
        /// Initializes a new instance of the <see cref="SkillHandler"/> class,
        /// using a credential provider.
        /// </summary>
        /// <param name="adapter">An instance of the <see cref="BotAdapter"/> that will handle the request.</param>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="conversationIdFactory">A <see cref="SkillConversationIdFactoryBase"/> to unpack the conversation ID and map it to the calling bot.</param>
        /// <param name="credentialProvider">The credential provider.</param>
        /// <param name="authConfig">The authentication configuration.</param>
        /// <param name="channelProvider">The channel provider.</param>
        /// <param name="logger">The ILogger implementation this adapter should use.</param>
        /// <exception cref="ArgumentNullException">throw ArgumentNullException.</exception>
        /// <remarks>Use a <see cref="MiddlewareSet"/> object to add multiple middleware
        /// components in the constructor. Use the Use(<see cref="IMiddleware"/>) method to
        /// add additional middleware to the adapter after construction.
        /// </remarks>
        public SkillHandler(
            BotAdapter adapter,
            IBot bot,
            SkillConversationIdFactoryBase conversationIdFactory,
            ICredentialProvider credentialProvider,
            AuthenticationConfiguration authConfig,
            IChannelProvider channelProvider = null,
            ILogger logger = null)
            : base(credentialProvider, authConfig, channelProvider)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException(nameof(adapter));
            }

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

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

            _inner = new SkillHandlerImpl(
                SkillConversationReferenceKey,
                adapter,
                bot,
                conversationIdFactory,
                () => ChannelProvider != null && ChannelProvider.IsGovernment()
                    ? GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope
                    : AuthenticationConstants.ToChannelFromBotOAuthScope,
                logger ?? NullLogger.Instance);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudSkillHandler"/> class using BotFrameworkAuth.
        /// </summary>
        /// <param name="adapter">An instance of the <see cref="BotAdapter"/> that will handle the request.</param>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="conversationIdFactory">A <see cref="SkillConversationIdFactoryBase"/> to unpack the conversation ID and map it to the calling bot.</param>
        /// <param name="auth">auth.</param>
        /// <param name="logger">The ILogger implementation this adapter should use.</param>
        public CloudSkillHandler(
            BotAdapter adapter,
            IBot bot,
            SkillConversationIdFactoryBase conversationIdFactory,
            BotFrameworkAuthentication auth,
            ILogger logger = null)
            : base(auth)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException(nameof(adapter));
            }

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

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

            _inner = new SkillHandlerImpl(
                SkillConversationReferenceKey,
                adapter,
                bot,
                conversationIdFactory,
                auth.GetOriginatingAudience,
                logger ?? NullLogger.Instance);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkillHandler"/> class,
 /// using a credential provider.
 /// </summary>
 /// <param name="adapter">An instance of the <see cref="BotAdapter"/> that will handle the request.</param>
 /// <param name="bot">The <see cref="IBot"/> instance.</param>
 /// <param name="conversationIdFactory">A <see cref="SkillConversationIdFactoryBase"/> to unpack the conversation ID and map it to the calling bot.</param>
 /// <param name="credentialProvider">The credential provider.</param>
 /// <param name="authConfig">The authentication configuration.</param>
 /// <param name="channelProvider">The channel provider.</param>
 /// <param name="logger">The ILogger implementation this adapter should use.</param>
 /// <exception cref="ArgumentNullException">throw ArgumentNullException.</exception>
 /// <remarks>Use a <see cref="MiddlewareSet"/> object to add multiple middleware
 /// components in the constructor. Use the Use(<see cref="IMiddleware"/>) method to
 /// add additional middleware to the adapter after construction.
 /// </remarks>
 public SkillHandler(
     BotAdapter adapter,
     IBot bot,
     SkillConversationIdFactoryBase conversationIdFactory,
     ICredentialProvider credentialProvider,
     AuthenticationConfiguration authConfig,
     IChannelProvider channelProvider = null,
     ILogger logger = null)
     : base(credentialProvider, authConfig, channelProvider)
 {
     _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
     _bot     = bot ?? throw new ArgumentNullException(nameof(bot));
     _conversationIdFactory = conversationIdFactory ?? throw new ArgumentNullException(nameof(conversationIdFactory));
     _logger = logger ?? NullLogger.Instance;
 }
        internal SkillHandlerImpl(
            string skillConversationReferenceKey,
            BotAdapter adapter,
            IBot bot,
            SkillConversationIdFactoryBase conversationIdFactory,
            Func <string> getOAuthScope,
            ILogger logger = null)
        {
            if (string.IsNullOrWhiteSpace(skillConversationReferenceKey))
            {
                throw new ArgumentNullException(nameof(skillConversationReferenceKey));
            }

            _skillConversationReferenceKey = skillConversationReferenceKey;
            _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
            _bot     = bot ?? throw new ArgumentNullException(nameof(bot));
            _conversationIdFactory = conversationIdFactory ?? throw new ArgumentNullException(nameof(conversationIdFactory));
            _getOAuthScope         = getOAuthScope ?? (() => string.Empty);
            _logger = logger ?? NullLogger.Instance;
        }