public static StoredCliData GetStoredData() { CheckIfExistsFolder(); CheckIfFileFolder(); var content = File.ReadAllText(GetFilePath()); if (!string.IsNullOrEmpty(content)) { StoredCliData data = null; using (var stream = System.IO.File.OpenRead(GetFilePath())) { var serializer = new XmlSerializer(typeof(StoredCliData)); data = serializer.Deserialize(stream) as StoredCliData; } return(data); } throw new Exception(); }
public static void SaveStoredCliData(StoredCliData data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } CheckIfExistsFolder(); MakeFileBackup(); try { using (var writer = new System.IO.StreamWriter(GetFilePath())) { var serializer = new XmlSerializer(typeof(StoredCliData)); serializer.Serialize(writer, data); writer.Flush(); } } catch (Exception) { throw; } }
public StoredDataService(StoredCliData storedCliData, ICryptoService cryptoService) { StoredCliData = storedCliData ?? throw new ArgumentNullException(nameof(storedCliData)); CryptoService = cryptoService ?? throw new ArgumentNullException(nameof(cryptoService)); }