Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            InjectorBootStrapper.UpdateDatabase(app);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseSwaggerDocumentation();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        public PathFinderTxtHandlerTest()
        {
            var services = new ServiceCollection();

            InjectorBootStrapper.RegisterServices(services);
            _shortestPathFinder = services.BuildServiceProvider().GetService <IShortestPathFinderService>();
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.OutputFormatters.Remove(new XmlDataContractSerializerOutputFormatter());
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            services.AddSwaggerGen(s =>
            {
                s.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Test Project - Restaurante Ordering",
                    Description = "Equinox API Swagger surface",
                    Contact     = new OpenApiContact {
                        Name = "Thiago Ribeiro", Email = "*****@*****.**"
                    },
                    License = new OpenApiLicense {
                        Name = "MIT"
                    }
                });
            });

            InjectorBootStrapper.RegisterServices(services);
            InjectorBootStrapper.ConfigureMappings(services);
            InjectorBootStrapper.InitMemoryDb();
        }
        public static void AddDependencyInjectionConfiguration(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            InjectorBootStrapper.RegisterServices(services);
        }
Ejemplo n.º 5
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterForNavigation <NavigationPage>();
            containerRegistry.RegisterForNavigation <MainPage, MainPageViewModel>();
            containerRegistry.RegisterForNavigation <CartPage, CartPageViewModel>();

            InjectorBootStrapper.RegisterTypes(containerRegistry);
            containerRegistry.RegisterForNavigation <CheckoutPage, CheckoutPageViewModel>();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var services = new ServiceCollection();

            InjectorBootStrapper.RegisterServices(services);
            services.AddMediatR(typeof(Program));
            var serviceProvider = services.BuildServiceProvider();


            var bus = serviceProvider.GetService <IMediatorHandler>();

            bus.SendCommand(new CadastroClienteCommand());
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            new HostBuilder()
            .ConfigureAppConfiguration((hostingContext, config) =>
            {
                config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
            })
            .ConfigureServices((hostContext, services) =>
            {
                InjectorBootStrapper.RegisterServices(services);

                services.AddSingleton <IHostedService, MigrationRunner>();
            })
            .RunConsoleAsync();
        }
Ejemplo n.º 8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            // In production, the Angular files will be served from this directory
            services.AddDbContext <DataContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddAutoMapper(typeof(CoreMapper));
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.AddScoped(typeof(IBaseValidate <>), typeof(OperationValidator <>));
            services.AddTransient(typeof(ILogger <>), (typeof(Logger <>)));
            services.AddAutoMapper(typeof(CoreMapper).Assembly);

            services.AddMediatR();
            InjectorBootStrapper.CreateServiceProvider(services);
        }
Ejemplo n.º 9
0
        //https://go.microsoft.com/fwlink/?LinkID=398940


        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CommonSettings>(Configuration.GetSection("CommonSettings"));
            services.Configure <ConnectionDB>(Configuration.GetSection("ConnectionDB"));

            services.Configure <FZSettings44>(Configuration.GetSection("FzSettings44"));
            services.Configure <FZSettings223>(Configuration.GetSection("FzSettings223"));

            services.Configure <NsiSettings44>(Configuration.GetSection("NsiSettings44"));
            services.Configure <NsiSettings223>(Configuration.GetSection("NsiSettings223"));

            services.AddSingleton <ILoggerFactory, LoggerFactory>();
            services.AddSingleton(typeof(ILogger <>), typeof(Logger <>));
            services.AddLogging((conf) => conf.SetMinimumLevel(LogLevel.Trace));
            services.AddEntityFrameworkNpgsql();


            InjectorBootStrapper.RegisterServices(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.AddSwaggerGen(options => {
                options.SwaggerDoc("v1",
                                   new OpenApiInfo
                {
                    Title       = "Menor caminho para entrega de encomendas",
                    Version     = "v1",
                    Description = @"Esta API é responsável em manter as operações necessárias para calcular o melhor caminho 
                            e tempo de entrega de encomendas.",
                    Contact     = new OpenApiContact
                    {
                        Name = "Daniel Carvalho Souza",
                        Url  = new Uri("https://github.com/danielcarvalhosouza")
                    },
                });
                options.IncludeXmlComments(GetXmlCommentsPath(), true);
            });

            InjectorBootStrapper.RegisterServices(services);
        }
Ejemplo n.º 11
0
        private void RegisterServices(IServiceCollection services)
        {
            var connection = string.Format(Configuration["ConnectionStrings:SqliteConnection"], AppDomain.CurrentDomain.BaseDirectory);

            InjectorBootStrapper.RegisterServices(services, connection);
        }
Ejemplo n.º 12
0
 private static void RegisterServices(IServiceCollection services)
 {
     // Adding dependencies from another layers (isolated from Presentation)
     NativeInjectorBootStrapper.RegisterServices(services);
     InjectorBootStrapper.RegisterServices(services);
 }
Ejemplo n.º 13
0
 private static void RegisterServices(IServiceCollection services)
 {
     InjectorBootStrapper.RegisterServices(services);
 }
Ejemplo n.º 14
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     InjectorBootStrapper.RegisterServices(services, Configuration);
 }
 public static void AddInjectorBootstrapper(this IServiceCollection services, IConfiguration configuration)
 {
     InjectorBootStrapper.RegisterServices(services, configuration);
 }
Ejemplo n.º 16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            #region "  Configure MVC and JSON Serialize options  "

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };

                opt.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                opt.SerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore;
                opt.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                opt.SerializerSettings.DateFormatString      = "yyyy-MM-ddTHH:mm:ss";
                opt.SerializerSettings.Culture               = new System.Globalization.CultureInfo("en-US");
                opt.SerializerSettings.Formatting            = Formatting.None;
                opt.SerializerSettings.FloatFormatHandling   = FloatFormatHandling.DefaultValue;
                opt.SerializerSettings.FloatParseHandling    = FloatParseHandling.Double;
                opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                opt.SerializerSettings.TypeNameHandling      = TypeNameHandling.None;
            })
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <UserValidator>());;

            #endregion

            #region "  Configure Dependency Injection  "

            InjectorBootStrapper.RegisterServices(services);

            var tokenConfig = new TokenConfigurations();
            Configuration.Bind("TokenConfigurations", tokenConfig);

            var signingConfigurations = new SigningConfigurations();

            services.AddSingleton(tokenConfig);
            services.AddSingleton(signingConfigurations);

            #endregion

            #region "  Configure one transation per HTTP Call  "

            services.AddScoped((serviceProvider) =>
            {
                var wow = serviceProvider.GetService <IUnitOfWork>();

                wow.Open();

                return(wow.BeginTransaction());
            });

            services.AddScoped(typeof(UnitOfWorkFilter));

            services.Configure <MvcOptions>(options =>
            {
                options.Filters.AddService <UnitOfWorkFilter>(1);
            });

            #endregion

            #region "  Configure API Result  "

            services.AddScoped(typeof(APIResultFilter));

            services.Configure <MvcOptions>(options =>
            {
                options.Filters.AddService <APIResultFilter>(2);
            });

            #endregion

            #region "  Configure Auth  "

            ConfigureAuth(services, signingConfigurations);

            #endregion
        }