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); }
public DataLink() { Connection = DataPlugFactory.GetInstance(); }
//clear _instance variable for a fresh object public static void CleanUp() { _instance = null; }