static ClientServices() { OldMessages = new List<string>(); ConfigName = ""; IsRunning = true; CurrentInstance = null; CurrentRenderProcess = null; Settings = new ClientSettings(); }
public static ClientSettings LoadSettings() { string settingsFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Amleto"); Directory.CreateDirectory(settingsFile); settingsFile = Path.Combine(settingsFile, "ClientSettings.xml"); ClientSettings settings = new ClientSettings(); try { if (File.Exists(settingsFile)) { XmlSerializer serializer = new XmlSerializer(settings.GetType()); TextReader reader = new StreamReader(settingsFile); object deserialised = serializer.Deserialize(reader); reader.Close(); settings = (ClientSettings) deserialised; } } catch (Exception ex) { logger.Error(ex, "Unable to load ClientSettings.xml"); } return settings; }
public static void SaveSettings(ClientSettings settings) { try { string settingsFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Amleto"); settingsFile = Path.Combine(settingsFile, "ClientSettings.xml"); XmlSerializer seriaizer = new XmlSerializer(settings.GetType()); TextWriter writer = new StreamWriter(settingsFile); seriaizer.Serialize(writer, settings); writer.Close(); } catch (Exception ex) { logger.Error(ex, "Unable to save ClientSettings.xml"); } }
/// <summary> /// Gets the configuration settings from the registry /// </summary> public static void RestoreSettings() { Settings = ClientSettings.LoadSettings(); }