public void CheckVersions() { CheckDbExists(); currentDbVersion = Converter.ToDouble(dbService.SettingsGetValue(SettingsType.DBVersion)); if (AppVersion != currentDbVersion) { var answer = messageBoxService.AskWarningQuestion(Resources.Resources.VersionsMismatchWarningQuestionText, currentDbVersion.ToString("F1", CultureInfo.InvariantCulture), AppVersion.ToString("F1", CultureInfo.InvariantCulture)); if (answer) { DoMigrations(); } else { messageBoxService.ShowError(Resources.Resources.VersionsMismatchErrorText, AppVersion.ToString("F1", CultureInfo.InvariantCulture), currentDbVersion.ToString("F1", CultureInfo.InvariantCulture)); throw new Exception("DB version and App version is different"); } } }
public T Read <T>(SettingsType key) { lock (locker) { object value; if (typeof(T) == typeof(double)) { value = Converter.ToDouble(dbService.SettingsGetValue(key)); } else if (typeof(T) == typeof(decimal)) { value = Converter.ToDecimal(dbService.SettingsGetValue(key)); } else if (typeof(T) == typeof(float)) { value = Converter.ToFloat(dbService.SettingsGetValue(key)); } else if (typeof(T) == typeof(int)) { value = Converter.ToInt(dbService.SettingsGetValue(key)); } else if (typeof(T) == typeof(bool)) { value = Converter.ToBool(dbService.SettingsGetValue(key)); } else if (typeof(T) == typeof(string)) { value = dbService.SettingsGetValue(key); } else { throw new Exception($"Not supported type for {nameof(Read)} method"); } return((T)value); } }