Ejemplo n.º 1
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddMediatR(typeof(Startup));
            builder.Services.AddSingleton((s) =>
            {
                return(ConfigureCosmosDb());
            });

            builder.Services.AddSingleton((s) =>
            {
                return(ConfigureServiceBusClient());
            });


            builder.Services.AddDbContext <BankContext>((options) =>
                                                        SqlServerDbContextOptionsExtensions.UseSqlServer(
                                                            options,
                                                            Environment.GetEnvironmentVariable("SQLServerDbConnectionString")
                                                            )
                                                        );

            builder.Services.AddSingleton <IEventStore, CosmosDbEventStore>();
            builder.Services.AddSingleton <IEntityStore, EntityStore>();
            builder.Services.AddSingleton <IOpenBankAccountHandler, OpenBankAccountHandler>();
            builder.Services.AddSingleton <ICommandBus, CommandBus>();
            builder.Services.AddSingleton <IEventBus, ServiceBusEventBus>();
            builder.Services.AddScoped <IRepositoryFacade, RepositoryFacade>();
            builder.Services.AddSingleton <IMakeDepositHandler, MakeDepositHandler>();
        }
Ejemplo n.º 2
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            string connString = Environment.GetEnvironmentVariable("TodoContext");

            builder.Services.AddDbContext <TodoContext>(options =>
                                                        SqlServerDbContextOptionsExtensions.UseSqlServer(options, connString));
        }
Ejemplo n.º 3
0
        public async Task TestRealmsGetter()
        {
            const string         connectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=GuildTools;Integrated Security=True";
            KeyedResourceManager manager          = new KeyedResourceManager();

            BlizzardApiSecrets blizzardSecrets = new BlizzardApiSecrets()
            {
                ClientId     = this.config.GetValue <string>("BlizzardApiSecrets:ClientId"),
                ClientSecret = this.config.GetValue <string>("BlizzardApiSecrets:ClientSecret")
            };

            HttpClient        client      = new HttpClient();
            IMemoryCache      memoryCache = new MemoryCache(new MemoryCacheOptions());
            GuildToolsContext context     = new GuildToolsContext(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options as DbContextOptions);
            IDatabaseCache    dbCache     = new DatabaseCache(context) as IDatabaseCache;

            IDataRepository  repo            = new DataRepository(context);
            IBlizzardService blizzardService = new BlizzardService(repo, this.config, client);

            RealmsCache cache = new RealmsCache(blizzardService, memoryCache, dbCache, manager);

            DateTime initial = DateTime.Now;

            var realms = await cache.GetRealms(EF.Models.Enums.GameRegionEnum.US);

            DateTime second       = DateTime.Now;
            TimeSpan sinceInitial = second - initial;

            var realms2 = await cache.GetRealms(EF.Models.Enums.GameRegionEnum.US);

            DateTime third       = DateTime.Now;
            TimeSpan sinceSecond = third - second;

            int x = 42;
        }
 public static void AddWebAppIdentityConfiguration(this IServiceCollection services, IConfiguration configuration)
 {
     services.AddIdentityEntityFrameworkContextConfiguration(options =>
                                                             SqlServerDbContextOptionsExtensions.UseSqlServer(options, configuration.GetConnectionString("DefaultConnection"),
                                                                                                              b => b.MigrationsAssembly("Estoque.Infra.CrossCutting.Identity")));
     services.AddIdentityConfiguration();
 }
Ejemplo n.º 5
0
        private DbContextOptions GetDbContextOptions(IContext context)
        {
            var connectionString = this.configuration.GetConnectionString("Default");

            return(SqlServerDbContextOptionsExtensions
                   .UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options);
        }
Ejemplo n.º 6
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var configurationBuilder = new ConfigurationBuilder();

#if DEBUG
            // Local Development
            // CMD Setup: dotnet user-secrets set <key> <value>
            configurationBuilder.AddUserSecrets(Assembly.GetExecutingAssembly(), false);
#else
            var azureServiceTokenProvider = new AzureServiceTokenProvider();
            var keyVaultClient            = new KeyVaultClient(
                new KeyVaultClient.AuthenticationCallback(
                    azureServiceTokenProvider.KeyVaultTokenCallback));

            configurationBuilder.AddAzureKeyVault(
                "https://pophistory.vault.azure.net/",
                keyVaultClient,
                new DefaultKeyVaultSecretManager());
