Esempio n. 1
0
        /// <summary>
        /// Default constructor. This constructor is used by Lambda to construct the instance. When invoked in a Lambda environment
        /// the AWS credentials will come from the IAM role associated with the function and the AWS region will be set to the
        /// region the Lambda function is executed in.
        /// </summary>
        public ForroLevelLambda()
        {
            var forroAppConfig = new ForroAppConfig
            {
                AWSForroBucketName    = Environment.GetEnvironmentVariable("AWSForroBucketName"),
                AWSRegionEndpoint     = Environment.GetEnvironmentVariable("AWSRegionEndpoint"),
                ForroLevelSNSTopicArn = Environment.GetEnvironmentVariable("ForroLevelSNSTopicArn")
            };

            //Create Dependency Injection Container. Ideally I would use AutoFac, but this for now meets my expectations.
            _serviceCollection = new ServiceCollection();

            //_serviceCollection.
            var forroDependencyInjectionService = new ForroDependencyInjectionService(forroAppConfig);

            forroDependencyInjectionService.DeclareDependencies(_serviceCollection);

            var serviceProvider = _serviceCollection.BuildServiceProvider();

            _forroLevelService = serviceProvider.GetService <IForroLevelService>();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            var forroAppConfig = new ForroAppConfig();

            Configuration.GetSection("ForroAppConfig").Bind(forroAppConfig);

            var forroDependencyInjectionService = new ForroDependencyInjectionService(forroAppConfig);

            forroDependencyInjectionService.DeclareDependencies(services);

            var serviceProvider = services.BuildServiceProvider();
            var nLogConfig      = new NLogConfig(serviceProvider);

            nLogConfig.ConfigNLogToUseAWSCloudWatch();

            EnsureSQSForroLevelCreation(serviceProvider);
            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }