protected override void OnStartup(StartupEventArgs e) { PlatformService.Instance = this; Config config = Config.Load(); if(!config.UseWebServices) { string connectionString = String.Format("Server = {0}; Database = {1}; Uid = {2};", config.DatabaseServer, config.DatabaseName, config.DatabaseUser); IDatabase db = null; try { db = new MYSQLDatabase(connectionString); } catch(Exception ex) { PlatformService.Instance.ShowErrorMessage( "Could not connect to database '" + connectionString + "'\n\n" + ex.Message, "Database connection failure"); Environment.Exit(-1); } SharedServices.Init(db); } else { var client = new RestClient(config.WebServiceBase); SharedServices.Init(client); } base.OnStartup(e); }
static void Main(string[] args) { IDatabase database; string providerName = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ProviderName; if (providerName == "Mysql.Data.MysqlClient") { database = new MYSQLDatabase(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString); } else { throw new NotSupportedException("Database not supported"); } Console.ReadKey(); }