// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { RepositoryModule.Register(services, Configuration.GetConnectionString("DefaultConnection"), GetType().Assembly.FullName); ServicesModule.Register(services); services.AddMvc(option => option.EnableEndpointRouting = false).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //services.AddControllers(); }
public static void RegisterServices(this Container container) { UnitOfWorkModule.Register(container); ServicesModule.Register(container); RepositoryModule.Register(container); DbContextModule.Register(container); }
/// <inheritdoc /> /// <summary> /// Register's the application module /// </summary> /// <param name="container">The reference to the DryIOC container</param> public void Register(IContainer container) { var configuration = Startup.Configuration; CommonWebApiModules.Register(container, configuration); ServicesModule.Register(container); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IDataSeed>(new DataSeed()); RepositoryModule.Register(services, Configuration.GetConnectionString("DefaultConnection"), GetType().Assembly.FullName); ServicesModule.Register(services); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "CrossOver API Documentation", Version = "v1", Description = "This API makes use of json response", Contact = new Contact() { Email = "*****@*****.**", Name = "Emad Hamdy" } }); //c.AddSecurityDefinition("Bearer", new ApiKeyScheme() { In = "header", Description = "Please insert JWT with Bearer into field", Name = "Authorization", Type = "apiKey" }); //c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>> // { // { "Bearer", new string[]{ } }, // { "Basic", new string[]{ } }, // }); // Set the comments path for the Swagger JSON and UI. var basePath = PlatformServices.Default.Application.ApplicationBasePath; var xmlPath = Path.Combine(basePath, "XOProject.Api.xml"); c.IncludeXmlComments(xmlPath); }); services.AddMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { RepositoryModule.Register(services, Configuration.GetConnectionString("DefaultConnection"), GetType().Assembly.FullName); ServicesModule.Register(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IDataSeed>(new DataSeed()); RepositoryModule.Register(services, Configuration.GetConnectionString("DefaultConnection"), GetType().Assembly.FullName); ServicesModule.Register(services); services.AddMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { RepositoryModule.Register(services, Configuration.GetConnectionString("DefaultConnection"), GetType().Assembly.FullName); ServicesModule.Register(services); services.AddMvc(option => option.EnableEndpointRouting = false).SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddCors(allowsites => { allowsites.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .CreateLogger(); services.Configure <FormOptions>(options => { options.ValueLengthLimit = int.MaxValue; options.MultipartBodyLengthLimit = int.MaxValue; options.MemoryBufferThreshold = int.MaxValue; }); services.AddScoped(typeof(IGenericRepository <>), typeof(GenericRepository <>)); //Register services ServicesModule.Register(services); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); // ASP.NET Core DI services.AddScoped <ApplicationContext, ApplicationContext>(); //services.AddDbContext<ApplicationContext>(options => options.UseSqlServer(Configuration.GetConnectionString(SQLSERVER_CONNECTION_STRING_KEY))); services.AddDbContext <ApplicationContext>(options => options.UseInMemoryDatabase(databaseName: "HaunDb")); services.AddControllersWithViews(); services.AddTransient <IUnitOfWork, UnitOfWork>(); //Fluent Validator services.AddControllersWithViews().AddFluentValidation(opt => { opt.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly()); }); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = OPEN_API_TITLE, Version = "v1" }); //c.OperationFilter<ExamplesOperationFilter>(); }); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
public static void Register(IServiceCollection services, IConfiguration configuration) { InfrastructuteModule.Register(services, configuration); ServicesModule.Register(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.WithOrigins("http://localhost:4200") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddSignalR(); services.AddControllersWithViews(); ServicesModule.Register(services); SignalRModule.SignalR(services); services.Configure <ConnectionSettings>(Configuration.GetSection("ConnectionStrings")); services.AddDbContext <DatabaseContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddScoped <IDatabaseContext, DatabaseContext>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <ILoggerManager, LoggerManager>(); services.AddScoped(typeof(IGenericRepository <>), typeof(GenericRepository <>)); services.AddTransient <IContextFactory, ContextFactory>(); services.AddTransient <IUnitOfWork, UnitOfWork>(); services.AddControllersWithViews(); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "TestProject", Version = "v1" }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, Description = "Please insert JWT with Bearer into field", Name = "Authorization", Type = SecuritySchemeType.ApiKey }); c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } }, new string[] { } } }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); // configure strongly typed settings objects var appSettingsSection = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); // configure jwt authentication var appSettings = appSettingsSection.Get <AppSettings>(); var key = Encoding.ASCII.GetBytes(appSettings.Secret); 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 }; }); }
protected override void Load(ContainerBuilder builder) { ServicesModule.Register(builder); DatabaseModule.Register(builder); IdentityModule.Register(builder); }
protected override void Load(ContainerBuilder builder) { ServicesModule.Register(builder); }