Exemplo n.º 1
0
        public static IAppBuilder UseContainer(this IAppBuilder app, HttpConfiguration config)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var rabbitUri = ConfigurationManager.AppSettings["rabbit"];
            var token     = ConfigurationManager.AppSettings["token"];
            var client    = new AlchemyClient("ab5ff507c8d6e3e7d4019b4e81451a6b0bf147c0", "https://gateway-a.watsonplatform.net/calls");

            var container = new UnityContainer();

            container.RegisterInstance(client);
            container.RegisterType <ITelegramBotClient, TelegramBotClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(token));
            container.RegisterInstance(app.GetLoggerFactory().Create("WebHooks"));
            container.RegisterType <IBot, GenerativeBot>();
            app.UseMassTransit(rabbitUri, container);


            config.DependencyResolver = new UnityDependencyResolver(container);
            return(app);
        }
Exemplo n.º 2
0
 public GenerativeBot(AlchemyClient client)
 {
     _client = client;
 }