public static void RegisterServices(IServiceCollection services) { var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new ServicesMapperProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); services.AddSingleton(mapper); RepositoriesInjector.RegisterServices(services); ServicesInjector.RegisterServices(services); var key = Encoding.ASCII.GetBytes(SecuritySettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); }
public static void AddDependencyInjectionConfiguration(this IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } ServicesInjector.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddRazorPages().AddRazorRuntimeCompilation(); //Database Settings services.AddDatabaseConfiguration(Configuration); //Transient/scoped/singleton services ServicesInjector.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //API Configs services.AddControllers(); //Database configs services.AddDatabaseConfiguration(Configuration); //Transient/scoped/singleton services ServicesInjector.RegisterServices(services); }