Exemplo n.º 1
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)
        {
            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);
        }
Exemplo n.º 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);
        }