#endif

            var config = configurationBuilder.Build();
            builder.Services.AddSingleton <IConfiguration>(config);

            string connectionString = config["ConnectionStrings:SqlServer"];

            builder.Services.AddDbContext <PopHistoryFunctionContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
        }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins("*")
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowAnyOrigin();
                });
            });
            var connectionString = Configuration.GetConnectionString("dataBase");

            services.AddScoped <TemplateHelper>();
            services.AddScoped <ContactoHelper>();
            services.AddScoped <ContactoTareaHelper>();
            services.AddScoped <ContactoDepartamentoHelper>();
            services.AddScoped <RolHelper>();
            services.AddScoped <RolUsuarioHelper>();
            services.AddScoped <UsuarioHelper>();
            services.AddDbContext <DataContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
        }
        /// <summary>
        /// 添加模块
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public virtual IServiceCollection AddXscfModule(IServiceCollection services, IConfiguration configuration)
        {
            if (this is IXscfDatabase databaseRegister)
            {
                //定义 XscfSenparcEntities 实例生成
                Func <IServiceProvider, object> implementationFactory = s =>
                {
                    //准备创建 DbContextOptionsBuilder 实例,定义类型
                    var dbOptionBuilderType = typeof(DbContextOptionsBuilder <>);
                    //获取泛型对象类型,如:DbContextOptionsBuilder<SenparcEntity>
                    dbOptionBuilderType = dbOptionBuilderType.MakeGenericType(databaseRegister.XscfDatabaseDbContextType);
                    //创建 DbContextOptionsBuilder 实例
                    DbContextOptionsBuilder dbOptionBuilder = Activator.CreateInstance(dbOptionBuilderType) as DbContextOptionsBuilder;
                    //继续定义配置
                    dbOptionBuilder = SqlServerDbContextOptionsExtensions.UseSqlServer(dbOptionBuilder, Scf.Core.Config.SenparcDatabaseConfigs.ClientConnectionString, b => databaseRegister.DbContextOptionsAction(b, null));
                    //创建 SenparcEntities 实例
                    var xscfSenparcEntities = Activator.CreateInstance(databaseRegister.XscfDatabaseDbContextType, new object[] { dbOptionBuilder.Options });
                    return(xscfSenparcEntities);
                };
                //添加 XscfSenparcEntities 依赖注入配置
                services.AddScoped(databaseRegister.XscfDatabaseDbContextType, implementationFactory);
                //注册当前数据库的对象(必须)
                EntitySetKeys.TryLoadSetInfo(databaseRegister.XscfDatabaseDbContextType);

                //添加数据库相关注册过程
                databaseRegister.AddXscfDatabaseModule(services);
            }
            return(services);
        }
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddDbContext <SqlDbContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(
                    options, Environment.GetEnvironmentVariable("MSSQLDB_CONNECTION")));

            // 3rd parties
            builder.Services.AddAutoMapper(Assembly.GetAssembly(this.GetType()));
            builder.Services.AddSingleton <ICosmosDbClientFactory>(x => new CosmosDbClientFactory(
                                                                       new CosmosDbSetting(
                                                                           Environment.GetEnvironmentVariable("COSMOSDB_URI"),
                                                                           Environment.GetEnvironmentVariable("COSMOSDB_KEY"),
                                                                           Environment.GetEnvironmentVariable("COSMOSDB_DATABASENAME")
                                                                           )
                                                                       ));
            builder.Services.Configure <TelemetryConfiguration>((o) =>
            {
                o.InstrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
                o.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
            });
            builder.Services.Configure <BlobStorageOptions>((o) =>
            {
                o.ConnectionString = Environment.GetEnvironmentVariable("BLOB_STORAGE_CONNECTION");
                o.Containers       = new Dictionary <string, string> {
                    { "your_container_key", "your_container_name" }
                };
            });
            builder.Services.AddSingleton <IBlobStorageService, BlobStorageService>();

            // Our services
            builder.Services.AddScoped(typeof(IAsyncRepository <>), typeof(EfRepository <>));
            builder.Services.AddScoped <ISampleRepository, SampleRepository>();
            builder.Services.AddScoped <ITemplateCosmosRepository, TemplateCosmosRepository>();
            builder.Services.AddScoped <ISampleViewModelService, SampleViewModelService>();
        }
Ejemplo n.º 10
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            V_0 = MixService.GetConnectionString("MixCmsConnection");
            if (!string.IsNullOrEmpty(V_0))
            {
                switch (Enum.Parse <MixEnums.DatabaseProvider>(MixService.GetConfig <string>("DatabaseProvider")))
                {
                case 0:
                {
                    dummyVar0 = SqlServerDbContextOptionsExtensions.UseSqlServer(optionsBuilder, V_0, null);
                    return;
                }

                case 1:
                {
                    dummyVar1 = MySqlDbContextOptionsExtensions.UseMySql(optionsBuilder, V_0, null);
                    return;
                }

                case 2:
                {
                    dummyVar2 = NpgsqlDbContextOptionsExtensions.UseNpgsql(optionsBuilder, V_0, null);
                    break;
                }

                default:
                {
                    return;
                }
                }
            }
            return;
        }
