protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); BundleConfig.RegisterBundles(BundleTable.Bundles); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Microsoft.Bot.Connector.IMessageActivity, Data.Activity>() .ForMember(dest => dest.FromId, opt => opt.MapFrom(src => src.From.Id)) .ForMember(dest => dest.RecipientId, opt => opt.MapFrom(src => src.Recipient.Id)) .ForMember(dest => dest.FromName, opt => opt.MapFrom(src => src.From.Name)) .ForMember(dest => dest.RecipientName, opt => opt.MapFrom(src => src.Recipient.Name)); }); var builder = new ContainerBuilder(); builder.RegisterType <EntityFrameworkActivityLogger>().AsImplementedInterfaces().InstancePerDependency(); var store = new SqlBotDataStore("ConversationDataContextConnectionString"); builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.LastWriteWins)) .As <IBotDataStore <BotData> >() .AsSelf() .InstancePerLifetimeScope(); builder.Update(Conversation.Container); }
public static void Configure() { ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType <RootDialog>().InstancePerDependency(); builder.RegisterType <QnAMakerService>().Keyed <IQnAMakerService>(FiberModule.Key_DoNotSerialize).AsImplementedInterfaces(); #region BotState var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["SqlDatabase.ConnectionString"].ConnectionString); builder.Register(c => store) .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy .ETagBasedConsistency)) .As <IBotDataStore <BotData> >() .AsSelf() .InstancePerLifetimeScope(); #endregion builder.Update(container: Conversation.Container); }
protected void Application_Start(object sender, EventArgs e) { { // http://docs.autofac.org/en/latest/integration/webapi.html#quick-start var builder = new ContainerBuilder(); // register the Bot Builder module builder.RegisterModule(new DialogModule()); // register the alarm dependencies builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly())); builder .RegisterInstance(new EchoDialog()) .As <IDialog <object> >(); var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["BotDataContextConnectionString"].ConnectionString); builder.Register(c => store) .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency)) .As <IBotDataStore <BotData> >() .AsSelf() .InstancePerLifetimeScope(); // Get your HttpConfiguration. var config = GlobalConfiguration.Configuration; // Register your Web API controllers. builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); // OPTIONAL: Register the Autofac filter provider. builder.RegisterWebApiFilterProvider(config); // Set the dependency resolver to be Autofac. //var container = builder.Build(); builder.Update(Conversation.Container); config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container); } // WebApiConfig stuff GlobalConfiguration.Configure(config => { config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); var builder = new ContainerBuilder(); builder.RegisterModule(new DialogModule()); var store = new SqlBotDataStore("BotDataContextConnectionString"); builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.LastWriteWins)) .As <IBotDataStore <BotData> >() .AsSelf() .InstancePerLifetimeScope(); builder.Update(Conversation.Container); }
protected void Application_Start(object sender, EventArgs e) { { var config = GlobalConfiguration.Configuration; Conversation.UpdateContainer( builder => { builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly())); var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["BotDataContextConnectionString"].ConnectionString); builder.Register(c => store) .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); // Register your Web API controllers. builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterWebApiFilterProvider(config); }); config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container); } // WebApiConfig stuff GlobalConfiguration.Configure(config => { config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }); }