Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Bind Database
            string connection = Configuration.GetConnectionString("Default");

            ProxiesServiceCollectionExtensions.AddEntityFrameworkProxies(services);
            services.AddDbContext <CollegeDbContext>(
                options => options.UseSqlServer(connection,
                                                sqlServerOptionsAction: sqlOptions =>
            {
                sqlOptions.EnableRetryOnFailure(
                    maxRetryCount: 5,
                    maxRetryDelay: TimeSpan.FromSeconds(10),
                    errorNumbersToAdd: null);
            }));

            services.AddScoped <IDepartmentService, DepartmentService>();
            services.AddScoped <ICourseService, CourseService>();
            services.AddScoped <IFacultyService, FacultyService>();
            services.AddScoped <IStudentService, StudentService>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }
Beispiel #2
0
        /// <summary>
        /// Add and configure any of the middleware
        /// </summary>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="configuration">Configuration root of the application</param>
        public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
        {
            ProxiesServiceCollectionExtensions.AddEntityFrameworkProxies(services);

            //compression
            services.AddResponseCompression(options => {
                options.EnableForHttps = true;
                options.MimeTypes      = ResponseCompressionDefaults.MimeTypes.Concat(new [] { "image/png", "image/jpeg", "image/gif", "image/x-icon" });
            });

            //add options feature
            services.AddOptions();

            //add memory cache
            services.AddMemoryCache();

            //add distributed memory cache
            services.AddDistributedMemoryCache();

            //add HTTP sesion state feature
            services.AddHttpSession();

            //add anti-forgery
            services.AddAntiForgery();

            //add localization
            services.AddLocalization();

            //add theme support
            services.AddThemes();

            //add gif resizing support
            //new PrettyGifs().Install(Config.Current);
        }