Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {

            #region Token Bearer
            services.AddJwtAuthentication(Path.Combine(_env.ContentRootPath, "./Security"), "RsaKey.json", "noobs", "http://leadisjourney.fr");
            #endregion

            services.AddNHibernate(Configuration.GetConnectionString("type"), Configuration.GetConnectionString("DefaultConnection"));

            // Add framework services.
            services.AddMvc();
            services.AddCors(option => option.AddPolicy("AllowAll", p =>
            {
                p.AllowAnyOrigin();
                p.AllowCredentials();
                p.AllowAnyMethod();
                p.AllowAnyHeader();
            }));

            // Adding ioc Autofac
            var containerBuilder = new ContainerBuilder();
            containerBuilder.Populate(services);

            containerBuilder.RegisterModule<GlobalRegistration>();
            var container = containerBuilder.Build();
            return container.Resolve<IServiceProvider>();
        }
 // This method gets called by a runtime.
 // Use this method to add services to the container
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
     // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
     // services.AddWebApiConventions();
 }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<ApplicationDbContext>(options =>
                    options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();

            // Create the Autofac container builder.
            var builder = new ContainerBuilder();
            // Add any Autofac modules or registrations.
            builder.RegisterModule(new ServiceModule());
            // Populate the services.
            builder.Populate(services);
            // Build the container.
            var container = builder.Build();
            // Resolve and return the service provider.
            return container.Resolve<IServiceProvider>();
        }
Exemple #4
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     // Add framework services.
     services.AddMvc();
     services.AddSingleton<ITodoRepository, TodoRepository>();
     services.AddSingleton<TaskManagerRepository>();
 }
        // This method gets called by a runtime.
        // Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.ConfigureCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigins",
                    builder => builder.WithOrigins("http://localhost:15831")
                                        .AllowAnyHeader()
                                        .AllowAnyMethod()
                                        .AllowCredentials()
                                        .Build());
            });

            //services.AddAuthorization(options =>
            //{
            //    options.AddPolicy("GetTokenClaims",
            //        policy => policy.Requirements.Add(new Karama.Resources.Aspnet5.Controllers.GetTokenClaimsRequirement()));
            //});

            services.AddAuthorization(options =>
            {
                options.AddPolicy("GetTokenClaims",
                    policy => policy.RequireClaim("role", "gettokenclaims"));
            });



            services.AddMvc();
            // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
            // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
            // services.AddWebApiConventions();
        }
 public void ConfigureServices(IServiceCollection services)
 { 
     services.AddGlimpse() 
             .RunningAgentWeb()
             .RunningServerWeb()
                 .WithLocalAgent(); 
 }
Exemple #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            services.AddInstance<IMulaRepository>(new MulaRepository());
        }
Exemple #8
0
        public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
        {
            services.AddEntityFramework()
              .AddSqlServer()
              .AddDbContext<ApplicationDbContext>(options =>
                    options.UseSqlServer(configuration["Data:DefaultConnection:ConnectionString"]));

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            // Add framework services.
            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver =
                    new CamelCasePropertyNamesContractResolver();
            });

            // Add CORS support
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAllOrigins",
                    builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            });

            services.AddScoped<IUsersRepository, AspNetIdentityUsersRepository>();
            services.AddScoped<IUserClaimsRepository, AspNetIdentityUserClaimsRepository>();
        }
Exemple #9
0
 // Set up application services
 public void ConfigureServices(IServiceCollection services)
 {
     // Add MVC services to the services container
     services.AddMvc();
     services.AddInstance(new MyService());
     services.AddScoped<ViewService, ViewService>();
 }
        private static void BuildAndFill(IServiceCollection serviceCollection, ServiceDescriptorsBuilder builder)
        {
            builder.AddTypesProvider(new ExistingServiceCollectionTypesProvider(serviceCollection));
            var serviceDescriptors = builder.Build();

            MergeServiceDescriptions(serviceCollection, serviceDescriptors);
        }
Exemple #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFrameworkSqlServer()
                .AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration["Data:ConnectionString"]));

            services
                .AddIdentity<ApplicationUser, ApplicationRole>(options =>
                {
                    options.Password.RequiredLength = 6;
                    options.Password.RequireDigit = false;
                    options.Password.RequireLowercase = false;
                    options.Password.RequireNonAlphanumeric = false;
                    options.Password.RequireUppercase = false;

                    options.Lockout.AllowedForNewUsers = false;

                    options.SignIn.RequireConfirmedEmail = false;
                    options.SignIn.RequireConfirmedPhoneNumber = false;
                })
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders()
                .AddUserStore<MyUserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, string>>()
                .AddRoleStore<MyRoleStore<ApplicationRole, ApplicationDbContext, string>>();

            // Add framework services.
            services.AddMvc();
        }
 public void ConfigureServices(IServiceCollection services)
 {
     // Configure AtsOption for NLog.Extensions.AzureTableStorage
     services.ConfigureAts(options => {
         options.StorageAccountConnectionString = Configuration["AppSettings:StorageAccountConnectionString"];
     });
 }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<DomainModelSqliteContext>();

            services.AddEntityFramework()
                            .AddSqlServer()
                            .AddDbContext<DomainModelMsSqlServerContext>();

            JsonOutputFormatter jsonOutputFormatter = new JsonOutputFormatter
            {
                SerializerSettings = new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                }
            };

            services.AddMvc(
                options =>
                {
                    options.OutputFormatters.Clear();
                    options.OutputFormatters.Insert(0, jsonOutputFormatter);
                }
            );

            // Use a SQLite database
            services.AddScoped<IDataAccessProvider, DataAccessSqliteProvider>();

            // Use a MS SQL Server database
            //services.AddScoped<IDataAccessProvider, DataAccessMsSqlServerProvider>();
        }
