コード例 #1
0
ファイル: Spam.cs プロジェクト: sandalkuilang/texto
        public void Main()
        {
            ConfigurationSettings settings = new ConfigurationSettings();
            ObjectPool.Instance.Register<ConfigurationSettings>().ImplementedBy(settings);

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
            dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = settings.ConnectionString.ConnectionString,
                IsDefault = true,
                Name = settings.ConnectionString.Name,
                ProviderName = settings.ConnectionString.ProviderName
            });

            ObjectPool.Instance.Register<PetapocoDbManager>().ImplementedBy(dbManager);
        }
コード例 #2
0
ファイル: DbCommand.cs プロジェクト: sandalkuilang/texto
        private void Initiliaze(DbConnection connection)
        {
            ResourceSqlLoader loader = new ResourceSqlLoader("resources.sql.loader",
                                                             string.Join(".", new string[] { this.GetType().Namespace, "SqlFiles" }),
                                                             System.Reflection.Assembly.GetAssembly(this.GetType()));

            dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(loader);
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = ((DbConnection)connection).ConnectionString,
                IsDefault        = true,
                ProviderName     = ((DbConnection)connection).ProviderName,
                Name             = "smsgw"
            });
        }
コード例 #3
0
        private void InitializeDatabase()
        {
            ApplicationSettings applicationSettings = (ApplicationSettings)ObjectPool.Instance.Resolve <GSMServer.Configuration.IConfiguration>();

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(new ResourceSqlLoader("resources-sql-loader", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ConnectionString,
                IsDefault        = true,
                Name             = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].Name,
                ProviderName     = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ProviderName
            });

            ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
        }
コード例 #4
0
ファイル: DbCommand.cs プロジェクト: sandalkuilang/texto
        private void Initiliaze(DbConnection connection)
        {
            ResourceSqlLoader loader = new ResourceSqlLoader("resources.sql.loader", 
                string.Join(".", new string[] { this.GetType().Namespace, "SqlFiles" }), 
                System.Reflection.Assembly.GetAssembly(this.GetType()));

            dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(loader);
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = ((DbConnection)connection).ConnectionString,
                IsDefault = true,
                ProviderName = ((DbConnection)connection).ProviderName,
                Name = "smsgw"
            });

        }
コード例 #5
0
        public void Main()
        {
            ConfigurationSettings settings = new ConfigurationSettings();

            ObjectPool.Instance.Register <ConfigurationSettings>().ImplementedBy(settings);

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = settings.ConnectionString.ConnectionString,
                IsDefault        = true,
                Name             = settings.ConnectionString.Name,
                ProviderName     = settings.ConnectionString.ProviderName
            });

            ObjectPool.Instance.Register <PetapocoDbManager>().ImplementedBy(dbManager);
        }
コード例 #6
0
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                ApplicationSettings settings = null;
                string formattedConnectionString;
                string connectionString;
                IDbManager dbManager;

                while (settings == null)
                {
                    settings = ObjectPool.Instance.Resolve <ApplicationSettings>();

                    if (settings != null)
                    {
                        formattedConnectionString = ConfigurationManager.AppSettings.Get("FormattedConnectionString");
                        connectionString          = string.Format(formattedConnectionString, settings.Database.Server, settings.Database.Name, settings.Database.Username, settings.Database.Password);

                        dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
                        dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SMSGatewayWpf.SqlFiles", Assembly.GetAssembly(this.GetType())));
                        dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                        {
                            ConnectionString = connectionString,
                            IsDefault        = true,
                            Name             = settings.Database.Name,
                            ProviderName     = settings.Database.ProviderName
                        });

                        ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
                        break;
                    }

                    Thread.Sleep(5000);
                }
            });
        }
コード例 #7
0
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() => 
            {
                ApplicationSettings settings = null;
                string formattedConnectionString;
                string connectionString;
                IDbManager dbManager;

                while (settings == null)
                {
                    settings = ObjectPool.Instance.Resolve<ApplicationSettings>();

                    if (settings != null)
                    {
                        formattedConnectionString = ConfigurationManager.AppSettings.Get("FormattedConnectionString");
                        connectionString = string.Format(formattedConnectionString, settings.Database.Server, settings.Database.Name, settings.Database.Username, settings.Database.Password);

                        dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
                        dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SMSGatewayWpf.SqlFiles", Assembly.GetAssembly(this.GetType())));
                        dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                        {
                            ConnectionString = connectionString,
                            IsDefault = true,
                            Name = settings.Database.Name,
                            ProviderName = settings.Database.ProviderName
                        });

                        ObjectPool.Instance.Register<IDbManager>().ImplementedBy(dbManager);
                        break;
                    }

                    Thread.Sleep(5000);
                }
                
            });
        }
コード例 #8
0
ファイル: Server.cs プロジェクト: sandalkuilang/texto
        private void InitializeDatabase()
        {
            ApplicationSettings applicationSettings = (ApplicationSettings)ObjectPool.Instance.Resolve<GSMServer.Configuration.IConfiguration>();  

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
            dbManager.AddSqlLoader(new ResourceSqlLoader("resources-sql-loader", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ConnectionString,
                IsDefault = true,
                Name = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].Name,
                ProviderName = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ProviderName
            });

            ObjectPool.Instance.Register<IDbManager>().ImplementedBy(dbManager); 
        }