forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContosoFlowersModule.cs
72 lines (60 loc) · 2.98 KB
/
ContosoFlowersModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace ContosoFlowers
{
using System.Configuration;
using Autofac;
using BotAssets;
using BotAssets.Dialogs;
using Dialogs;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Internals.Fibers;
using Microsoft.Bot.Builder.Location;
using Microsoft.Bot.Builder.Scorables;
using Microsoft.Bot.Connector;
using Services.Models;
public class ContosoFlowersModule : Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType<ContosoFlowersDialogFactory>()
.Keyed<IContosoFlowersDialogFactory>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
builder.RegisterType<RootDialog>()
.As<IDialog<object>>()
.InstancePerDependency();
builder.RegisterType<SettingsScorable>()
.As<IScorable<IActivity, double>>()
.InstancePerLifetimeScope();
builder.RegisterType<FlowerCategoriesDialog>()
.InstancePerDependency();
builder.RegisterType<BouquetsDialog>()
.InstancePerDependency();
builder.RegisterType<SavedAddressDialog>()
.InstancePerDependency();
builder.RegisterType<SettingsDialog>()
.InstancePerDependency();
// Location Dialog
// ctor signature: LocationDialog(string apiKey, string channelId, string prompt, LocationOptions options = LocationOptions.None, LocationRequiredFields requiredFields = LocationRequiredFields.None, LocationResourceManager resourceManager = null);
builder.RegisterType<LocationDialog>()
.WithParameter("apiKey", ConfigurationManager.AppSettings["MicrosoftBingMapsKey"])
.WithParameter("options", LocationOptions.UseNativeControl | LocationOptions.ReverseGeocode)
.WithParameter("requiredFields", LocationRequiredFields.StreetAddress | LocationRequiredFields.Locality | LocationRequiredFields.Country)
.WithParameter("resourceManager", new ContosoLocationResourceManager())
.InstancePerDependency();
// Service dependencies
builder.RegisterType<Services.InMemoryOrdersService>()
.Keyed<Services.IOrdersService>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<Services.InMemoryBouquetRepository>()
.Keyed<Services.IRepository<Bouquet>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<Services.InMemoryFlowerCategoriesRepository>()
.Keyed<Services.IRepository<FlowerCategory>>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance();
}
}
}