예제 #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()
            // Desabilitar referência circular na serialização dos json
            .AddNewtonsoftJson(opt =>
                               opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);

            // Configuração da injeção de dependencias
            RegisterIoC.Register(services);

            // Configuração do AutoMapper
            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            // Configuração do contexto ef
            //services.AddDbContext<ErrorCenterContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddDbContext <ErrorCenterContext>(options => options.UseNpgsql(Configuration.GetConnectionString("PgConnection")));


            // adicionando CORS
            services.AddCors();

            // Configuração da autenticação
            ConfigureAuth(services);


            ConfigureSwagger(services);
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <Contexto>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            MongoDbContext.ConnectionString = Configuration.GetConnectionString("mongoAtlas");

            RegisterIoC.Register(services);

            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            ConfigurationSwegger(services);

            ConfigurationAuthJWT(services);

            ConfigurationGraphQl(services);

            services.AddControllers()
            .AddNewtonsoftJson(opt =>
            {
                opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
                opt.SerializerSettings.NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore;
            });

            services.AddCors();
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            // Desabilitar referência ciricular na serialização dos JSON
            .AddNewtonsoftJson(opt =>
            {
                opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
                // Excluíndo os valores NULL do json, evitando assim que seja trafegado dados desnecessários
                opt.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            });

            // Configuração da injeção de dependências
            RegisterIoC.Register(services);

            // Configuração do AutoMapper
            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            // Configurando o EntityFramework (SQL SERVER)
            services.AddDbContext <AceleraDevContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            // Configuração do mongoDb
            MongoDbContext.ConnectionString = Configuration.GetConnectionString("mongoAtlas");

            // Configuração da autenticação JWT
            ConfigureAuth(services);

            // Configuração Swagger
            ConfiguracaoSwagger(services);
        }
예제 #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()
            // Desabilitar referência circular na serialiazção dos json
            .AddNewtonsoftJson(opt =>
            {
                opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                opt.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
            });

            // Configuração da injeção de dependencias
            RegisterIoC.Register(services);

            // Configuração do AutoMapper
            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            // Configuração do contexto ef
            //services.AddDbContext<AceleraDevContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddDbContext <AceleraDevContext>(options => options.UseNpgsql(Configuration.GetConnectionString("PgConnection")));

            // Configuração do mongodb
            MongoDbContext.ConnectionString = Configuration.GetConnectionString("mongodb");

            // adicionando CORS
            services.AddCors();

            ConfigureAuth(services);

            ConfigureSwagger(services);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            //adiciona conf. para tirar ref. circular na serialzaição
            .AddNewtonsoftJson(opt =>
                               opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);

            //localizer
            services.AddLocalization(opts => {
                opts.ResourcesPath = "Resources";
            });

            //mapeia localizer para view (não vou usar mas...) e data annotation (isso é interessante)
            services.AddMvc()
            .AddViewLocalization(
                opts => { opts.ResourcesPath = "Resources"; })
            .AddViewLocalization(Microsoft.AspNetCore.Mvc.Razor.LanguageViewLocationExpanderFormat.Suffix)
            .AddDataAnnotationsLocalization();

            //configura cultura com base nas requisições
            services.Configure <RequestLocalizationOptions>(opts =>
            {
                //configuração das culturas suportadas (fazem localizer chavear entre os recursos de linguagens difernetes
                //adicionar culturas que serão suportadas
                var suportedCultures = new List <CultureInfo>
                {
                    new CultureInfo("pt-BR"),
                    new CultureInfo("en-US")
                };

                //*** para setar outracoisa pode-se passar na query ?culture=en-US ou setar o header Accept-Language = en-US
                opts.DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("pt-BR");
                // formatação de numeros, datas, etc.
                opts.SupportedCultures = suportedCultures;
                //string de UI (não uso mas...)
                opts.SupportedUICultures = suportedCultures;
            });

            //ver ativação da cultura pela requisição no método Configure()

            // minha injeção de depedencia
            RegisterIoC.Register(services);

            // config. o automapper
            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            // config do Context (EF)
            services.AddDbContext <SaveTheCookTowerContext>(opions => opions.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            // adicionando CORS
            services.AddCors();


            // Configuração da autenticação
            ConfigureAuth(services);

            //configura doc. da api
            ConfigureSwagger(services);
        }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     services.AddDbContext <FutebaDbContext>();
     services.AddDbContext <ApplicationDbContext>();
     RegisterIoC.Register(services);
     ConfigureSecurity(services);
     ConfigureAutoMapper(services);
     services.AddCors();
     services.AddMvc();
 }
예제 #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            // Configuração da injeção de dependencias
            RegisterIoC.Register(services);

            // Configuração do AutoMapper
            services.AddAutoMapper(typeof(AutoMappingDomainToViewModel));
            services.AddAutoMapper(typeof(AutoMappingViewModelToDomain));

            // Configuração do contexto ef
            services.AddDbContext <ErrorCenterContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
        }
예제 #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);



            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            Code.RegisterPagesNavigation.Run();

            RegisterIoC.Run();
            Xamarin.Forms.Forms.Init(this, bundle);


            LoadApplication(new XForms.App());
        }
예제 #9
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                throw new ArgumentException("Please enter a csv file.");
            }
            if (args.Length != 1)
            {
                throw new ArgumentException("Only one argument should be informed.");
            }

            var file = args[0];

            var travelRouteController = RegisterIoC.Get <ITravelRouteController>();

            travelRouteController.Initialize(file);
        }
예제 #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(
                options => options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
            {
                ValidateActor            = true,
                ValidateAudience         = true,
                ValidateLifetime         = true,
                ValidateIssuerSigningKey = true,
                ValidIssuer      = Configuration["Issuer"],
                ValidAudience    = Configuration["Audience"],
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SigningKey"]))
            });

            services.AddDbContext <AdminCoreDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("localConnection")));
            return(RegisterIoC.Register(services));
        }