Exemple #14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            //cambiar dependiendo los contextos y cadenas
            //de conexión que tengas
            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<ApplicationDbContext>(options =>
                    options.UseSqlServer(Configuration["Data:ShellDBContextConnection"]));


            services.AddScoped<SeedContext>();



            //services.AddEntityFramework()
            //    .AddSqlServer()
            //    .AddDbContext<Context>();


            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();

            // Add application services.
            services.AddTransient<IEmailSender, AuthMessageSender>();
            services.AddTransient<ISmsSender, AuthMessageSender>();
        }
Exemple #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            services.Configure<AppConfig>(Configuration.GetSection("AppConfig"));
        }
Exemple #16
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.Configure<CorsOptions>(options =>
            {
                options.AddPolicy(
                    "AllowAnySimpleRequest",
                    builder =>
                    {
                        builder.AllowAnyOrigin()
                               .WithMethods("GET", "POST", "HEAD");
                    });

                options.AddPolicy(
                    "AllowSpecificOrigin",
                    builder =>
                    {
                        builder.WithOrigins("http://example.com");
                    });

                options.AddPolicy(
                    "WithCredentials",
                    builder =>
                    {
                        builder.AllowCredentials()
                               .WithOrigins("http://example.com");
                    });

                options.AddPolicy(
                    "WithCredentialsAnyOrigin",
                    builder =>
                    {
                        builder.AllowCredentials()
                               .AllowAnyOrigin()
                               .AllowAnyHeader()
                               .WithMethods("PUT", "POST")
                               .WithExposedHeaders("exposed1", "exposed2");
                    });

                options.AddPolicy(
                    "AllowAll",
                    builder =>
                    {
                        builder.AllowCredentials()
                               .AllowAnyMethod()
                               .AllowAnyHeader()
                               .AllowAnyOrigin();
                    });

                options.AddPolicy(
                    "Allow example.com",
                    builder =>
                    {
                        builder.AllowCredentials()
                               .AllowAnyMethod()
                               .AllowAnyHeader()
                               .WithOrigins("http://example.com");
                    });
            });
        }
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services
                .AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<TemplateContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

            services.AddMvc().Configure<MvcOptions>(options =>
            {
                // Support Camelcasing in MVC API Controllers
                int position = options.OutputFormatters.ToList().FindIndex(f => f is JsonOutputFormatter);

                var formatter = new JsonOutputFormatter()
                {
                    SerializerSettings = new JsonSerializerSettings()
                    {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    }
                };

                options.OutputFormatters.Insert(position, formatter);
            });

            ConfigureRepositories(services);
        }
Exemple #18
0
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
                .AddJsonOptions(opt =>
                {
                    opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // makes api results use camel case
                });

            services.AddLogging();

            services.AddScoped<CoordService>();

            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<WorldContext>();

            services.AddTransient<WorldContextSeedData>();

            services.AddScoped<IWorldRepository, WorldRepository>();

#if DEBUG
            services.AddScoped<IMailService, DebugMailService>();
#else
            services.AddScoped<IMailService, MailService>(); // or something like that 
#endif
        }
Exemple #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // dependency injection containers
        public void ConfigureServices(IServiceCollection services)
        {

           // addjsonoptions -> dataobjecten naar camelCase ipv .net standaard wanneer men ze parsed, gemakkelijker voor js
            services.AddMvc(/*config =>
            {
                 //hier kan men forcen voor naar https versie van site te gaan, werkt momenteel niet, geen certificaten
                 config.Filters.Add(new RequireHttpsAttribute()); 
            }*/)
                .AddJsonOptions(opt =>
                {
                    opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                });

            services.AddLogging();

            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<CatalogusContext>();
            
            services.AddIdentity<Gebruiker, IdentityRole>(config =>
            {
                //todo requirements voor login
                config.User.RequireUniqueEmail = true;
                config.Password.RequiredLength = 8;

                //route gebruikers naar loginpagina als ze afgeschermde url proberen te bereiken
                config.Cookies.ApplicationCookie.LoginPath = "/Auth/Login";

                //dit zorgt ervoor dat api calls niet naar loginpagina gereroute worden maar een echte error teruggeven aan de api caller
                config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
                {
                    OnRedirectToLogin = ctx =>
                    {
                        if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == (int)HttpStatusCode.OK)
                        {
                            //kijkt of er api call wordt gedaan en geeft dan correcte httpstatus terug, zodat de caller weet dat hij niet genoeg rechten heeft
                            ctx.Response.StatusCode = (int) HttpStatusCode.Unauthorized;
                        }
                        else
                        {
                            //Standaard gedrag
                            ctx.Response.Redirect(ctx.RedirectUri);
                        }

                        return Task.FromResult(0);
                    }
                };
            })
            .AddEntityFrameworkStores<CatalogusContext>();

            //Moet maar1x opgeroept worden, snellere garbage collect
            services.AddTransient<CatalogusContextSeedData>();

            services.AddScoped<ICatalogusRepository, CatalogusRepository>();

            //eigen services toevoegen , bijv mail
            //momenteel debugMail ingevoerd
            services.AddScoped<IMailService, DebugMailService>();
        }
Exemple #20
0
 // Set up application services
 public void ConfigureServices(IServiceCollection services)
 {
     // Add MVC services to the services container
     services.AddMvc();
     services.AddSingleton<ICompilerCache, CustomCompilerCache>();
     services.AddSingleton<CompilerCacheInitialiedService>();
 }
Exemple #21
0
        // Set up application services
        public void ConfigureServices(IServiceCollection services)
        {
            services.ConfigureRouting(
                routeOptions => routeOptions.ConstraintMap.Add(
                    "IsbnDigitScheme10",
                    typeof(IsbnDigitScheme10Constraint)));

            services.ConfigureRouting(
                routeOptions => routeOptions.ConstraintMap.Add(
                    "IsbnDigitScheme13",
                    typeof(IsbnDigitScheme10Constraint)));

            // Update an existing constraint from ConstraintMap for test purpose.
            services.ConfigureRouting(
                routeOptions =>
                {
                    if (routeOptions.ConstraintMap.ContainsKey("IsbnDigitScheme13"))
                    {
                        routeOptions.ConstraintMap["IsbnDigitScheme13"] =
                            typeof(IsbnDigitScheme13Constraint);
                    }
                });

            // Add MVC services to the services container
            services.AddMvc();
        }