Ejemplo n.º 11
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddHttpClient();
            string connectionString = Environment.GetEnvironmentVariable("SQLConnectionString");

            //string connectionString = System.Environment.GetEnvironmentVariable($"ConnectionStrings:SQLConnectionString", EnvironmentVariableTarget.Process);
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new NullReferenceException("ConnectionString not found");
            }
            //var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
            //optionsBuilder.UseSqlServer(connectionString);
            //var options = optionsBuilder.Options;
            //var context = new DatabaseContext(options);

            //builder.Services.AddSingleton((s) => {
            //    return context;
            //});
            var cache = new MemoryCache(new MemoryCacheOptions());

            builder.Services.AddDbContext <DatabaseContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
            builder.Services
            .AddTransient <TaskWeekService>()
            .AddTransient <TaskDefinitionService>()
            .AddTransient <TaskActivityService>()
            .AddTransient <AccountService>()
            .AddTransient <AuthorizationService>()
            .AddTransient <TransactionLogService>()
            .AddSingleton(cache);
        }
        private static DbContextOptions GetOptions()
        {
            string connectionString = @"Server=(localdb)\mssqllocaldb;Database=LoggerDb;Trusted_Connection=True;ConnectRetryCount=0";

            return(SqlServerDbContextOptionsExtensions.UseSqlServer(
                       new DbContextOptionsBuilder(), connectionString
                       ).Options);
        }
Ejemplo n.º 13
0
        public DataAccessClass()
        {
            DbContextOptions <SeeSharpLMS.Data.ApplicationDbContext> options = new DbContextOptions <SeeSharpLMS.Data.ApplicationDbContext>();
            DbContextOptionsBuilder builder = new DbContextOptionsBuilder(options);

            SqlServerDbContextOptionsExtensions.UseSqlServer(builder, "Server=titan.cs.weber.edu,10433;Initial Catalog=LMS_SeeSharp;PersistSecurityInfo=False;User ID=seesharp;Password=Password*1;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;", null);
            _context = new SeeSharpLMS.Data.ApplicationDbContext((DbContextOptions <SeeSharpLMS.Data.ApplicationDbContext>)builder.Options);
        }
        public void Setup()
        {
            string connectionString = "Server=WIN10VM2021\\SQLEXPRESS; Database=AdventureWorks2019; Integrated Security=True";
            var    opts             = SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder <AdventureWorksDbContext>(), connectionString).Options;
            var    context          = new AdventureWorksDbContext(opts);

            dbSet = context.Products;
        }
Ejemplo n.º 15
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            string connectionString = Environment.GetEnvironmentVariable("SQL_DB_CONNECTION");

            builder.Services.AddDbContext <EDCContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
            builder.Services.TryAddScoped <IPerson, PersonService>();
        }
Ejemplo n.º 16
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!optionsBuilder.get_IsConfigured())
     {
         dummyVar0 = SqlServerDbContextOptionsExtensions.UseSqlServer(optionsBuilder, "Server=115.79.139.90,4444;Database=mix_structure_account;UID=tinku;Pwd=1234qwe@;MultipleActiveResultSets=true;", null);
     }
     return;
 }
Ejemplo n.º 17
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var databaseConnectionString = Environment.GetEnvironmentVariable("DatabaseConnectionString");

            builder.Services.AddDbContext <CoverMeDbContext>(options =>
            {
                SqlServerDbContextOptionsExtensions.UseSqlServer(options, databaseConnectionString);
            });
        }
Ejemplo n.º 18
0
        private static DbContextOptions GetOptions()
        {
            var builder = new ConfigurationBuilder();

            builder.AddJsonFile("appsettings.json", optional: false);
            var configuration = builder.Build();

            return(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), configuration.GetConnectionString("CustomerApplicationConnection")).Options);
        }
Ejemplo n.º 19
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddHttpClient();
            string connectionString = Environment.GetEnvironmentVariable("SqlConnectionString");

            builder.Services.AddDbContext <PopularityContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString)
                );
        }
Ejemplo n.º 20
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var connectionString = Environment.GetEnvironmentVariable("SQLCONNSTR_MyDb");

            builder.Services.AddDbContext <IMyDbContext, MyDbContext>(options =>
                                                                      SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));

            builder.Services.AddSingleton <ILogger <GetUserByEmailFunction>, Logger <GetUserByEmailFunction> >();
        }
Ejemplo n.º 21
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            string connectionString = Environment.GetEnvironmentVariable("ConnectionString");

            builder.Services.AddDbContext <ApplicationDbContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));

            builder.Services.AddScoped <IAccountService, AccountService>();
        }
