public static void WriteToRegistry(ObservableCollection <TabOptions> options) { try { using (MemoryStream stream = new MemoryStream()) { BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, options); var data = stream.ToArray(); BblRegistryKey.GetKey().SetValue("savedOptions", data, Microsoft.Win32.RegistryValueKind.Binary); } } catch { Console.WriteLine("Failed to write bookmarks to Registry"); } }
public static void WriteToRegistry(List <BblTabState> tabStates) { try { using (MemoryStream stream = new MemoryStream()) { BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, tabStates); var data = stream.ToArray(); BblRegistryKey.GetKey().SetValue("TabStates", data, RegistryValueKind.Binary); } } catch { Console.WriteLine("Failed to write tabStates to Registry"); } }
public static ObservableCollection <TabOptions> ReadFromRegistry() { ObservableCollection <TabOptions> options = null; try { byte[] data = BblRegistryKey.GetKey().GetValue("savedOptions") as byte[]; if (data != null) { using (MemoryStream stream = new MemoryStream(data)) { BinaryFormatter bin = new BinaryFormatter(); options = (ObservableCollection <TabOptions>)bin.Deserialize(stream); } } } catch { Console.WriteLine("Failed to retrieve bookmarks from registry."); } return(options); }
public static List <BblTabState> ReadFromRegistry() { List <BblTabState> tabStates = new List <BblTabState>(); try { byte[] data = BblRegistryKey.GetKey().GetValue("TabStates") as byte[]; if (data != null) { using (MemoryStream stream = new MemoryStream(data)) { BinaryFormatter bin = new BinaryFormatter(); tabStates = (List <BblTabState>)bin.Deserialize(stream); } } } catch { Console.WriteLine("Failed to retrieve tabStates from registry."); } return(tabStates); }