Exemple #22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var cert = new X509Certificate2(Path.Combine(_environment.ApplicationBasePath, "idsrv4test.pfx"), "idsrv3test");
            var builder = services.AddIdentityServer(options =>
        {
                options.SigningCertificate = cert;
            });
            
            builder.AddInMemoryClients(Clients.Get());
            builder.AddInMemoryScopes(Scopes.Get());
            builder.AddInMemoryUsers(Users.Get());

            builder.AddCustomGrantValidator<CustomGrantValidator>();


            // for the UI
            services
                .AddMvc()
                .AddRazorOptions(razor =>
                {
                    razor.ViewLocationExpanders.Add(new CustomViewLocationExpander());
                });
            services.AddTransient<UI.Login.LoginService>();
            services.AddTransient<UI.SignUp.SignUpService>();
            services.AddTransient<ISmsSender, MessageServices>();
            services.Configure<ASPmsSercetCredentials>(Configuration);



        }
        public void ConfigureServices(IServiceCollection services)
        {
            // Add EF services to the services container
            services.AddEntityFramework()
                    .AddSqlServer()
                    .AddDbContext<MusicStoreContext>(options =>
                            options.UseSqlServer(Configuration.Get("Data:DefaultConnection:ConnectionString")));

            // Add MVC services to the services container
            services.AddMvc();

            //Add all SignalR related services to IoC.
            services.AddSignalR();

            //Add InMemoryCache
            services.AddSingleton<IMemoryCache, MemoryCache>();

            // Add session related services.
            services.AddCaching();
            services.AddSession();

            // Configure Auth
            services.Configure<AuthorizationOptions>(options =>
            {
                options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequireClaim("ManageStore", "Allowed").Build());
            });
        }
Exemple #24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            services.AddCors
             (
                 options =>
                 {
                     options.AddPolicy
                     (
                         "AllowSpecificDomains",
                         builder =>
                         {
                    var allowedDomains = new[] { "http://localhost:3000", "https://localhost:5000" };

                    //Load it
                    builder
                                 .WithOrigins(allowedDomains)
                                 .AllowAnyHeader()
                                 .AllowAnyMethod()
                                 .AllowCredentials();
                         }
                     );
                 }
             );
        }
        public void ConfigureServices(IServiceCollection services)
        {
            var documentStore = UseInstalledRavenDocumentStore();
            documentStore.Initialize();

            new ServiceConfigurer(documentStore).ConfigureServices(services);
        }
Exemple #26
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<ApplicationDbContext>();

            services.AddTransient<ApplicationDbContext, ApplicationDbContext>();


            services.AddIdentity<ApplicationUser, IdentityRole>(opt =>
            {
                opt.Password.RequireDigit = false;
                opt.Password.RequireNonLetterOrDigit = false;
                opt.Password.RequireUppercase = false;
                opt.Password.RequireLowercase = false;
                opt.User.AllowedUserNameCharacters = opt.User.AllowedUserNameCharacters + '+';
            })
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();

            // Add application services.
            services.AddTransient<IEmailSender, AuthMessageSender>();
            services.AddTransient<ISmsSender, AuthMessageSender>();

            services.AddSingleton(CreateJSEngine);

        }
Exemple #27
0
 public void ConfigureServices(IServiceCollection services)
 {
     // Add EF services to the services container.
     services.AddEntityFramework(Configuration)
         .AddSqlServer()
         .AddDbContext<MoBContext>();
 }
Exemple #28
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add Entity Framework services to the services container.
            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<ApplicationDbContext>(options =>
                    options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

            // Add Identity services to the services container.
            services.AddIdentity<ApplicationUser, IdentityRole>(m =>
                // Configure Identity
                {
                    m.Password.RequireUppercase = false;
                    m.Password.RequireLowercase = false;
                    m.Password.RequireNonLetterOrDigit = false;
                    m.Password.RequireDigit = false;
                })
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            // Add MVC services to the services container.
            services.AddMvc();

            // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
            // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
            // services.AddWebApiConventions();

            // Register application services.
            services.AddTransient<IEmailSender, AuthMessageSender>();
            services.AddTransient<ISmsSender, AuthMessageSender>();
        }
Exemple #29
0
        public void ConfigureServices(IServiceCollection services)
        {

            services.ConfigureDataContext(Configuration);

            // Register MyShuttle dependencies
            services.ConfigureDependencies();

            //Add Identity services to the services container
            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<MyShuttleContext>()
                .AddDefaultTokenProviders();

            CookieServiceCollectionExtensions.ConfigureCookieAuthentication(services, options =>
            {
                options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
            });

            // Add MVC services to the services container
            services.AddMvc();

            services
                .AddSignalR(options =>
                {
                    options.Hubs.EnableDetailedErrors = true;
                });

            //Add InMemoryCache
            services.AddSingleton<IMemoryCache, MemoryCache>();
        }
Exemple #30
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllersWithViews();
     services.AddScoped <IEmployeeRepository, EmployeeRepository>();
     services.AddDbContext <AppDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("WebMVCDbConnection")));
 }
