コード例 #1
0
        public static DataPlug GetInstance()
        {
            try
            {
                if (_instance == null)
                {
                    DatabaseType             = "MYSQL";
                    ConnectionString         = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                    ReadOnlyConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ReadOnlyConnection"].ConnectionString;
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-IN");

                    switch (DatabaseType.ToUpper())
                    {
                    case "MYSQL":
                        _instance = new MySQLDataPlug();
                        break;

                    case "SQLSERVER":
                        _instance = new SqlDataPlug();
                        break;
                        //add other providers here
                    }
                    if (_instance != null)
                    {
                        _instance.MakeConnection(ConnectionString, ReadOnlyConnectionString);
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            return(_instance);
        }
コード例 #2
0
 public DataLink()
 {
     Connection = DataPlugFactory.GetInstance();
 }
コード例 #3
0
 //clear _instance variable for a fresh object
 public static void CleanUp()
 {
     _instance = null;
 }