public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) { var builder = new ConfigurationBuilder() .SetBasePath(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); Configuration = builder.Build(); }
public Startup(IHostingEnvironment env) { // Set up configuration providers. var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); builder.AddEnvironmentVariables(); _configuration = builder.Build(); }
public LoginController(Microsoft.Extensions.Configuration.IConfiguration config) { _config = config; }
public WebpartsController(IWebHostEnvironment hostingEnvironment, QNZContext context, IMapper mapper, IConfiguration config) { _hostingEnvironment = hostingEnvironment; _context = context; _mapper = mapper; _config = config; }
public BlobStorageController(Microsoft.Extensions.Configuration.IConfiguration configuration) { _configuration = configuration; }
public MessageController(ILogService staffLog, IMessageService messageService, UserManager <ApplicationUser> userManager, IStudentService studentService, IConfiguration config, IUserService userService) { _staffLog = staffLog; _messageService = messageService; _studentService = studentService; _config = config; _userService = userService; _userManager = userManager; }
private static void AddMongoDbInfrastructureModules(this IServiceCollection services, IConfiguration configuration, Assembly[] assemblies) { var dbSettingsSection = configuration.GetSection(nameof(DbSettings)); services.Configure <IDbSettings>(dbSettingsSection); services.AddSingleton <IDbSettings>(e => e.GetRequiredService <IOptions <DbSettings> >().Value); services.AddSingleton <MongoDbContext>(); }
private static void AddInfrastructureModules(this IServiceCollection services, IConfiguration configuration, Assembly[] assemblies) { services.AddApplicationUserContext <ApplicationUser, RequestType, ApplicationUserSerializer, IApplicationUserContext, ApplicationUserContext>(); services.AddAutoMapper(assemblies); services.AddMediatR(assemblies); services.AddAspNetCoreInfrastructure(assemblies); services.AddAutoMapperInfrastructure(assemblies); services.AddFluentValidationInfrastructure(assemblies); services.AddMediatRInfrastructure(assemblies); services.AddNewtonsoftJsonInfrastructure(assemblies); services.AddSystemInfrastructure(assemblies); services.AddEfCoreInfrastructureModules(configuration, assemblies); // services.AddMongoDbInfrastructureModules(configuration, assemblies); }
/// <summary> /// it's just a tuple. Returns 2 parameters. /// Trying to improve readability at ConfigureServices /// </summary> private static (DatabaseType, string) DetectDatabase(IConfiguration configuration) => (
public static IServiceCollection AddOrderService(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) { #region 通常的写法 //services.Configure<OrderServiceOptions>(configuration); #endregion #region 验证方式1 //services.AddOptions<OrderServiceOptions>().Configure(options => //{ // configuration.Bind(options); //}).Validate(options => { // return options.MaxOrderCount < 100; //}, "MaxOrderCount不能小于100"); #endregion #region 验证方式二 //services.AddOptions<OrderServiceOptions>().Configure(options => //{ // configuration.Bind(options); //}).ValidateDataAnnotations(); #endregion #region 验证方式三 services.AddOptions <OrderServiceOptions>().Configure(options => { configuration.Bind(options); }).Services.AddSingleton <IValidateOptions <OrderServiceOptions>, OrderServieValidateOptions>(); #endregion //定义实例化服务之后的自动动作 //services.PostConfigure<OrderServiceOptions>(options => { options.MaxOrderCount += 100; }); //services.AddScoped<IOrderService, OrderService>();//scope services.AddSingleton <IOrderService, OrderService>();//单例 return(services); }
public static IServiceCollection ConfigureSsoApi(this IServiceCollection services, IConfiguration configuration) { services.ConfigureProviderForContext <SsoContext>(DetectDatabase(configuration)); //// ASP.NET Identity Configuration services .AddIdentity <UserIdentity, RoleIdentity>(AccountOptions.NistAccountOptions) .AddEntityFrameworkStores <SsoContext>() .AddDefaultTokenProviders();; //// SSO Services services .ConfigureSso <AspNetUser>() .AddSsoContext <SsoContext>() .AddDefaultAspNetIdentityServices(); //// IdentityServer4 Admin services services .ConfigureJpAdminServices <AspNetUser>() .ConfigureJpAdminStorageServices() .SetupDefaultIdentityServerContext <SsoContext>(); services.UpgradePasswordSecurity().UseArgon2 <UserIdentity>(); SetupGeneralAuthorizationSettings(services); return(services); }
public static void ConfigurePlayTogetherServices(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment env) { ConfigureDb(services, configuration, env); ConfigureSecurity(services, configuration); ConfigureBusinessLogic(services); }
public ContainerProvider(IConfiguration configuration = null) { _configService = new ConfigService(); _configService.LoadConfig(configuration); Configuration = _configService.Configuration; }
public ClientBookingController(IClientBookingRepository context, IMapper _mapper, Microsoft.Extensions.Configuration.IConfiguration _configuration, IEmailSender _emailSender) { clientRepository = context; mapper = _mapper; configuration = _configuration; emailSender = _emailSender; }
public AuthController(SignInManager <Person> signInManager, UserManager <Person> usermanager, ILogger <AuthController> logger, IPasswordHasher <Person> hasher, Microsoft.Extensions.Configuration.IConfiguration configuration) { this._signInManager = signInManager; this.usermanager = usermanager; this.logger = logger; this.hasher = hasher; this.configuration = configuration; }
public AuthController(IAuthRepository authRepository, IConfiguration configuration) { _authRepository = authRepository; _configuration = configuration; }
private AppSetting GetAppSetting() { Microsoft.Extensions.Configuration.IConfiguration cfg = GetConfiguration(); return(new AppSetting(cfg)); }
public AuthRepository(DataContext context, Microsoft.Extensions.Configuration.IConfiguration configuration) { _context = context; _configuration = configuration; }
public AdvertController(UserManager <DbUser> userManager, EFContext _dbcontext, IConfiguration configuration, IHostingEnvironment env) { this._userManager = userManager; dbcontext = _dbcontext; _configuration = configuration; _env = env; }
private static void AddEfCoreInfrastructureModules(this IServiceCollection services, IConfiguration configuration, Assembly[] assemblies) { var connectionKey = ConfigurationKeys.DatabaseConnectionKey; var connection = configuration.GetConnectionString(connectionKey); var type = typeof(Tools.Migrator.Module); var assembly = type.Assembly; var assemblyName = assembly.FullName; services.AddDbContext <DatabaseContext>(options => { options.UseSqlServer(connection, e => { e.MigrationsAssembly(assemblyName); }); options.EnableSensitiveDataLogging(); }); services.AddEntityFrameworkCoreInfrastructure(assemblies); }
public static IServiceCollection AddIdentityConfiguration(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration Configuration) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <ApplicationDbContext>(); return(services); }
/// <summary> /// Initializes a new instance of the <see cref="Startup"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="environment">The environment.</param> public Startup(IConfiguration configuration, IHostEnvironment environment) { Configuration = configuration; HostEnvironment = environment; }
private RunComponentsResult RunComponents(IEnumerable <IHostableComponentFactory> factories, IEnumerable <Assembly> componentsAssemblies, IConfiguration configuration, CancellationToken cancellationToken) { var cfg = ComponentConfiguration.Create(configuration); this.SetSharedLibrariesConfiguration(configuration, componentsAssemblies); var componentLoader = new ComponentAssemblyLoader(this.loader); var components = factories .Select(f => f.CreateComponent(componentLoader, cfg)) .ToArray(); var task = Task.Factory.StartNew( () => { foreach (var component in components) { component.Start(); // TODO: should pass the cancellationToken } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); return(new RunComponentsResult { StartTask = task, Components = components }); }
public MedicamentsAggregatorContextFactory(IConfiguration configuration) { _configuration = configuration; }
public Startup(Microsoft.Extensions.Configuration.IConfiguration config) { _config = config; }
public static IServiceCollection AddDependencyInjectionConfiguration(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) { services.AddScoped <SignInManager <MyIdentityUser> >(); services.AddScoped <UserManager <MyIdentityUser> >(); services.AddScoped <RoleManager <IdentityRole> >(); services.AddTransient <IEmailSender, SendGridEmailSender>(); services.Configure <AuthMessageSenderOptions>(configuration.GetSection("SendGrid")); return(services); }
public AuthenticateController(ITrainingCourseService trainingCourseService, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, Microsoft.Extensions.Configuration.IConfiguration configuration) { this.userManager = userManager; this.signInManager = signInManager; this.configuration = configuration; this.trainingCourseService = trainingCourseService; }
public Startup(IConfiguration configuration) { Configuration = configuration; }
public Startup (Microsoft.Extensions.Configuration.IConfiguration configuration) : base() { Configuration = configuration; }
public MailDemonDatabase GetDatabase(Microsoft.Extensions.Configuration.IConfiguration config = null) { return(new MailDemonDatabase(configuration)); }
public static IServiceCollection ConfigureAdminUi(this IServiceCollection services, IConfiguration configuration) { services.ConfigureProviderForContext <EventStoreContext>(DetectDatabase(configuration)); services.AddDbContext <EventStoreContext>(ProviderSelector.WithProviderAutoSelection(DetectDatabase(configuration))); services .ConfigureJpAdminServices <AspNetUser>() .ConfigureJpAdminStorageServices() .AddJpAdminContext(ProviderSelector.WithProviderAutoSelection(DetectDatabase(configuration))) .AddEventStore <EventStoreContext>(); return(services); }
public ProductUrlResolver(Microsoft.Extensions.Configuration.IConfiguration config) { _config = config; }
/// <summary> /// /// </summary> /// <param name="node"></param> public CoreConfiguration(CoreConfig.IConfiguration node) { Node = node; }