Esempio n. 1
0
 /// <summary>
 /// Check the environment variable, and create a new ApplicationDbContext accordingly.
 /// </summary>
 /// <returns></returns>
 public ApplicationDbContext Create()
 {
     if (LibUnityConfig.ChooseBookStoreFromConfig() == BookStoreFlag.MySql)
     {
         string envConnectionString = Environment.GetEnvironmentVariable(
             "GoogleCloudSamples:ConnectionStringCloudSql");
         if (envConnectionString != null)
         {
             // Pull the connection string from the environment variable.
             return(new ApplicationDbContext(
                        new MySql.Data.MySqlClient.MySqlConnection(envConnectionString)));
         }
     }
     else if (LibUnityConfig.ChooseBookStoreFromConfig() == BookStoreFlag.SqlServer)
     {
         string envConnectionString = Environment.GetEnvironmentVariable(
             "GoogleCloudSamples:ConnectionStringSqlServer");
         if (envConnectionString != null)
         {
             // Pull the connection string from the environment variable.
             return(new ApplicationDbContext(
                        new System.Data.SqlClient.SqlConnection(envConnectionString)));
         }
     }
     // Pulls connection string from Web.config.
     return(new ApplicationDbContext());
 }
Esempio n. 2
0
 /// <summary>Registers the type mappings with the Unity container.</summary>
 /// <param name="container">The unity container to configure.</param>
 public static void RegisterTypes(IUnityContainer container)
 {
     LibUnityConfig.RegisterTypes(container);
     container.RegisterInstance <ImageUploader>(
         new ImageUploader(
             LibUnityConfig.GetConfigVariable("LockedNLoaded:BucketName")
             )
         );
 }
Esempio n. 3
0
 public Configuration()
 {
     AutomaticMigrationsEnabled = false;
     if (LibUnityConfig.ChooseBookStoreFromConfig() == BookStoreFlag.MySql)
     {
         SetSqlGenerator("MySql.Data.MySqlClient",
                         new MySql.Data.Entity.MySqlMigrationSqlGenerator());
     }
 }
Esempio n. 4
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        public static void RegisterTypes(IUnityContainer container)
        {
            LibUnityConfig.RegisterTypes(container);
            var bookDetailLookup = new BookDetailLookup(LibUnityConfig.ProjectId);

            bookDetailLookup.CreateTopicAndSubscription();
            container.RegisterInstance <BookDetailLookup>(bookDetailLookup);

            container.RegisterInstance <ImageUploader>(
                new ImageUploader(
                    LibUnityConfig.GetConfigVariable("GoogleCloudSamples:BucketName")
                    )
                );
        }
Esempio n. 5
0
 public Configuration()
 {
     AutomaticMigrationsEnabled = false;
     if (LibUnityConfig.ChoosePlaceStoreFromConfig() == PlaceStoreFlag.MySql)
     {
         SetSqlGenerator("MySql.Data.MySqlClient",
                         new MySql.Data.Entity.MySqlMigrationSqlGenerator());
     }
     else if (LibUnityConfig.ChoosePlaceStoreFromConfig() == PlaceStoreFlag.SqlServer)
     {
         SetSqlGenerator("System.Data.SqlClient",
                         new System.Data.Entity.SqlServer.SqlServerMigrationSqlGenerator());
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Pulls connection string from Web.config.
 /// </summary>
 internal ApplicationDbContext() : base("name=" +
                                        ((LibUnityConfig.ChoosePlaceStoreFromConfig() == PlaceStoreFlag.MySql)
     ? s_mySqlServerBaseName : s_sqlServerBaseName))
 {
 }