Exemple #31
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);
            services.Configure<ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders =
                    ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
            });

            services.AddAuthorization();

            var identityUrl = Configuration["IDENTITY_URL"];
            var publicIdentityUrl = Configuration["IDENTITY_URL_PUB"];

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options =>
            {
                options.Authority = identityUrl;
                options.RequireHttpsMetadata = false;
                options.Audience = "menu-api";
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    NameClaimType = JwtClaimTypes.Name,
                    RoleClaimType = JwtClaimTypes.Role,
                    ValidateIssuer = false
                };
            });

            var connectionString = Configuration.GetConnectionString("MenuDatabaseConnectionString");
            services.AddDbContext<ApplicationDbContext>(options =>
            {
                options.UseNpgsql(connectionString);
            });

            services.AddCors(o => o.AddPolicy("ServerPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .WithExposedHeaders("WWW-Authenticate");
            }));

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
                {
                    Title = "Restaurant - Menu HTTP API",
                    Version = "v1",
                    TermsOfService = "Terms Of Service"
                });

                options.AddSecurityDefinition("oauth2", new OAuth2Scheme
                {
                    Type = "oauth2",
                    Flow = "implicit",
                    AuthorizationUrl = $"{publicIdentityUrl}/connect/authorize",
                    TokenUrl = $"{publicIdentityUrl}/connect/token",
                    Scopes = new Dictionary<string, string>()
                    {
                        { "menu-api", "Restaurant Menu Api" }
                    }
                });
                options.OperationFilter<SecurityRequirementsOperationFilter>();
            });

            services.AddScoped<IAmazonS3>(provider =>
            {
                var configuration = provider.GetService<IConfiguration>();
                var accessKeyId = "";
                var secretKey = "";
                var amazonInstance = new AmazonS3Client(accessKeyId, secretKey, RegionEndpoint.EUCentral1);
                return amazonInstance;
            });

            services.AddScoped<IFileUploadManager, LocalFileUploadManager>();
            services.AddScoped<IFileInfoFacade, FileInfoFacade>();
            services.AddScoped<IRepository<Category>, CategoryRepository>();
            services.AddScoped<IRepository<Food>, FoodRepository>();
            services.AddScoped<IRepository<FoodPicture>, PictureRepository>();
            services.AddScoped<IFoodPictureService, FoodPictureService>();
            services.AddAutoMapper(typeof(Startup).GetTypeInfo().Assembly);
        }
Exemple #32
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContextPool<AppDbContext>(options => options.UseSqlServer(_config.GetConnectionString("EmployeeDBConnection")));
     services.AddMvc().AddXmlSerializerFormatters();
     services.AddScoped<IEmployeeRepository, SqlEmployeeRepository>();
 }
Exemple #33
0
 /// <summary>
 /// 判断指定服务类型是否存在
 /// </summary>
 public static bool AnyServiceType(this IServiceCollection services, Type serviceType)
 {
     return(services.Any(m => m.ServiceType == serviceType));
 }
Exemple #34
0
 /// <summary>
 /// 获取<see cref="IConfiguration"/>配置信息
 /// </summary>
 public static IConfiguration GetConfiguration(this IServiceCollection services)
 {
     return(services.GetSingletonInstanceOrNull <IConfiguration>());
 }
Exemple #35
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     // Add framework services.
     services.AddMvc();
 }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry();

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

            services.Configure<OrganizationOptions>(options => Configuration
                .GetSection("Github")
                .Bind(options));

            services.AddMvc()
                .SetCompatibilityVersion(CompatibilityVersion.Latest)
                .AddRazorRuntimeCompilation();

            services.AddRazorPages(options =>
            {
                options.Conventions.AuthorizeFolder("/Assemblies", RequireOrganizationPolicy);
                options.Conventions.AddPageRoute("/Assemblies/Index", "");
            });

            services.AddSingleton<BlobCodeFileRepository>();
            services.AddSingleton<BlobOriginalsRepository>();
            services.AddSingleton<CosmosReviewRepository>();
            services.AddSingleton<CosmosCommentsRepository>();
            services.AddSingleton<CosmosPullRequestsRepository>();
            services.AddSingleton<DevopsArtifactRepository>();

            services.AddSingleton<ReviewManager>();
            services.AddSingleton<CommentsManager>();
            services.AddSingleton<NotificationManager>();
            services.AddSingleton<PullRequestManager>();

            services.AddSingleton<LanguageService, JsonLanguageService>();
            services.AddSingleton<LanguageService, CSharpLanguageService>();
            services.AddSingleton<LanguageService, CLanguageService>();
            services.AddSingleton<LanguageService, JavaLanguageService>();
            services.AddSingleton<LanguageService, PythonLanguageService>();
            services.AddSingleton<LanguageService, JavaScriptLanguageService>();
            services.AddSingleton<LanguageService, CppLanguageService>();
            services.AddSingleton<LanguageService, GoLanguageService>();
            services.AddSingleton<LanguageService, ProtocolLanguageService>();
            services.AddSingleton<LanguageService, SwiftLanguageService>();
            services.AddSingleton<LanguageService, XmlLanguageService>();

            services.AddAuthentication(options =>
                {
                    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                })
                .AddCookie(options =>
                {
                    options.LoginPath = "/Login";
                    options.AccessDeniedPath = "/Unauthorized";
                })
                .AddOAuth("GitHub", options =>
                {
                    options.ClientId = Configuration["Github:ClientId"];
                    options.ClientSecret = Configuration["Github:ClientSecret"];
                    options.CallbackPath = new PathString("/signin-github");
                    options.Scope.Add("user:email");

                    options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
                    options.TokenEndpoint = "https://github.com/login/oauth/access_token";
                    options.UserInformationEndpoint = "https://api.github.com/user";

                    options.SaveTokens = true;

                    options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
                    options.ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
                    options.ClaimActions.MapJsonKey(ClaimConstants.Login, "login");
                    options.ClaimActions.MapJsonKey(ClaimConstants.Url, "html_url");
                    options.ClaimActions.MapJsonKey(ClaimConstants.Avatar, "avatar_url");
                    options.ClaimActions.MapJsonKey(ClaimConstants.Name, "name");

                    options.Events = new OAuthEvents
                    {
                        OnCreatingTicket = async context =>
                        {
                            var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint);
                            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken);

                            var response = await context.Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.HttpContext.RequestAborted);
                            response.EnsureSuccessStatusCode();

                            var user = JsonDocument.Parse(await response.Content.ReadAsStringAsync());

                            context.RunClaimActions(user.RootElement);
                            if (user.RootElement.TryGetProperty("organizations_url", out var organizationsUrlProperty))
                            {
                                request = new HttpRequestMessage(HttpMethod.Get, organizationsUrlProperty.GetString());
                                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken);

                                response = await context.Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.HttpContext.RequestAborted);
                                response.EnsureSuccessStatusCode();

                                var orgs = JArray.Parse(await response.Content.ReadAsStringAsync());
                                var orgNames = new StringBuilder();

                                bool isFirst = true;
                                foreach (var org in orgs)
                                {
                                    if (isFirst)
                                    {
                                        isFirst = false;
                                    }
                                    else
                                    {
                                        orgNames.Append(",");
                                    }
                                    orgNames.Append(org["login"]);
                                }

                                string msEmail = await GetMicrosoftEmailAsync(context);
                                if (msEmail != null)
                                {
                                    context.Identity.AddClaim(
                                        new Claim(ClaimConstants.Email, msEmail));
                                }
                                context.Identity.AddClaim(new Claim(ClaimConstants.Orgs, orgNames.ToString()));
                            }
                        }
                    };
                });

            services.AddAuthorization();
            services.AddSingleton<IConfigureOptions<AuthorizationOptions>, ConfigureOrganizationPolicy>();

            services.AddSingleton<IAuthorizationHandler, OrganizationRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, CommentOwnerRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, ReviewOwnerRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, RevisionOwnerRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, ApproverRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, AutoReviewModifierRequirementHandler>();
            services.AddSingleton<IAuthorizationHandler, PullRequestPermissionRequirementHandler>();
            services.AddHostedService<ReviewBackgroundHostedService>();
            services.AddHostedService<PullRequestBackgroundHostedService>();
        }
