Skip to content

Commit

Permalink
Replace ContainerBuilder.Update with Conversation.UpdateContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
pcostantini committed Jun 13, 2017
1 parent 4104733 commit 34fc91f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 63 deletions.
18 changes: 9 additions & 9 deletions CSharp/core-CustomState/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ protected void Application_Start()
Uri docDbServiceEndpoint = new Uri(ConfigurationManager.AppSettings["DocumentDbServiceEndpoint"]);
string docDbEmulatorKey = ConfigurationManager.AppSettings["DocumentDbAuthKey"];

var builder = new ContainerBuilder();
Conversation.UpdateContainer(builder =>
{
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
var store = new DocumentDbBotDataStore(docDbServiceEndpoint, docDbEmulatorKey);
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();

var store = new DocumentDbBotDataStore(docDbServiceEndpoint, docDbEmulatorKey);
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();

builder.Update(Conversation.Container);
});

GlobalConfiguration.Configure(WebApiConfig.Register);
}
Expand Down
12 changes: 5 additions & 7 deletions CSharp/core-GlobalMessageHandlers/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ protected void Application_Start()

private void RegisterBotModules()
{
var builder = new ContainerBuilder();

builder.RegisterModule(new ReflectionSurrogateModule());

builder.RegisterModule<GlobalMessageHandlersBotModule>();

builder.Update(Conversation.Container);
Conversation.UpdateContainer(builder =>
{
builder.RegisterModule(new ReflectionSurrogateModule());
builder.RegisterModule<GlobalMessageHandlersBotModule>();
});
}
}
}
7 changes: 4 additions & 3 deletions CSharp/core-Middleware/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
var builder = new ContainerBuilder();
builder.RegisterType<DebugActivityLogger>().AsImplementedInterfaces().InstancePerDependency();
builder.Update(Conversation.Container);
Conversation.UpdateContainer(builder =>
{
builder.RegisterType<DebugActivityLogger>().AsImplementedInterfaces().InstancePerDependency();
});

GlobalConfiguration.Configure(WebApiConfig.Register);
}
Expand Down
27 changes: 13 additions & 14 deletions CSharp/demo-CardsAttachments/public-TestBot/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@ protected void Application_Start()

private void RegisterBotDependencies()
{
var builder = new ContainerBuilder();

builder
.Register(c => new ActivityLogger(c.Resolve<IBotData>()))
.As<IActivityLogger>()
.InstancePerLifetimeScope();

foreach (var commandType in CommandsHelper.GetRegistrableTypes())
Conversation.UpdateContainer(builder =>
{
builder
.RegisterType(commandType)
.Keyed(commandType.Name, commandType)
.AsImplementedInterfaces()
.InstancePerMatchingLifetimeScope(DialogModule.LifetimeScopeTag);
}
.Register(c => new ActivityLogger(c.Resolve<IBotData>()))
.As<IActivityLogger>()
.InstancePerLifetimeScope();

builder.Update(Conversation.Container);
foreach (var commandType in CommandsHelper.GetRegistrableTypes())
{
builder
.RegisterType(commandType)
.Keyed(commandType.Name, commandType)
.AsImplementedInterfaces()
.InstancePerMatchingLifetimeScope(DialogModule.LifetimeScopeTag);
}
});
}
}
}
29 changes: 14 additions & 15 deletions CSharp/demo-Search/JobListingBot/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@ public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
ContainerBuilder builder = new ContainerBuilder();
Conversation.UpdateContainer(builder =>
{
builder.RegisterType<IntroDialog>()
.As<IDialog<object>>()
.InstancePerDependency();

builder.RegisterType<IntroDialog>()
.As<IDialog<object>>()
.InstancePerDependency();
builder.RegisterType<JobsMapper>()
.Keyed<IMapper<DocumentSearchResult, GenericSearchResult>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.RegisterType<JobsMapper>()
.Keyed<IMapper<DocumentSearchResult, GenericSearchResult>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.RegisterType<AzureSearchClient>()
.Keyed<ISearchClient>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.Update(Conversation.Container);
builder.RegisterType<AzureSearchClient>()
.Keyed<ISearchClient>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();
});

GlobalConfiguration.Configure(WebApiConfig.Register);
}
Expand Down
29 changes: 14 additions & 15 deletions CSharp/demo-Search/RealEstateBot/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ public class WebApiApplication : HttpApplication
{
protected void Application_Start()
{
ContainerBuilder builder = new ContainerBuilder();
Conversation.UpdateContainer(builder =>
{
builder.RegisterType<IntroDialog>()
.As<IDialog<object>>()
.InstancePerDependency();

builder.RegisterType<IntroDialog>()
.As<IDialog<object>>()
.InstancePerDependency();
builder.RegisterType<RealEstateMapper>()
.Keyed<IMapper<DocumentSearchResult, GenericSearchResult>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.RegisterType<RealEstateMapper>()
.Keyed<IMapper<DocumentSearchResult, GenericSearchResult>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.RegisterType<AzureSearchClient>()
.Keyed<ISearchClient>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();

builder.Update(Conversation.Container);
builder.RegisterType<AzureSearchClient>()
.Keyed<ISearchClient>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();
});

GlobalConfiguration.Configure(WebApiConfig.Register);
}
Expand Down

0 comments on commit 34fc91f

Please sign in to comment.