Esempio n. 1
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder
            .Register((c, p) => p.TypedAs <HttpRequestMessage>())
            .AsSelf()
            .InstancePerMatchingLifetimeScope(LifetimeScopeTag);

            builder
            .RegisterType <CallingContext>()
            .AsSelf()
            .InstancePerMatchingLifetimeScope(LifetimeScopeTag);

            builder
            .Register(c => CallingBotServiceSettings.LoadFromCloudConfiguration())
            .AsSelf()
            .SingleInstance();

            builder
            .Register(c => new CallingBotService(c.Resolve <CallingBotServiceSettings>()))
            .AsSelf()
            .As <ICallingBotService>()
            .SingleInstance();
        }
Esempio n. 2
0
        /// <summary>
        ///     Instantiates CallingBotService using provided settings
        /// </summary>
        /// <param name="settings"></param>
        public CallingBotService(CallingBotServiceSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            _callbackUrl = settings.CallbackUrl;
        }
Esempio n. 3
0
        /// <summary>
        /// Loads core bot library configuration from the cloud service configuration
        /// </summary>
        /// <returns>MessagingBotServiceSettings</returns>
        public static CallingBotServiceSettings LoadFromCloudConfiguration()
        {
            CallingBotServiceSettings settings;

            try
            {
                settings = new CallingBotServiceSettings
                {
                    CallbackUrl = ConfigurationManager.AppSettings.Get("Microsoft.Bot.Builder.Calling.CallbackUrl")
                };
            }
            catch (Exception e)
            {
                throw new BotConfigurationException(
                          "A mandatory configuration item is missing or invalid", e);
            }

            settings.Validate();
            return(settings);
        }
        /// <summary>
        /// Loads core bot library configuration from the cloud service configuration
        /// </summary>
        /// <returns>MessagingBotServiceSettings</returns>
        public static CallingBotServiceSettings LoadFromCloudConfiguration()
        {
            CallingBotServiceSettings settings;

            try
            {
                settings = new CallingBotServiceSettings
                {
                    CallbackUrl = ConfigurationManager.AppSettings.Get("Microsoft.Bot.Builder.Calling.CallbackUrl")
                };
            }
            catch (Exception e)
            {
                throw new BotConfigurationException(
                    "A mandatory configuration item is missing or invalid", e);
            }

            settings.Validate();
            return settings;
        }