public PathFinderTxtHandlerTest()
        {
            var services = new ServiceCollection();

            InjectorBootStrapper.RegisterServices(services);
            _shortestPathFinder = services.BuildServiceProvider().GetService <IShortestPathFinderService>();
        }
Ejemplo n.º 2
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.º 4
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.º 5
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.º 6
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.º 8
0
        private void RegisterServices(IServiceCollection services)
        {
            var connection = string.Format(Configuration["ConnectionStrings:SqliteConnection"], AppDomain.CurrentDomain.BaseDirectory);

            InjectorBootStrapper.RegisterServices(services, connection);
        }
Ejemplo n.º 9
0
 private static void RegisterServices(IServiceCollection services)
 {
     // Adding dependencies from another layers (isolated from Presentation)
     NativeInjectorBootStrapper.RegisterServices(services);
     InjectorBootStrapper.RegisterServices(services);
 }
Ejemplo n.º 10
0
 private static void RegisterServices(IServiceCollection services)
 {
     InjectorBootStrapper.RegisterServices(services);
 }
Ejemplo n.º 11
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.º 13
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
        }