Ejemplo n.º 1
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 public LoginController(Microsoft.Extensions.Configuration.IConfiguration config)
 {
     _config = config;
 }
Ejemplo n.º 4
0
 public WebpartsController(IWebHostEnvironment hostingEnvironment, QNZContext context, IMapper mapper, IConfiguration config)
 {
     _hostingEnvironment = hostingEnvironment;
     _context            = context;
     _mapper             = mapper;
     _config             = config;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 7
0
        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>();
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// it's just a tuple. Returns 2 parameters.
 /// Trying to improve readability at ConfigureServices
 /// </summary>
 private static (DatabaseType, string) DetectDatabase(IConfiguration configuration) => (
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 17
0
        private AppSetting GetAppSetting()
        {
            Microsoft.Extensions.Configuration.IConfiguration cfg = GetConfiguration();

            return(new AppSetting(cfg));
        }
Ejemplo n.º 18
0
 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;
 }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
 /// <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;
 }
Ejemplo n.º 23
0
        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;
 }
Ejemplo n.º 25
0
 public Startup(Microsoft.Extensions.Configuration.IConfiguration config)
 {
     _config = config;
 }
Ejemplo n.º 26
0
        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;
 }
Ejemplo n.º 28
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
 }
Ejemplo n.º 29
0
 public Startup
     (Microsoft.Extensions.Configuration.IConfiguration configuration) : base()
 {
     Configuration = configuration;
 }
Ejemplo n.º 30
0
 public MailDemonDatabase GetDatabase(Microsoft.Extensions.Configuration.IConfiguration config = null)
 {
     return(new MailDemonDatabase(configuration));
 }
Ejemplo n.º 31
0
        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);
        }
Ejemplo n.º 32
0
 public ProductUrlResolver(Microsoft.Extensions.Configuration.IConfiguration config)
 {
     _config = config;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public CoreConfiguration(CoreConfig.IConfiguration node)
 {
     Node = node;
 }