Exemple #37
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<VaccinationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddCors(
                options => options.AddPolicy(
                    "AllowAll",
                    builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials()));

            services.AddMvc();

            services.AddDistributedMemoryCache();

            services.AddIdentity<IdentityUser, IdentityRole>(options =>
                {
                    options.Password.RequireDigit = true;
                    options.Password.RequiredLength = 6;
                    options.Password.RequireLowercase = true;
                    options.Password.RequireUppercase = true;
                    options.Password.RequireNonAlphanumeric = false;
                })
                .AddEntityFrameworkStores<VaccinationDbContext>()
                .AddDefaultTokenProviders();

            services.AddAuthentication(options =>
                {
                    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
                })
                .AddJwtBearer(options =>
                {
                    options.RequireHttpsMetadata = false;
                    options.TokenValidationParameters = new TokenValidationParameters
                    {
                        ValidateIssuer = false,
                        ValidateAudience = false,
                        ValidateLifetime = true,
                        IssuerSigningKey = Constants.AuthOptions.GetSymmetricSecurityKey(),
                        ValidateIssuerSigningKey = true
                    };
                    options.SaveToken = true;
                });

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
                options.AddSecurityDefinition(
                    "Bearer",
                    new ApiKeyScheme
                    {
                        Description = "Please enter JWT with Bearer into field",
                        Name = "Authorization",
                        In = "header",
                        Type = "apiKey"
                    });
                options.AddSecurityRequirement(
                    new Dictionary<string, IEnumerable<string>> { { "Bearer", Enumerable.Empty<string>() } });
            });

            services.AddScoped<IAnimalsRepository, AnimalsRepository>();
            services.AddScoped<IUsersRepository, UsersRepository>();
            services.AddScoped<IBreedsRepository, BreedsRepository>();
            services.AddScoped<IVaccinesRepository, VaccinesRepository>();
            services.AddScoped<ITreatmentsRepository, TreatmentRepository>();
            services.AddScoped<IWorkTypesRepository, WorkTypesRepository>();
            services.AddScoped<IGraphicsRepository, GraphicsRepository>();
            services.AddScoped<ICallsRepository, CallsRepository>();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Register the IConfiguration instance which AppConfig binds against.
            services.Configure<AppConfig>(Configuration);

            // Set symmetric security key
            string securityKey = Environment.GetEnvironmentVariable("JWT_SECURITY_KEY") ?? "JWT_SECURITY_KEY";
            _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(securityKey));
            
            // Add application services
            services.AddSingleton<Microsoft.AspNetCore.Http.IHttpContextAccessor, Microsoft.AspNetCore.Http.HttpContextAccessor>();
            services.AddSingleton<Microsoft.Extensions.Configuration.IConfiguration>(Configuration);
            services.AddSingleton<IRepository<BookDto>, MongoRepository<BookDto>>();
            services.AddSingleton<IRepository<AccountDto>, MongoRepository<AccountDto>>();
            services.AddSingleton<IRepository<Security>, MongoRepository<Security>>();
            services.AddSingleton<IRepository<Price>, MongoRepository<Price>>();
            services.AddSingleton<IRepository<Period>, MongoRepository<Period>>();

            #region CQRS
            services.AddMemoryCache();
            
            //Add Cqrs services
            services.AddSingleton<InProcessBus>(new InProcessBus());
            services.AddSingleton<ICommandSender>(y => y.GetService<InProcessBus>());
            services.AddSingleton<IEventPublisher>(y => y.GetService<InProcessBus>());
            services.AddSingleton<IHandlerRegistrar>(y => y.GetService<InProcessBus>());
            services.AddScoped<ISession, Session>();
            services.AddSingleton<IEventStore, MongoEventStore>();
            services.AddScoped<ICache, CQRSlite.Cache.MemoryCache>();
            services.AddScoped<IRepository>(y => new CQRSlite.Cache.CacheRepository(new Repository(y.GetService<IEventStore>()), y.GetService<IEventStore>(), y.GetService<ICache>()));
            
            services.AddTransient<IReadModelFacade, ReadModelFacade>();
            
            //Scan for commandhandlers and eventhandlers
            services.Scan(scan => scan
                .FromAssemblies(typeof(BookCommandHandlers).GetTypeInfo().Assembly)
                    .AddClasses(classes => classes.Where(x => {
                        var allInterfaces = x.GetInterfaces();
                        return 
                            allInterfaces.Any(y => y.GetTypeInfo().IsGenericType && y.GetTypeInfo().GetGenericTypeDefinition() == typeof(ICommandHandler<>)) ||
                            allInterfaces.Any(y => y.GetTypeInfo().IsGenericType && y.GetTypeInfo().GetGenericTypeDefinition() == typeof(IEventHandler<>));
                    }))
                    .AsSelf()
                    .WithTransientLifetime()
            );

            //Register bus
            var serviceProvider = services.BuildServiceProvider();
            var registrar = new BusRegistrar(new DependencyResolver(serviceProvider));
            registrar.Register(typeof(BookCommandHandlers));
            
            //Register Mongo
            MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;
            BsonClassMap.RegisterClassMap<AccountCreated>(cm =>
            {
                cm.AutoMap();
                cm.SetIdMember(cm.GetMemberMap(c => c.ObjectId));
            });
            BsonClassMap.RegisterClassMap<AccountDeleted>(cm =>
            {
                cm.AutoMap();
                cm.SetIdMember(cm.GetMemberMap(c => c.ObjectId));
            });
            BsonClassMap.RegisterClassMap<BookCreated>(cm =>
            {
                cm.AutoMap();
                cm.SetIdMember(cm.GetMemberMap(c => c.ObjectId));
            });
            BsonClassMap.RegisterClassMap<ParentAccountAssigned>(cm =>
            {
                cm.AutoMap();
                cm.SetIdMember(cm.GetMemberMap(c => c.ObjectId));
            });
            BsonClassMap.RegisterClassMap<TransactionCreated>(cm =>
            {
                cm.AutoMap();
                cm.SetIdMember(cm.GetMemberMap(c => c.ObjectId));
            });
            #endregion

            // AutoMapper
            services.AddAutoMapper();
            
            // Add framework services.
            services.AddMvc(
                config =>
                {
                    // Make authentication compulsory
                    var policy = new AuthorizationPolicyBuilder()
                         .RequireAuthenticatedUser()
                         .Build();
                    config.Filters.Add(new AuthorizeFilter(policy));
                    // Bad request filter
                    config.Filters.Add(new BadRequestActionFilter());
                }
            ).AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>()); // FluentValidation

            // Set up authorization policies.
            services.AddAuthorization(options =>
            {
                options.AddPolicy(Constants.AuthorizationPolicy,
                                policy => policy.RequireClaim(Constants.ClaimType, Constants.ClaimValue));
            });
            
            // Get options from app settings
            var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));

            // Configure JwtIssuerOptions
            services.Configure<JwtIssuerOptions>(options =>
            {
                options.Issuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
                options.SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256);
            });
        }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
 }
