/// <summary> /// Saves the given <paramref name="settingsObject"/> to <paramref name="path"/>. /// </summary> /// <param name="settingsObject">The settings object that sould be saved.</param> /// <param name="path">The path, the given settings object should be saved to.</param> /// <exception cref="System.ArgumentNullException"><paramref name="settingsObject"/> or <paramref name="path"/> is null.</exception> public static void SaveSettings(Settings settingsObject, string path) { if (settingsObject == null) { throw new ArgumentNullException("settingsObject"); } if (path == null) { throw new ArgumentNullException("path"); } try { using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, 8192, FileOptions.Encrypted)) { // Yup - we don't need that object after that so just... don't save it new BinaryFormatter().Serialize(fileStream, settingsObject); } } // Not the finest way, but it's okay to just say nothing... // We don't want to bother the user with that. catch (SecurityException) { } }
/// <summary> /// Creates a new instance of the RestoreData class. /// </summary> /// <param name="settings">The current Settings object.</param> /// <param name="values">The current float-array with the values.</param> /// <param name="sheetEntries">The current array of SpreadsheetEntry objects.</param> /// <param name="sheetService">The current SpreadsheetService object.</param> public RestoreData(Settings settings, float[] values, SpreadsheetEntry[] sheetEntries, SpreadsheetsService sheetService) { this.Settings = settings; this.Values = values; this.SheetEntries = sheetEntries; this.SheetService = SheetService; }