Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddCors(options =>
            {
                options.AddPolicy(name: MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:4200/")
                    .AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.Add(new ServiceDescriptor(typeof(IDiaryService), typeof(DiaryService), ServiceLifetime.Scoped));
            services.Add(new ServiceDescriptor(typeof(IDiaryDataManager), typeof(DiaryDataManager), ServiceLifetime.Scoped));

            BaseDataManager.Configure(Configuration["ConnectionStrings:Diary"]);
        }