Esempio n. 1
0
 public void ConfigureServices(IServiceCollection services)
 {
     ServiceConfiguration.Configure(services, Configuration);
     DependencyResolver.Resolve(services, Configuration);
     ServiceResolver.Resolve(services);
     MapperResolver.Resolve(services);
 }
Esempio 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.AddDbContext <RadixNotificationContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            //services.AddMvc(options =>
            //{
            //    options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            //});

            services.AddMvc();
            services.AddSingleton <IConfiguration>(Configuration);

            //Automapper Configuration
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfileConfiguration());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            RepositoryConfiguration.Configure(services);
            ServiceConfiguration.Configure(services);

            // DataTables.AspNet registration with default options.
            services.RegisterDataTables();
        }
Esempio n. 3
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            ServiceConfiguration.Configure(config);

            app.UseWebApi(config);
        }
Esempio n. 4
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            ServiceConfiguration.Configure(GlobalConfiguration.Configuration);

            routes.MapRoute("default", "{controller}/{action}/{id}",
                            new { controller = "Home", action = "Index", id = UrlParameter.Optional });
        }
Esempio n. 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 <RabbitMqOptions>(Configuration.GetSection("RabbitMq"));
            services.Configure <ConsulOptions>(Configuration.GetSection("Consul"));

            services.AddControllers();
            services.AddRabbitMq();
            services.AddConsul();

            ServiceConfiguration.Configure(services);
        }
Esempio n. 6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddDbContext <ClassroomSailorDbContext>(options =>
                                                      options.UseSqlServer(this.Configuration.GetConnectionString("Default")));
     services.AddScoped <ITeacherEntityFactory <TeacherApiModel>, TeacherEntityFactory <TeacherApiModel> >();
     services.AddScoped <IStudentEntityFactory <StudentApiModel>, StudentEntityFactory <StudentApiModel> >();
     services.AddScoped <IClassroomSailorUserService <StudentApiModel>, StudentService <StudentApiModel> >();
     services.AddScoped <IClassroomSailorUserService <TeacherApiModel>, TeacherService <TeacherApiModel> >();
     RepositoryConfiguration.Configure(services);
     ServiceConfiguration.Configure(services);
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ServiceConfiguration.Configure(Configuration);

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

            app.UseMvc();

            ConfigureEventBus(app);
        }
Esempio n. 8
0
        public void ConfigureServices(IServiceCollection services)
        {
            //services.Configure<RabbitMqOptions>(Configuration.GetSection("RabbitMq"));
            //services.Configure<ConsulOptions>(Configuration.GetSection("Consul"));

            var connectionString = Configuration.GetConnectionString("CatalogConnection");

            services.AddOptions <string>(connectionString);

            services.AddControllers();
            //services.AddRabbitMq();
            //services.AddConsul();

            ServiceConfiguration.Configure(services, connectionString);
        }
Esempio n. 9
0
        static void Main()
        {
            var config = new HttpSelfHostConfiguration(new Uri("http://localhost:9200"));

            ServiceConfiguration.Configure(config);

            var host = new HttpSelfHostServer(config);

            host.OpenAsync().Wait();

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();

            host.CloseAsync().Wait();
        }
        /// <summary>Integrates Unity when the application starts.</summary>
        public static void Start()
        {
            var container = UnityConfig.GetConfiguredContainer();

            FilterProviders.Providers.Remove(FilterProviders.Providers.OfType <FilterAttributeFilterProvider>().First());
            FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));

            var serviceConfiguration = new ServiceConfiguration();

            serviceConfiguration.Configure(container);

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));

            // TODO: Uncomment if you want to use PerRequestLifetimeManager
            // Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
        }
Esempio n. 11
0
        public async Task RunAsync()
        {
            var services = new ServiceCollection();                   // Create a new instance of a service collection

            ServiceConfiguration.Configure(services, Configuration);  // Add services to service collection

            var provider = services.BuildServiceProvider();           // Build the service provider

            provider.GetRequiredService <CommandHandler>();           // Start the command handler service
            provider.GetRequiredService <EventHandler>();             // Start the event handler service


            await DiscordConfiguration.ConfigureAndRun(provider, Configuration); //Configures and starts the discord socket client

            await Task.Delay(-1);                                                // Keep the program alive
        }
Esempio n. 12
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile(
                path: "appsettings.json",
                optional: false,
                reloadOnChange: true);

            var configuration = builder.Build();

            _container = ServiceConfiguration.Configure(configuration);
            _rpcServer = RpcServerConfiguration.Configure(_container, configuration);

            _rpcServer.Start();

            return(Task.CompletedTask);
        }
        public void ConfigureServices(IServiceCollection services)
        {
            ServiceConfiguration.Configure(Configuration.GetConnectionString("IAFProjectDatabase"), services);

            #region JWT token configuration

            var appSettingsSection = Configuration.GetSection("AppSettings");
            services.Configure <AppSettings>(appSettingsSection);
            AppSettings appSettings = appSettingsSection.Get <AppSettings>();

            ServiceConfiguration.Authenticate(services, appSettings.Secret);

            #endregion

            ServiceConfiguration.ConfigureServices(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(opt => opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver());
        }
        public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration configuration)
        {
            #region DB Congfig
            services.AddDbContext <FacilitDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("DbConnection")));
            //services.AddDbContext<FacilitDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("Server=172.20.1.177;Database=FacilitTest;User ID=dev;Password=B1ost@rR3@der;Trusted_Connection=False;")));
            #endregion

            #region Services

            ServiceConfiguration.Configure(services);

            #endregion

            #region Repositories

            RepositoryConfiguration.ConfigureRepositories(services);

            #endregion

            return(services);
        }
Esempio n. 15
0
 static void Main(string[] args)
 {
     ServiceConfiguration.Configure();
 }
Esempio n. 16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Swagger Configuration
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Cinema App Api", Description = "Swagger Cinema App Api"
                });
            });

            //Automapper Configuration
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            //DataConfiguration
            services.AddDbContext <CinemaContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddSingleton <IJwtFactory, JwtFactory>();

            // jwt wire up
            // Get options from app settings
            var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));

            // Configure JwtIssuerOptions
            services.Configure <JwtIssuerOptions>(options =>
            {
                options.Issuer             = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
                options.Audience           = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)];
                options.SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256);
            });

            // api user claim policy
            services.AddAuthorization(options =>
            {
                options.AddPolicy("ApiUser", policy => policy.RequireClaim(Constants.Strings.JwtClaimIdentifiers.Rol, Constants.Strings.JwtClaims.ApiAccess));
            });

            services.AddIdentity <AppUser, IdentityRole>
                (o =>
            {
                // configure identity options
                o.Password.RequireDigit           = false;
                o.Password.RequireLowercase       = false;
                o.Password.RequireUppercase       = false;
                o.Password.RequireNonAlphanumeric = false;
                o.Password.RequiredLength         = 6;
            })
            .AddEntityFrameworkStores <CinemaContext>()
            .AddDefaultTokenProviders();


            //Application Services and Repositories
            RepositoryConfiguration.Configure(services);
            ServiceConfiguration.Configure(services);

            services.AddCors(options =>
            {
                options.AddPolicy("AllowNGApp", builder =>
                {
                    builder.AllowAnyOrigin();
                    builder.AllowAnyMethod();
                    builder.AllowAnyHeader();
                });
            });

            services.AddMvc()
            .AddJsonOptions(
                options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                );

            // DataTables.AspNet registration with default options.
            services.RegisterDataTables();
        }
Esempio n. 17
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     ServiceConfiguration.Configure(app, env);
 }