Exemple #40
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (!string.IsNullOrEmpty(Configuration[ConfigurationKey.DataProtectionPath]))
            {
                string protectionPath = Configuration[ConfigurationKey.DataProtectionPath];
                string discriminator  = Configuration[ConfigurationKey.ApplicationDescriminator]
                                        ?? "gra";
                services.AddDataProtection(_ => _.ApplicationDiscriminator = discriminator)
                .PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(protectionPath, "keys")));
            }

            // Add framework services.
            services.AddSession(_ =>
            {
                _.IdleTimeout = TimeSpan.FromMinutes(30);
            });
            services.TryAddSingleton(_ => Configuration);
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddResponseCompression();
            services.AddMemoryCache();

            // check for a connection string for storing sessions in a database table
            string sessionCs     = Configuration.GetConnectionString("SqlServerSessions");
            string sessionSchema = Configuration[ConfigurationKey.SqlSessionSchemaName] ?? "dbo";
            string sessionTable  = Configuration[ConfigurationKey.SqlSessionTable] ?? "Sessions";

            if (!string.IsNullOrEmpty(sessionCs))
            {
                services.AddDistributedSqlServerCache(_ =>
                {
                    _.ConnectionString = sessionCs;
                    _.SchemaName       = sessionSchema;
                    _.TableName        = sessionTable;
                });
            }
            services.AddMvc();

            services.AddAuthorization(options =>
            {
                foreach (var permisisonName in Enum.GetValues(typeof(Domain.Model.Permission)))
                {
                    options.AddPolicy(permisisonName.ToString(),
                                      _ => _.RequireClaim(ClaimType.Permission, permisisonName.ToString()));
                }

                options.AddPolicy(Domain.Model.Policy.ActivateChallenges,
                                  _ => _.RequireClaim(ClaimType.Permission,
                                                      Domain.Model.Permission.ActivateAllChallenges.ToString(),
                                                      Domain.Model.Permission.ActivateSystemChallenges.ToString()));
            });

            // path validator
            services.AddScoped <Controllers.Base.ISitePathValidator, Controllers.Validator.SitePathValidator>();

            // service facades
            services.AddScoped <Controllers.ServiceFacade.Controller, Controllers.ServiceFacade.Controller>();
            services.AddScoped <Data.ServiceFacade.Repository, Data.ServiceFacade.Repository>();

            // database
            services.AddScoped <Data.Context, Data.SqlServer.SqlServerContext>();
            //services.AddScoped<Data.Context, Data.SQLite.SQLiteContext>();

            // utilities
            services.AddScoped <IUserContextProvider, Controllers.UserContextProvider>();
            services.AddScoped <Security.Abstract.IPasswordHasher, Security.PasswordHasher>();
            services.AddScoped <Abstract.IPasswordValidator, PasswordValidator>();
            services.AddScoped <Abstract.IPathResolver, PathResolver>();
            services.AddScoped <Abstract.ITokenGenerator, TokenGenerator>();
            services.AddScoped <Abstract.IEntitySerializer, EntitySerializer>();
            services.AddScoped <Abstract.ICodeGenerator, CodeGenerator>();
            services.AddScoped <ICodeSanitizer, CodeSanitizer>();

            // filters
            services.AddScoped <Controllers.Filter.MissionControlFilter>();
            services.AddScoped <Controllers.Filter.NotificationFilter>();
            services.AddScoped <Controllers.Filter.SiteFilter>();
            services.AddScoped <Controllers.Filter.UserFilter>();

            // services
            services.AddScoped <ActivityService>();
            services.AddScoped <AuthenticationService>();
            services.AddScoped <BadgeService>();
            services.AddScoped <CategoryService>();
            services.AddScoped <ChallengeService>();
            services.AddScoped <DrawingService>();
            services.AddScoped <DynamicAvatarService>();
            services.AddScoped <EmailReminderService>();
            services.AddScoped <EmailService>();
            services.AddScoped <EventImportService>();
            services.AddScoped <EventService>();
            services.AddScoped <MailService>();
            services.AddScoped <PageService>();
            services.AddScoped <PrizeWinnerService>();
            services.AddScoped <QuestionnaireService>();
            services.AddScoped <ReportService>();
            services.AddScoped <SampleDataService>();
            services.AddScoped <SchoolImportService>();
            services.AddScoped <SchoolService>();
            services.AddScoped <SiteLookupService>();
            services.AddScoped <SiteService>();
            services.AddScoped <StaticAvatarService>();
            services.AddScoped <SystemInformationService>();
            services.AddScoped <TriggerService>();
            services.AddScoped <UserService>();
            services.AddScoped <VendorCodeService>();

            // service resolution
            services.AddScoped <IInitialSetupService, SetupMultipleProgramService>();

            // repositories
            services.AddScoped <Domain.Repository.IAnswerRepository, Data.Repository.AnswerRepository>();
            services.AddScoped <Domain.Repository.IAuthorizationCodeRepository, Data.Repository.AuthorizationCodeRepository>();
            services.AddScoped <Domain.Repository.IBadgeRepository, Data.Repository.BadgeRepository>();
            services.AddScoped <Domain.Repository.IBookRepository, Data.Repository.BookRepository>();
            services.AddScoped <Domain.Repository.IBranchRepository, Data.Repository.BranchRepository>();
            services.AddScoped <Domain.Repository.IDrawingCriterionRepository, Data.Repository.DrawingCriterionRepository>();
            services.AddScoped <Domain.Repository.IDrawingRepository, Data.Repository.DrawingRepository>();
            services.AddScoped <Domain.Repository.IDynamicAvatarBundleRepository, Data.Repository.DynamicAvatarBundleRepository>();
            services.AddScoped <Domain.Repository.IDynamicAvatarColorRepository, Data.Repository.DynamicAvatarColorRepository>();
            services.AddScoped <Domain.Repository.IDynamicAvatarElementRepository, Data.Repository.DynamicAvatarElementRepository>();
            services.AddScoped <Domain.Repository.IDynamicAvatarItemRepository, Data.Repository.DynamicAvatarItemRepository>();
            services.AddScoped <Domain.Repository.IDynamicAvatarLayerRepository, Data.Repository.DynamicAvatarLayerRepository>();
            services.AddScoped <Domain.Repository.ICategoryRepository, Data.Repository.CategoryRepository>();
            services.AddScoped <Domain.Repository.IChallengeRepository, Data.Repository.ChallengeRepository>();
            services.AddScoped <Domain.Repository.IChallengeTaskRepository, Data.Repository.ChallengeTaskRepository>();
            services.AddScoped <Domain.Repository.IEmailReminderRepository, Data.Repository.EmailReminderRepository>();
            services.AddScoped <Domain.Repository.IEnteredSchoolRepository, Data.Repository.EnteredSchoolRepository>();
            services.AddScoped <Domain.Repository.IEventRepository, Data.Repository.EventRepository>();
            services.AddScoped <Domain.Repository.ILocationRepository, Data.Repository.LocationRepository>();
            services.AddScoped <Domain.Repository.IMailRepository, Data.Repository.MailRepository>();
            services.AddScoped <Domain.Repository.INotificationRepository, Data.Repository.NotificationRepository>();
            services.AddScoped <Domain.Repository.IPageRepository, Data.Repository.PageRepository>();
            services.AddScoped <Domain.Repository.IPointTranslationRepository, Data.Repository.PointTranslationRepository>();
            services.AddScoped <Domain.Repository.IPrizeWinnerRepository, Data.Repository.PrizeWinnerRepository>();
            services.AddScoped <Domain.Repository.IProgramRepository, Data.Repository.ProgramRepository>();
            services.AddScoped <Domain.Repository.IRequiredQuestionnaireRepository, Data.Repository.RequiredQuestionnaireRepository>();
            services.AddScoped <Domain.Repository.IQuestionRepository, Data.Repository.QuestionRepository>();
            services.AddScoped <Domain.Repository.IQuestionnaireRepository, Data.Repository.QuestionnaireRepository>();
            services.AddScoped <Domain.Repository.IRecoveryTokenRepository, Data.Repository.RecoveryTokenRepository>();
            services.AddScoped <Domain.Repository.IRoleRepository, Data.Repository.RoleRepository>();
            services.AddScoped <Domain.Repository.ISchoolDistrictRepository, Data.Repository.SchoolDistrictRepository>();
            services.AddScoped <Domain.Repository.ISchoolRepository, Data.Repository.SchoolRepository>();
            services.AddScoped <Domain.Repository.ISchoolTypeRepository, Data.Repository.SchoolTypeRepository>();
            services.AddScoped <Domain.Repository.ISiteRepository, Data.Repository.SiteRepository>();
            services.AddScoped <Domain.Repository.IStaticAvatarRepository, Data.Repository.StaticAvatarRepository>();
            services.AddScoped <Domain.Repository.ISystemInformationRepository, Data.Repository.SystemInformationRepository>();
            services.AddScoped <Domain.Repository.ISystemRepository, Data.Repository.SystemRepository>();
            services.AddScoped <Domain.Repository.ITriggerRepository, Data.Repository.TriggerRepository>();
            services.AddScoped <Domain.Repository.IUserLogRepository, Data.Repository.UserLogRepository>();
            services.AddScoped <Domain.Repository.IUserRepository, Data.Repository.UserRepository>();
            services.AddScoped <Domain.Repository.IVendorCodeRepository, Data.Repository.VendorCodeRepository>();
            services.AddScoped <Domain.Repository.IVendorCodeTypeRepository, Data.Repository.VendorCodeTypeRepository>();

            services.AddAutoMapper();
        }
