public static bool Resolved() { UserSettings defaultUserSettings = GetDefaultUserSettingsForPlatform (); UserSettings userSettings = UserSettings.Load (defaultUserSettings); bool valid = IsUserSettingsValid (userSettings); if (valid) mResolvedSettings = userSettings; else File.Delete (UserSettings.AppUserSettingsFile); return valid; }
private static bool IsUserSettingsValid(UserSettings userSettings) { if (!File.Exists (userSettings.ConvertLocation)) return false; if (!IsVersionInfoCorrect (userSettings.ConvertLocation)) return false; if (!File.Exists (userSettings.MontageLocation)) return false; if (!IsVersionInfoCorrect (userSettings.MontageLocation)) return false; return true; }
public static UserSettings Load(UserSettings defaultUserSettings) { if (!Directory.Exists (AppDataFolder)) Directory.CreateDirectory (AppDataFolder); if (!File.Exists (AppUserSettingsFile)) { UserSettings.Write (AppUserSettingsFile, defaultUserSettings); } DataContractSerializer s = new DataContractSerializer (typeof(UserSettings)); using (FileStream fs = File.Open(AppUserSettingsFile, FileMode.Open)) { object s2 = s.ReadObject (fs); if (s2 == null) return null; else return (UserSettings)s2; } }
private static void Write(string filename, UserSettings userSettings) { DataContractSerializer s = new DataContractSerializer (typeof(UserSettings)); using (FileStream fs = File.Open(filename, FileMode.Create)) { s.WriteObject (fs, userSettings); } }