Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add catalog db context
            EFConfiguration.ConfigureService(services, Configuration);

            // IOC containers / Entity Framework
            StationeryConfiguration.ConfigureService(services);
            CatalogConfiguration.ConfigureService(services);

            // config connections options
            ConfigurationOptions.ConfigureService(services, this.Configuration);

            ManagerConfiguration.ConfigureService(services);

            // config jwtfactory and authenticatioin
            this.ConfigAuthentication(services);

            // Add framework services.
            services.AddLogging();
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });

            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Beispiel #2
0
        public void config(IServiceCollection services)
        {
            JwtSetting.Audience          = Configuration.GetSection("JwtTokenValues")["audience"].ToString();
            JwtSetting.Issuer            = Configuration.GetSection("JwtTokenValues")["issuer"].ToString();
            JwtSetting.SecreteKey        = Configuration.GetSection("JwtTokenValues")["securityKey"].ToString();
            JwtSetting.ExpairesInMinutes = Convert.ToInt32(Configuration.GetSection("JwtTokenValues")["expairesInMinutes"]);

            EFConfiguration.ConfigureService(services, Configuration);
            AspNetIdentityConfiguration.ConfigureService(services, Configuration);
            AuthenticationConfiguration.ConfigureService(services, Configuration);
            IocConfigurationRepository.ConfigureService(services, Configuration);
            IocConfigurationService.ConfigureService(services, Configuration);

            services.AddTransient <IDataBaseManager, DataBaseManager>();
            services.AddScoped(
                x => new ConnectionSetting(Configuration.GetConnectionString("DefaultConnection"))
                );
            services.AddScoped <SpHelper>();
        }