/// <summary>
        /// Configured detault DI services.
        /// </summary>
        /// <param name="serviceCollection">The DI service collection.</param>
        /// <param name="environmentService">The environment of the skill.</param>
        protected void ConfigureServices(IServiceCollection serviceCollection, IEnvironmentService environmentService = null)
        {
            IEnvironmentService configuredEnvironmentService;

            if (environmentService == null)
            {
                // Standard dotnet environment service.
                EnvironmentService defaultEnvironmentService = new EnvironmentService();
                serviceCollection.AddSingleton <IEnvironmentService>(defaultEnvironmentService);
                configuredEnvironmentService = defaultEnvironmentService;
            }
            else
            {
                // Unit Testing Environment Service
                serviceCollection.AddSingleton(environmentService);
                configuredEnvironmentService = environmentService;
            }


            // Add the configurations
            ConfigurationService configurationService = new ConfigurationService(configuredEnvironmentService);

            serviceCollection.AddSingleton <IConfigurationService>(configurationService);

            // Add Flagscript Alexa Configuration
            IConfiguration           configuration            = configurationService.GetConfiguration();
            AlexaLambdaConfiguration alexaLambdaConfiguration = configuration
                                                                .GetSection(AlexaLambdaConfiguration.Configurationname)
                                                                .Get <AlexaLambdaConfiguration>();

            serviceCollection.AddSingleton(alexaLambdaConfiguration);

            // Add aws options for unit test and development
            if (configuredEnvironmentService.IsUnitTest || configuredEnvironmentService.IsDevelopment)
            {
                serviceCollection.AddDefaultAWSOptions(configuration.GetAWSOptions());
            }

            // Add logging
            serviceCollection.AddLogging(builder =>
                                         builder.AddConfiguration(configurationService.GetConfiguration().GetSection("Logging"))
                                         );
        }
        /// <summary>
        /// Default Constructor.
        /// </summary>
        protected AlexaSkillRequestHandlerLambda(IEnvironmentService environmentService = null)
        {
            // Set up Dependency Injection
            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection, environmentService);
            ServiceProvider = serviceCollection.BuildServiceProvider();

            // Get service from DI system
            ConfigurationService = ServiceProvider.GetService <IConfigurationService>();

            // Configure Logging
            ConfigureLogging(ServiceProvider);

            // Setup Logger
            AlexaLambdaConfiguration alexaLambdaConfiguration = ServiceProvider.GetService <AlexaLambdaConfiguration>();
            ILoggerFactory           loggerFactory            = ServiceProvider.GetService <ILoggerFactory>();

            Logger = loggerFactory.CreateLogger(alexaLambdaConfiguration.AlexaLoggerCategory);
        }
        /// <summary>
        /// Configures default aws logging for the alexa skill.
        /// </summary>
        /// <param name="serviceProvider">The DI service provider.</param>
        protected void ConfigureLogging(IServiceProvider serviceProvider)
        {
            IEnvironmentService environmentService = serviceProvider.GetService <IEnvironmentService>();
            ILoggerFactory      loggerFactory      = serviceProvider.GetService <ILoggerFactory>();
            IConfiguration      configuration      = ConfigurationService.GetConfiguration();

            // Add Console and Debug logging in development/unittest.
            if (environmentService.IsUnitTest || environmentService.IsDevelopment)
            {
                loggerFactory.AddConsole(configuration.GetSection("Logging"));
                loggerFactory.AddDebug();
            }

            // Add AWS logging, optional.
            AlexaLambdaConfiguration alexaLambdaConfiguration = serviceProvider.GetService <AlexaLambdaConfiguration>();

            if (alexaLambdaConfiguration.EnableAlexaLogger)
            {
                loggerFactory.AddAWSProvider(configuration.GetAWSLoggingConfigSection());
            }
        }