Exemple #41
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_1);
 }
Exemple #42
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <DataContext>(p => p.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));

            services.AddControllers();
        }
Exemple #43
0
 public void ConfigureServices(IServiceCollection service)
 {
     //telling my project that it will use an MVC template
     service.AddControllersWithViews();
 }
Exemple #44
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllersWithViews();
 }
Exemple #45
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddRazorPages();
     services.AddServerSideBlazor();
     services.AddSingleton <WeatherForecastService>();
 }
Exemple #46
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton<Repository.IProductRepository, Repository.ProductRepository>();
        }
Exemple #47
0
 private void RegisterServices(IServiceCollection services)
 {
     DependencyContainer.RegisterServices(services);
 }
Exemple #48
0
 /// <summary>
 /// This method gets called by the runtime. Use this method to add services to the container.
 /// </summary>
 /// <param name="services"></param>
 public IServiceProvider ConfigureServices(IServiceCollection services)
 {
     return services.ConfigureApiServices(Configuration, Environment);
 }
 public void ConfigureServices(IServiceCollection collection)
 {
 }
Exemple #50
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllersWithViews();
     services.AddDbContext <EmployeeContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Appconnection")));
 }
 public static IServiceCollection AddCommunicationInfrastructure(this IServiceCollection services)
 {
     services.AddTransient <IJsonPlaceholderApi, JsonPlaceholderApiBase>();
     return(services);
 }
