Beispiel #1
0
        static DatabaseSettings()
        {
            SettingsReader sr = new SettingsReader(Paths.DatabaseSettingsFilePath);

            if (sr.GetValue("type") != null)
            {
                switch (Convert.ToInt32(sr.GetValue("type")))
                {
                    case 0:
                        DbType = Enums.DatabaseType.MsSQL;
                        break;
                    case 1:
                        DbType = Enums.DatabaseType.MySQL;
                        break;
                    default:
                        throw new Exception("Invalid database type. Must be 0 for MS SQL and 1 for My SQL");
                }
            }

            if (sr.GetValue("con") != null)
            {
                ConnectionString = sr.GetValue("con").ToString();

                if (string.IsNullOrEmpty(ConnectionString) | string.IsNullOrWhiteSpace(ConnectionString))
                {
                    throw new ArgumentNullException("Invalid connection string");
                }

            }
        }
Beispiel #2
0
        static LanguageProvider()
        {
            SettingsReader sr = new SettingsReader(Paths.LanguageSettingFilePath);

            if (sr.ContainKey("lang"))
            {
                string file_path = Path.Combine(Paths.LanguagesFolder, sr.GetValue("lang") + ".json");
                if (File.Exists(file_path))
                {
                    lang_data = (Dictionary<string, object>)Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(file_path), typeof(Dictionary<string, object>));
                }
                else
                {
                    throw new ArgumentException("The language file specified does not exist");
                }
            }
            else
            {
                //Fallback to english
                string file_path = Path.Combine(Paths.LanguagesFolder, "en-US.json");
                if (File.Exists(file_path))
                {
                    lang_data = (Dictionary<string, object>)Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(file_path), typeof(Dictionary<string, object>));
                }
                else
                {
                    throw new ArgumentException("The language file specified does not exist");
                }
            }

            if (sr.ContainKey("tor"))
            {

            }
            else { TextOrientation = Enums.TextOrientation.LeftToRight; }
        }