예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <ImageWizardOptions>(Configuration.GetSection("General"));
            services.Configure <HttpLoaderOptions>(Configuration.GetSection("HttpLoader"));
            services.Configure <FileCacheSettings>(Configuration.GetSection("FileCache"));
            services.Configure <FileLoaderOptions>(Configuration.GetSection("FileLoader"));
            services.Configure <MongoDBCacheOptions>(Configuration.GetSection("MongoDBCache"));

            services.AddControllersWithViews();
            services.AddRazorPages();

            string cache = Configuration.GetSection("General")["Cache"];

            IImageWizardBuilder imageWizard = services.AddImageWizard()
                                              .AddImageSharp()
                                              .AddSvgNet()
                                              .AddDocNET()
                                              .AddHttpLoader()
                                              .AddFileLoader()
                                              .AddYoutubeLoader()
                                              .AddGravatarLoader()
                                              .AddAnalytics();

            switch (cache)
            {
            case "InMemory":
                imageWizard.SetDistributedCache();
                break;

            case "File":
                imageWizard.SetFileCache();
                break;

            case "MongoDB":
                imageWizard.SetMongoDBCache();
                break;

            default:
                throw new Exception("unknown cache type selected");
            }

            services.Configure <ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
            });
        }
예제 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <ImageWizardOptions>(Configuration.GetSection("General"));
            services.Configure <HttpLoaderOptions>(Configuration.GetSection("HttpLoader"));
            services.Configure <FileCacheSettings>(Configuration.GetSection("FileCache"));
            services.Configure <FileLoaderOptions>(Configuration.GetSection("FileLoader"));
            services.Configure <MongoDBCacheOptions>(Configuration.GetSection("MongoDBCache"));

            services.AddControllersWithViews();
            services.AddRazorPages();

            string cache = Configuration.GetSection("General")["Cache"];

            IImageWizardBuilder imageWizard = services.AddImageWizard()
                                              .AddImageSharp()
                                              .AddSvgNet()
                                              .AddHttpLoader()
                                              .AddFileLoader()
                                              .AddYoutubeLoader()
                                              .AddGravatarLoader()
                                              .AddImageSharp()
                                              .AddAnalytics();

            switch (cache)
            {
            case "InMemory":
                imageWizard.SetDistributedCache();
                break;

            case "File":
                imageWizard.SetFileCache();
                break;

            case "MongoDB":
                imageWizard.SetMongoDBCache();
                break;

            default:
                throw new Exception("unknown cache type selected");
            }

            services.AddHttpsRedirection(x => { x.RedirectStatusCode = StatusCodes.Status301MovedPermanently; x.HttpsPort = 443; });
        }