Exemple #52
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <TodoContext>(opt => opt.UseInMemoryDatabase("TodoList"));
     services.AddMvc();
 }
Exemple #53
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_1);
     services.AddDbContextPool <ServerContext>(x => x.UseSqlServer(@"Data Source=SQL6007.site4now.net;Initial Catalog=DB_A4EEE5_alfack1997;User Id=DB_A4EEE5_alfack1997_admin;Password=metro2033;"));
 }
Exemple #54
0
 /// <summary>
 /// Registers repositories for DB operations.
 /// </summary>
 /// <param name="services">Collection of services.</param>
 public static void RegisterRepositories(this IServiceCollection services)
 {
     services.AddTransient <IRepositoryAccessors, RepositoryAccessors>();
 }
Exemple #55
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddRazorPages();
     services.AddSignalR();
 }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddSingleton(Configuration.GetSection("CosmosDbConfiguration").Get<CosmosDbConfiguration>());
     services.AddSingleton<IRepository<ReviewDocument>, ReviewRepository>();
 }
Exemple #57
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //add SQLite
            services.AddDbContext <LifeguardIdentityDbContext>(options =>
                                                               options.UseSqlite(
                                                                   Configuration.GetConnectionString("DefaultConnection")));

            //adds pre-sign in user
            services.AddDefaultIdentity <LifeguardUser>(
                options => options.SignIn.RequireConfirmedAccount = true)
            .AddRoles <IdentityRole>()
            .AddEntityFrameworkStores <LifeguardIdentityDbContext>();

            services.AddRazorPages();

            //sign-in
            services.AddControllers(config =>
            {
                var policy = new AuthorizationPolicyBuilder()
                             .RequireAuthenticatedUser()
                             .Build();
                config.Filters.Add(new AuthorizeFilter(policy));
            });

            //admin sign-in
            services.AddAuthorization(options =>
            {
                options.AddPolicy("RequireAdministratorsRole",
                                  policy => policy.RequireRole("Administrators"));
            });

            services.Configure <IdentityOptions>(options =>
            {
                // Password settings.
                options.Password.RequiredLength         = 6;
                options.Password.RequiredUniqueChars    = 1;
                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;

                // Lockout settings.
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(10);
                options.Lockout.MaxFailedAccessAttempts = 5;
                options.Lockout.AllowedForNewUsers      = true;

                // User settings.
                options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
                options.User.RequireUniqueEmail        = true;

                options.SignIn.RequireConfirmedAccount = false;
                options.SignIn.RequireConfirmedEmail   = false;
            });

            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly = true;
                options.ExpireTimeSpan  = TimeSpan.FromMinutes(10);

                options.LoginPath         = "/Identity/Account/Login";
                options.AccessDeniedPath  = "/Identity/Account/AccessDenied";
                options.SlidingExpiration = true;
            });
        }
Exemple #58
0
 public static void AddHubs(this IServiceCollection services)
 {
     services.AddScoped <ChatHub>();
 }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     services.AddDbContext <DataContext>(
         options => options.UseSqlServer(Configuration.GetConnectionString("Conexion")));
 }
Exemple #60
-1
 private void LogRegistrations(IServiceCollection services)
 {            
     foreach(var service in services)
     {
         Console.WriteLine($"IT: {service.ImplementationType} - ST: {service.ServiceType}");
     }
 }