Ejemplo n.º 22
0
        public static void AddWebAppIdentityConfiguration(this IServiceCollection services, IConfiguration configuration)
        {
            // Default EF Context for Identity (inside of the NetDevPack.Identity)
            services.AddIdentityEntityFrameworkContextConfiguration(options =>
                                                                    SqlServerDbContextOptionsExtensions.UseSqlServer(options, configuration.GetConnectionString("DefaultConnection"),
                                                                                                                     b => b.MigrationsAssembly("Games.Infra.CrossCutting.Identity")));

            // Default Identity configuration from NetDevPack.Identity
            services.AddIdentityConfiguration();
        }
Ejemplo n.º 23
0
        public UnitTest1()
        {
            DbContextOptions <Group_Project.Data.ApplicationDbContext> options = new DbContextOptions <Group_Project.Data.ApplicationDbContext>();
            DbContextOptionsBuilder builder = new DbContextOptionsBuilder(options);

            SqlServerDbContextOptionsExtensions.UseSqlServer(builder, "Server=titan.cs.weber.edu,10433;Database=LMS_Zenith;user id=LMS_Zenith;password=Password*2", null);

            _context    = new Group_Project.Data.ApplicationDbContext((DbContextOptions <Group_Project.Data.ApplicationDbContext>)builder.Options);
            _unitOfWork = new Group_Project.Data.Repository.UnitOfWork(_context);
        }
Ejemplo n.º 24
0
        public ApplicationDbContext CreateDbContext(string[] args)
        {
            var _dbContextOptions = SqlServerDbContextOptionsExtensions.UseSqlServer(
                new DbContextOptionsBuilder(),
                "Data Source=(localdb)\\MSSQLLocalDB;Catalog=Placeless2;Integrated Security=True",
                options => options.CommandTimeout(120)
                ).Options;

            return(new ApplicationDbContext(_dbContextOptions));
        }
        private static DbContextOptions GetOptions()    //The configuration for the DB Context Options
        {
            var builder = new ConfigurationBuilder();   //We are building the config for the middleware

            builder.AddJsonFile("appsettings.json", optional: false);
            var configuration = builder.Build();

            //Populating connection string to the SQL Server
            return(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), configuration.GetConnectionString("ShopHubConnection")).Options);
            //options.UseSqlServer("Server= DESKTOP-KGITG3T; Database=Store; Trusted_connection = true;");
        }
Ejemplo n.º 26
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            string connectionString = Environment.GetEnvironmentVariable("SqlConnectionString");

            if (connectionString == null)
            {
                connectionString = Environment.GetEnvironmentVariable("SQLCONNSTR_SqlConnectionString");
            }
            builder.Services.AddDbContext <UserManagementDBContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
        }
Ejemplo n.º 27
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddLogging();
            var    con = "Server=tcp:abhlnuz2at.database.windows.net,1433;Initial Catalog=customerEventAzureDb;Persist Security Info=False;User ID=ucforecast;Password=Berlin..77;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string connectionString = Environment.GetEnvironmentVariable("SqlConnectionString");

            builder.Services.AddDbContext <CustomerEventContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, con));

            builder.Services.AddTransient <IEventRepository, EventRepository>();
        }
Ejemplo n.º 28
0
 private static DbContextOptions <ScGimpContext> GetSqlServerOptions(string connectionString)
 {
     return(SqlServerDbContextOptionsExtensions
            .UseSqlServer
            (
                new DbContextOptionsBuilder <ScGimpContext>(),
                connectionString,
                GetSqlServerOptions
            )
            .Options);
 }
Ejemplo n.º 29
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string connectionString = Configuration["ConnectionStrings:SqlServer"];

            services.AddDbContext <PopHistoryContext>(
                options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));

            services.AddOutputCaching();

            services.AddControllersWithViews();
        }
Ejemplo n.º 30
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     builder.Services.AddDbContext <ChamaContext>(options =>
                                                  SqlServerDbContextOptionsExtensions.UseSqlServer(options, Environment.GetEnvironmentVariable("DefaultConnection")));
     builder.Services.AddTransient <IStudentRepository, StudentRepository>();
     builder.Services.AddTransient <ICourseRepository, CourseRepository>();
     builder.Services.AddTransient <IStudentManager, StudentManager>();
     builder.Services.AddTransient <IEmailSender, EmailSender>();
     builder.Services.AddTransient <IDataAggregator, DataAggregator>();
     builder.Services.AddAutoMapper(typeof(ChamaProfiles).Assembly);
     builder.Services.AddLogging(x => x.AddConsole());
 }