// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var fileDirectory = System.AppDomain.CurrentDomain.BaseDirectory + "SaveFolder";

            if (!Directory.Exists(fileDirectory))
            {
                Directory.CreateDirectory(fileDirectory);
            }

            RootConfig.Entry(services, Configuration);
            #region Swagger Config
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("onkeiapi"
                             , new Info
                {
                    Title = "Onkei Solution"
                    ,
                    Version = "v1.0"
                    ,
                    Description = "ASP.NET Core Onkei Solution API",
                });
                var xmlFile = System.AppDomain.CurrentDomain.BaseDirectory + $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlFile);
            });
            #endregion
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RootConfig.Entry(services, Configuration);
            services.Configure <UserConfiguration>(Configuration.GetSection("UserConfiguration"));
            //services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            //    .AddJwtBearer(options =>
            //    {
            //        options.Audience = "http://dev.authorize.reso.vn";
            //        options.ClaimsIssuer = "http://dev.authorize.reso.vn";
            //        options.Authority = "issuers";
            //    });
            //var DBConnect = this.Configuration.GetConnectionString("DBContext");
            //var IdentityConnect = this.Configuration.GetConnectionString("IdentityContext");
            //services.AddDbContext<ApplicationDbContext>(o =>
            //{
            //    o.UseSqlServer(IdentityConnect);
            //});

            // service context
            //services.AddDbContext<Pea_devContext>(o =>
            //{
            //    o.UseSqlServer(DBConnect);
            //});

            //add identity
            //services.AddIdentity<IdentityUser, IdentityRole>()
            //    .AddEntityFrameworkStores<ApplicationDbContext>()
            //    .AddDefaultTokenProviders();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddMvc(options =>
            {
                // add an instance of the filter, like we used to do it
                //options.Filters.Add(new BlockCustomAttribute());
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Pea API", Version = "v1"
                });
                c.AddSecurityDefinition("Bearer", new ApiKeyScheme {
                    In = "header", Description = "Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey"
                });
                c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > {
                    { "Bearer", Enumerable.Empty <string>() },
                });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                //c.DocumentFilter<ApplyDocumentVendorExtensions>();
                c.IncludeXmlComments(xmlPath);
            });

            services.AddMvc();
        }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RootConfig.Entry(services, Configuration);

            services.AddCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigin", builder =>
                                  builder
                                  .AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });

            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RootConfig.Entry(services, Configuration);

            services.AddImageSharpCore()
            .SetRequestParser <QueryCollectionRequestParser>()
            .SetMemoryAllocatorFromMiddlewareOptions()
            .SetCache(provider => new PhysicalFileSystemCache(
                          provider.GetRequiredService <IHostingEnvironment>(),
                          provider.GetRequiredService <MemoryAllocator>(),
                          provider.GetRequiredService <IOptions <ImageSharpMiddlewareOptions> >())
            {
                Settings =
                {
                    [PhysicalFileSystemCache.Folder] = PhysicalFileSystemCache.DefaultCacheFolder
                }
            })
            .SetCacheHash <CacheHash>()
            .AddProvider <PhysicalFileSystemProvider>()
            .AddProcessor <ResizeWebProcessor>()
            .AddProcessor <FormatWebProcessor>()
            .AddProcessor <BackgroundColorWebProcessor>();


            services.AddCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigin", builder =>
                                  builder
                                  .AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });

            services.Configure <ForwardedHeadersOptions>(options =>
            {
            });

            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1);

            // Swagger Configuration
            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerDocument(c =>
            {
                c.DocumentName = "Doitsu Fandom Api";
                c.Version      = "1.6";
                c.Title        = "Doitsu Fandom Api";
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RootConfig.Entry(services, Configuration);

            services.AddCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigin", builder =>
                                  builder
                                  .AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1);
            services.Configure <IISOptions>(options =>
            {
                options.ForwardClientCertificate = false;
            });
        }
Exemple #6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     RootConfig.Entry(services, Configuration);
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
 }