public static bool SaveSettingsFile(PluginSettingsBase settings, Type type, string filename) { MemoryStream ms = null; FileStream fs = null; XmlSerializer xs = null; try { ms = new MemoryStream(); fs = new FileStream(filename, FileMode.Create, FileAccess.Write); xs = new XmlSerializer(type); xs.Serialize(ms, settings); ms.Seek(0, SeekOrigin.Begin); fs.Write(ms.ToArray(), 0, (int)ms.Length); ms.Close(); fs.Close(); return(true); } catch (Exception) { return(false); } finally { if (ms != null) { ms.Close(); } if (fs != null) { fs.Close(); } } }
public static bool LoadSettingsFile(ref PluginSettingsBase settings, Type type, string filename) { MemoryStream ms = null; try { if (!File.Exists(filename)) { return(false); } byte[] data = File.ReadAllBytes(filename); XmlSerializer xs = new XmlSerializer(type); ms = new MemoryStream(data); ms.Seek(0, SeekOrigin.Begin); settings = (PluginSettingsBase)xs.Deserialize(ms); ms.Close(); return(true); } catch (Exception) { return(false); } finally { if (ms != null) { ms.Close(); } } }
public static bool SaveSettingsFile(PluginSettingsBase settings, Type type, string filename) { MemoryStream ms = null; FileStream fs = null; XmlSerializer xs = null; try { ms = new MemoryStream(); fs = new FileStream(filename, FileMode.Create, FileAccess.Write); xs = new XmlSerializer(type); xs.Serialize(ms, settings); ms.Seek(0, SeekOrigin.Begin); fs.Write(ms.ToArray(), 0, (int)ms.Length); ms.Close(); fs.Close(); return true; } catch (Exception) { return false; } finally { if (ms != null) ms.Close(); if (fs != null) fs.Close(); } }
public virtual void SaveSettings() { try { PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile); } catch (Exception) { } }
public PluginSettingsBase(PluginSettingsBase orig) { try { this.activated = orig.activated; } catch (Exception) { } }
public AutoRefSettings(PluginSettingsBase orig) : base(orig) { try { } catch (Exception) { } }
public SettingsWindow(PluginSettingsBase settings) { try { InitializeComponent(); this.settings = new AutoRefSettings(settings); checkBoxActivated.IsChecked = this.settings.activated; } catch (Exception) { } }
public virtual void LoadSettings() { try { if (File.Exists(SettingsFile)) { if (!PluginSettingsBase.LoadSettingsFile(ref settings, GetSettingsType(), SettingsFile)) { settings = GetNewSettings(); PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile); } } else { settings = GetNewSettings(); PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile); } } catch (Exception) { } }
public static bool LoadSettingsFile(ref PluginSettingsBase settings, Type type, string filename) { MemoryStream ms = null; try { if (!File.Exists(filename)) return false; byte[] data = File.ReadAllBytes(filename); XmlSerializer xs = new XmlSerializer(type); ms = new MemoryStream(data); ms.Seek(0, SeekOrigin.Begin); settings = (PluginSettingsBase)xs.Deserialize(ms); ms.Close(); return true; } catch (Exception) { return false; } finally { if (ms != null) ms.Close(); } }