Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <KestrelServerOptions>(options =>
            {
                options.Limits.MaxRequestBodySize = int.MaxValue;                 // if don't set default value is: 30 MB
            });
            services.Configure <IISServerOptions>(options =>
            {
                options.MaxRequestBodySize = int.MaxValue;
            });
            services.Configure <FormOptions>(options =>
            {
                options.ValueLengthLimit            = int.MaxValue;
                options.MultipartBodyLengthLimit    = int.MaxValue;              // if don't set default value is: 128 MB
                options.MultipartHeadersLengthLimit = int.MaxValue;
            });
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "Files API",
                    Version = "v1"
                });
            });
            //App Settings Injection
            services.Configure <MongoDBAppSettings>(Configuration.GetSection("MongoDBAppSettings"));
            services.Configure <LiteDBAppSettings>(Configuration.GetSection("LiteDBAppSettings"));

            //services.AddSingleton<IStorageService, FilesService>();
            services.AddScoped <IStorageService, StorageService>();
            services.AddSingleton <ISettingsService, SettingsService>();
            services.AddScoped <IStorageRepository, StorageRepository>();
            services.AddScoped <IFileDetailsRepository, FileDetailsRepository>();

            services.AddScoped <RecordDownloadHandler>();
            services.AddScoped <EventHandlerContainer>();
            EventHandlerContainer.Subscribe <FileDownloadedEvent, RecordDownloadHandler>();

            services.AddControllers();
        }
        // 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_2);

            services.AddScoped <IOrderManager, OrderManager>();
            services.AddScoped <IShoppingCartManager, ShoppingCartManager>();
            services.AddScoped <IShoppingCartRepository, ShoppingCartRepository>();
            services.AddScoped <IOrderRepository, OrderRepository>();
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.AddScoped <CreateOrderHandler>();
            services.AddScoped <EventHandlerContainer>();
            services.AddScoped <ConfirmEmailSentHandler>();


            EventHandlerContainer.Subscribe <ShoppingCartSubmittedEvent, CreateOrderHandler>();
            EventHandlerContainer.Subscribe <ShoppingCartSubmittedEvent, ConfirmEmailSentHandler>();
        }