diff --git a/skills/csharp/calendarskill/Startup.cs b/skills/csharp/calendarskill/Startup.cs index e4f650b928..ff7a7645e7 100644 --- a/skills/csharp/calendarskill/Startup.cs +++ b/skills/csharp/calendarskill/Startup.cs @@ -60,7 +60,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/emailskill/Startup.cs b/skills/csharp/emailskill/Startup.cs index 8518a2bb47..a18ba8a308 100644 --- a/skills/csharp/emailskill/Startup.cs +++ b/skills/csharp/emailskill/Startup.cs @@ -58,7 +58,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/experimental/automotiveskill/Startup.cs b/skills/csharp/experimental/automotiveskill/Startup.cs index fbd01d9379..be4f06b57f 100644 --- a/skills/csharp/experimental/automotiveskill/Startup.cs +++ b/skills/csharp/experimental/automotiveskill/Startup.cs @@ -58,7 +58,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/experimental/bingsearchskill/Startup.cs b/skills/csharp/experimental/bingsearchskill/Startup.cs index 994026d3c7..33091cc465 100644 --- a/skills/csharp/experimental/bingsearchskill/Startup.cs +++ b/skills/csharp/experimental/bingsearchskill/Startup.cs @@ -54,7 +54,6 @@ public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/experimental/eventskill/Startup.cs b/skills/csharp/experimental/eventskill/Startup.cs index 6eb808b3bf..4dc821e215 100644 --- a/skills/csharp/experimental/eventskill/Startup.cs +++ b/skills/csharp/experimental/eventskill/Startup.cs @@ -55,8 +55,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/skills/csharp/experimental/hospitalityskill/Startup.cs b/skills/csharp/experimental/hospitalityskill/Startup.cs index 59b8a1a5be..6e20679642 100644 --- a/skills/csharp/experimental/hospitalityskill/Startup.cs +++ b/skills/csharp/experimental/hospitalityskill/Startup.cs @@ -60,8 +60,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/skills/csharp/experimental/itsmskill/Startup.cs b/skills/csharp/experimental/itsmskill/Startup.cs index 94af15334b..8f91ba740d 100644 --- a/skills/csharp/experimental/itsmskill/Startup.cs +++ b/skills/csharp/experimental/itsmskill/Startup.cs @@ -58,8 +58,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/skills/csharp/experimental/musicskill/Startup.cs b/skills/csharp/experimental/musicskill/Startup.cs index 1071726edf..26db64436f 100644 --- a/skills/csharp/experimental/musicskill/Startup.cs +++ b/skills/csharp/experimental/musicskill/Startup.cs @@ -54,8 +54,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/skills/csharp/experimental/newsskill/Startup.cs b/skills/csharp/experimental/newsskill/Startup.cs index b974abf76e..b61b0e21a2 100644 --- a/skills/csharp/experimental/newsskill/Startup.cs +++ b/skills/csharp/experimental/newsskill/Startup.cs @@ -54,7 +54,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/experimental/restaurantbookingskill/Startup.cs b/skills/csharp/experimental/restaurantbookingskill/Startup.cs index c99f69e461..4e2392cdda 100644 --- a/skills/csharp/experimental/restaurantbookingskill/Startup.cs +++ b/skills/csharp/experimental/restaurantbookingskill/Startup.cs @@ -58,7 +58,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/experimental/weatherskill/Startup.cs b/skills/csharp/experimental/weatherskill/Startup.cs index f2f14930b3..0d516c41bc 100644 --- a/skills/csharp/experimental/weatherskill/Startup.cs +++ b/skills/csharp/experimental/weatherskill/Startup.cs @@ -54,7 +54,6 @@ public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/pointofinterestskill/Startup.cs b/skills/csharp/pointofinterestskill/Startup.cs index 8f012cd28e..7f991eafa3 100644 --- a/skills/csharp/pointofinterestskill/Startup.cs +++ b/skills/csharp/pointofinterestskill/Startup.cs @@ -56,7 +56,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/skills/csharp/todoskill/Startup.cs b/skills/csharp/todoskill/Startup.cs index ac427c9740..1455047eb9 100644 --- a/skills/csharp/todoskill/Startup.cs +++ b/skills/csharp/todoskill/Startup.cs @@ -55,7 +55,6 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); // Load settings var settings = new BotSettings(); diff --git a/templates/Skill-Template/csharp/Sample/SkillSample/Startup.cs b/templates/Skill-Template/csharp/Sample/SkillSample/Startup.cs index 92782c53b5..bcda0ec6eb 100644 --- a/templates/Skill-Template/csharp/Sample/SkillSample/Startup.cs +++ b/templates/Skill-Template/csharp/Sample/SkillSample/Startup.cs @@ -55,8 +55,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/templates/Skill-Template/csharp/Template/Skill/Startup.cs b/templates/Skill-Template/csharp/Template/Skill/Startup.cs index 60420a57ec..2e9336b900 100644 --- a/templates/Skill-Template/csharp/Template/Skill/Startup.cs +++ b/templates/Skill-Template/csharp/Template/Skill/Startup.cs @@ -55,8 +55,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings); diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs index 6ebcf71014..58b7cfc297 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs @@ -23,6 +23,8 @@ namespace VirtualAssistantSample.Dialogs { public class MainDialog : RouterDialog { + private const string Location = "location"; + private const string TimeZone = "timezone"; private BotServices _services; private BotSettings _settings; private TemplateEngine _templateEngine; @@ -236,10 +238,10 @@ protected override async Task OnEventActivityAsync(DialogContext innerDc, Cancel case Events.Location: { var locationObj = new JObject(); - locationObj.Add(Events.Location, JToken.FromObject(value)); + locationObj.Add(Location, JToken.FromObject(value)); var skillContext = await _skillContext.GetAsync(innerDc.Context, () => new SkillContext()); - skillContext[Events.Location] = locationObj; + skillContext[Location] = locationObj; await _skillContext.SetAsync(innerDc.Context, skillContext); break; @@ -251,10 +253,10 @@ protected override async Task OnEventActivityAsync(DialogContext innerDc, Cancel { var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(value); var timeZoneObj = new JObject(); - timeZoneObj.Add(Events.TimeZone, JToken.FromObject(timeZoneInfo)); + timeZoneObj.Add(TimeZone, JToken.FromObject(timeZoneInfo)); var skillContext = await _skillContext.GetAsync(innerDc.Context, () => new SkillContext()); - skillContext[Events.TimeZone] = timeZoneObj; + skillContext[TimeZone] = timeZoneObj; await _skillContext.SetAsync(innerDc.Context, skillContext); } catch diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Startup.cs b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Startup.cs index f6f8133cdf..ee72667680 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Startup.cs +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Startup.cs @@ -96,14 +96,16 @@ public void ConfigureServices(IServiceCollection services) services.AddTransient(); // Register skill dialogs - var provider = services.BuildServiceProvider(); foreach (var skill in settings.Skills) { - var userState = provider.GetService(); - var telemetryClient = provider.GetService(); var authDialog = BuildAuthDialog(skill, settings, appCredentials); var credentials = new MicrosoftAppCredentialsEx(settings.MicrosoftAppId, settings.MicrosoftAppPassword, skill.MSAappId); - services.AddTransient(sp => new SkillDialog(skill, credentials, telemetryClient, userState, authDialog)); + services.AddTransient(sp => + { + var userState = sp.GetService(); + var telemetryClient = sp.GetService(); + return new SkillDialog(skill, credentials, telemetryClient, userState, authDialog); + }); } // Configure adapters diff --git a/templates/Virtual-Assistant-Template/csharp/Template/VA/Startup.cs b/templates/Virtual-Assistant-Template/csharp/Template/VA/Startup.cs index e05f400720..4b6dd44250 100644 --- a/templates/Virtual-Assistant-Template/csharp/Template/VA/Startup.cs +++ b/templates/Virtual-Assistant-Template/csharp/Template/VA/Startup.cs @@ -54,8 +54,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - var provider = services.BuildServiceProvider(); - // Load settings var settings = new BotSettings(); Configuration.Bind(settings);