コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //Configuração do Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version     = "v1",
                    Title       = "Api Taxa de Juros",
                    Description = "Retorna taxa de juros",
                    Contact     = new Contact
                    {
                        Name  = "Estêvão Braga",
                        Email = "*****@*****.**",
                        Url   = "https://github.com/estevaobraga"
                    }
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            //Injeção de dependência
            Injetor.RegistrarServicos(services);
        }
コード例 #2
0
ファイル: UnityConfig.cs プロジェクト: M4N0V3Y/LaborSafety
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or
        /// API controllers (unless you want to change the defaults), as Unity
        /// allows resolving a concrete type even if it was not previously
        /// registered.
        /// </remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below.
            // Make sure to add a Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your type's mappings here.
            // container.RegisterType<IProductRepository, ProductRepository>();
            Injetor.Inicializar(container);
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("pt-BR");

            var stackTelas = new Stack <ITela>(2);

            stackTelas.Push(Injetor.PreencherTela());

            var telaAtual = stackTelas.Peek();

            while (stackTelas.TryPeek(out telaAtual))
            {
                Console.Clear();

                Console.WriteLine("SIMULAÇÂO DE JUROS COMPOSTO : A qualquer instante digite \"SAIR\" para sair do sistema e \"VOLTAR\" para voltar à tela anterior");
                Console.WriteLine();
                Console.WriteLine("Digite a opção do menu desejado e der ENTER");
                Console.WriteLine();
                telaAtual.Renderizar();
                Console.WriteLine();

                var entrada = Console.ReadLine();

                if (entrada.ToUpperInvariant() == BotoesEnum.SAIR.ToString())
                {
                    return;
                }
                if (entrada.ToUpperInvariant() == BotoesEnum.VOLTAR.ToString())
                {
                    if (!stackTelas.TryPop(out telaAtual))
                    {
                        return;
                    }
                    continue;
                }
                var telaAcao = telaAtual.TratarEntradaValor(entrada);

                if (telaAcao != null)
                {
                    stackTelas.Push(telaAcao);
                }
            }
        }
コード例 #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            string mySqlConnectionStr = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContextPool <DataContext>(options =>
                                                    options
                                                    .UseMySql(mySqlConnectionStr, ServerVersion.AutoDetect(mySqlConnectionStr))
                                                    .UseLazyLoadingProxies());
            Injetor.Injetar(services);
            services.AddControllers();

            var key = Encoding.ASCII.GetBytes(TokenSettings.Chave);

            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
                };
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "BExpress.Api", Version = "v1"
                });
            });
        }
コード例 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            Injetor.InjetarDependecias(services);

            //services.AddTransient<Contexto>();
            //services.AddTransient<IUnitOfWork, IUnitOfWork>();
            //services.AddTransient(typeof(IRepositoryBase<>), typeof(RepositoryBase<>));
            //services.AddTransient<IAnuncioRepository, AnuncioRepository>();

            //services.AddTransient(typeof(IServiceBase<>), typeof(IServiceBase<>));
            //services.AddTransient<IAnuncioService, AnuncioService>();


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }