コード例 #1
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"));
        }
コード例 #2
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"))
            {
            }
        }
コード例 #3
0
ファイル: TestBase.cs プロジェクト: aprilix/bltoolkit
        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);
                }
            };
        }
コード例 #4
0
ファイル: FluentMapTest.cs プロジェクト: tychen81/bltoolkit
 public void Initialize()
 {
     DbManager.AddDataProvider(typeof(MockDataProvider));
 }
コード例 #5
0
ファイル: TestBase.cs プロジェクト: jimmislim/bltoolkit
        static TestBase()
        {
            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") >= 0)
                {
                    assembly = @"PostgreSql\Npgsql.dll";
                }
                else if (args.Name.IndexOf("Mono.Security") >= 0)
                {
                    assembly = @"PostgreSql\Mono.Security.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;
                }
            }
        }
コード例 #6
0
 public override void OnApplicationStart(IIocContainer container, object context)
 {
     DbManager.AddDataProvider("Oracle", new OdpDataProvider());
     base.OnApplicationStart(container, context);
 }