Exemplo n.º 1
0
 public DBConnector(string connectionString)
 {
     if (!String.IsNullOrEmpty(connectionString))
     {
         DbManager.AddConnectionString(connectionString);
     }
 }
Exemplo n.º 2
0
        public void Setup()
        {
            DataProviderBase provider = new OdpDataProvider();

            DbManager.AddDataProvider(provider);
            DbManager.AddConnectionString(provider.Name,
                                          string.Format(
                                              "data source={0};User Id={1};Password={2};Incr Pool Size=1;Max Pool Size=3; Connection Timeout=15; pooling=false",
                                              "MUSICFR01.TEST", "scurutchet", "kisscool12"));
        }
Exemplo n.º 3
0
        public void Test2()
        {
            /*[a]*/ DbManager.AddConnectionString/*[/a]*/ (
                "NewConfig",                            // configuration string
                sqlConnectionString);                   // connection string

            using (DbManager db = /*[a]*/ new DbManager("NewConfig") /*[/a]*/)
            {
                Assert.AreEqual(ConnectionState.Open, db.Connection.State);
            }
        }
Exemplo n.º 4
0
        public void Test3()
        {
            /*[a]*/ DbManager.AddConnectionString/*[/a]*/ (
                "OleDb",                                // provider name
                "NewConfig",                            // configuration string
                oleDbConnectionString);                 // connection string

            using (DbManager db = /*[a]*/ new DbManager("OleDb", "NewConfig") /*[/a]*/)
            {
                Assert.AreEqual(ConnectionState.Open, db.Connection.State);
            }
        }
Exemplo n.º 5
0
        public void Test()
        {
            // 3rd party data provider registration.
            //
            DbManager./*[a]*/ AddDataProvider/*[/a]*/ (new /*[a]*/ SybaseAdoDataProvider/*[/a]*/ ());

            // It can be configured by App.config.
            // We use this way for the demo purpose only.
            //
            DbManager.AddConnectionString(
                "SybaseAdo",                       // Provider name
                "Default",                         // Configuration
                connectionString);                 // Connection string

            using (DbManager db = new DbManager("SybaseAdo", "Default"))
            {
            }
        }
Exemplo n.º 6
0
        public void Test1()
        {
            string defaultConfiguration = DbManager.DefaultConfiguration;

            DbManager.DefaultConfiguration = "";             //to reset possible previous changes

            try
            {
                /*[a]*/ DbManager.AddConnectionString/*[/a]*/ (
                    sqlConnectionString);                       // connection string

                using (DbManager db = /*[a]*/ new DbManager() /*[/a]*/)
                {
                    Assert.AreEqual(ConnectionState.Open, db.Connection.State);
                }
            }
            finally
            {
                DbManager.DefaultConfiguration = defaultConfiguration;                 // to restore previous settings
            }
        }
Exemplo n.º 7
0
        static BltDbBroker()
        {
            SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();

            sb.DataSource         = @"(local)";
            sb.InitialCatalog     = "TrackerDb";
            sb.UserID             = "sa";
            sb.Password           = "******";
            sb.ConnectTimeout     = 60;
            sb.LoadBalanceTimeout = 5;
            sb.MaxPoolSize        = (int)(Settings.Default.ThreadsCount * 1.25);
            sb.MinPoolSize        = Settings.Default.ThreadsCount;

            DbManager.AddConnectionString(sb.ConnectionString);
            //DbManager.AddConnectionString(_connectionString);


            _timer          = new Timer();
            _timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
            _timer.Interval = 2 * 1000;
            _timer.Start();
        }
Exemplo n.º 8
0
        static TestBase()
        {
            var providerListFile =
                File.Exists(@"..\..\UserDataProviders.txt") ?
                @"..\..\UserDataProviders.txt" :
                @"..\..\DefaultDataProviders.txt";

            UserProviders.AddRange(
                File.ReadAllLines(providerListFile)
                .Select(s => s.Trim())
                .Where(s => s.Length > 0 && !s.StartsWith("--"))
                .Select(s =>
            {
                var ss = s.Split('*');
                switch (ss.Length)
                {
                case 0:  return(null);

                case 1:  return(new UserProviderInfo {
                        Name = ss[0].Trim()
                    });

                default: return(new UserProviderInfo {
                        Name = ss[0].Trim(), ConnectionString = ss[1].Trim()
                    });
                }
            })
                .Where(_ => _ != null));

            foreach (var provider in UserProviders)
            {
                if (provider.ConnectionString != null)
                {
                    DbManager.AddConnectionString(provider.Name, provider.ConnectionString);
                }
            }


            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
            {
                string assembly;

                if (args.Name.IndexOf("Sybase.AdoNet2.AseClient") >= 0)
                {
                    assembly = @"Sybase\Sybase.AdoNet2.AseClient.dll";
                }
                else if (args.Name.IndexOf("Oracle.DataAccess") >= 0)
                {
                    assembly = @"Oracle\Oracle.DataAccess.dll";
                }
                else if (args.Name.IndexOf("IBM.Data.DB2") >= 0)
                {
                    assembly = @"IBM\IBM.Data.DB2.dll";
                }
                else if (args.Name.IndexOf("Npgsql.resources") >= 0)
                {
                    return(null);
                }
                else if (args.Name.IndexOf("Npgsql") >= 0)
                {
                    assembly = @"PostgreSql\Npgsql.dll";
                }
                else if (args.Name.IndexOf("Mono.Security") >= 0)
                {
                    assembly = @"PostgreSql\Mono.Security.dll";
                }
                else if (args.Name.IndexOf("System.Data.SqlServerCe,") >= 0)
                {
                    assembly = @"SqlCe\System.Data.SqlServerCe.dll";
                }
                else
                {
                    return(null);
                }

                assembly = @"..\..\..\..\Redist\" + assembly;

                if (!File.Exists(assembly))
                {
                    assembly = @"..\..\" + assembly;
                }

                return(Assembly.LoadFrom(assembly));
            };

            DbManager.TurnTraceSwitchOn();

            PostgreSQLSqlProvider.QuoteIdentifiers = true;

            var path = Path.GetDirectoryName(typeof(DbManager).Assembly.CodeBase.Replace("file:///", ""));

            foreach (var info in Providers)
            {
                try
                {
                    Type type;

                    if (info.Assembly == null)
                    {
                        type = typeof(DbManager).Assembly.GetType(info.Type, true);
                    }
                    else
                    {
#if FW4
                        var fileName = info.Assembly + ".4.dll";
#else
                        var fileName = info.Assembly + ".3.dll";
#endif

                        var assembly = Assembly.LoadFile(Path.Combine(path, fileName));

                        type = assembly.GetType(info.Type, true);
                    }

                    DbManager.AddDataProvider(type);

                    info.Loaded = true;
                }
                catch (Exception)
                {
                    info.Loaded = false;
                }
            }

            LinqService.TypeResolver = str =>
            {
                switch (str)
                {
                //case "Data.Linq.Model.Gender" : return typeof(Gender);
                case "Data.Linq.Model.Person": return(typeof(Person));

                case "Data.Linq.WhereTest+TestEnum": return(typeof(WhereTest.TestEnum));

                default: return(null);
                }
            };
        }