示例#1
0
 private void GetAllDependency(IServiceCollection services)
 {
     services.AddSingleton <IAuthorizationHandler, TokenPolicyHandler>();
     DLLDependency.ALLDependency(services);
     BLLDependency.AllDependency(services);
     UtilityDependency.AllDependency(services);
 }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Inject appsettings (3rd Section)
            services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings"));

            services.AddControllers();
            services.AddControllers().AddNewtonsoftJson();

            DLLDependency.AllDependency(services, Configuration);

            services.AddCors();

            //Jwt Authentication (1st Section)

            var key = Encoding.UTF8.GetBytes(Configuration["ApplicationSettings:Jwt_Secret"].ToString());

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(x => {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = false;
                x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false,
                    ClockSkew = TimeSpan.Zero
                };
            });
        }
示例#3
0
文件: Startup.cs 项目: keenedy/API
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            SetupSwagger(services);

            services.AddApiVersioning(config =>
            {
                config.DefaultApiVersion = new ApiVersion(1, 0);
                config.AssumeDefaultVersionWhenUnspecified = true;
            });

            DLLDependency.AllDependency(services, Configuration);
        }
示例#4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            SetupSwagger(services);
            services.AddApiVersioning(config =>
            {
                // Specify the default API Version as 1.0
                config.DefaultApiVersion = new ApiVersion(1, 0);
                // If the client hasn't specified the API version in the request, use the default API version number
                config.AssumeDefaultVersionWhenUnspecified = true;
            });

            DLLDependency.AllDependency(services, Configuration);
        }
示例#5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddFluentValidation().AddNewtonsoftJson(
                opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);;

            SetupSwegger(services);

            services.AddApiVersioning(config =>
            {
                // Specify the default API Version as 1.0
                config.DefaultApiVersion = new ApiVersion(1, 0);
                // If the client hasn't specified the API version in the request, use the default API version number
                config.AssumeDefaultVersionWhenUnspecified = true;
            });

            DLLDependency.AllDependency(services, Configuration);
            BLLDependency.AllDependency(services, Configuration);
        }
示例#6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers()
     .AddFluentValidation()
     .AddNewtonsoftJson();
     //.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<StudentCreateRequestViewModelValidator>());
     ;
     services.AddApiVersioning(config =>
     {
         config.DefaultApiVersion = new ApiVersion(1, 0);
         config.AssumeDefaultVersionWhenUnspecified = true;
         config.ReportApiVersions = true;
         config.ApiVersionReader  = new HeaderApiVersionReader("api-version");
     });
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new OpenApiInfo {
             Title = "WebApplication1", Version = "v1"
         });
     });
     DLLDependency.AllDependency(services, Configuration);
     BLLDependency.AllDependency(services);
 }
示例#7
0
 private void GetAllDependency(IServiceCollection services)
 {
     DLLDependency.ALLDependency(services);
     BLLDependency.ALLDependency(services);
 }
示例#8
0
 private void AddALLExternalDependency(IServiceCollection services)
 {
     DLLDependency.Dependency(services);
 }