This commit is contained in:
Ivan Kalivan 2024-06-14 03:13:18 +03:00
commit c0f9ad8f17

View File

@ -93,13 +93,13 @@ public class StorageCollection<T>
public void SaveData(string filename)
{
if (_storages.Count == 0)
if (_storages.Count == 0)
{
throw new Exception("В хранилище отсутствуют коллекции для сохранения");
}
if (File.Exists(filename))
if (File.Exists(filename))
{
File.Delete(filename);
File.Delete(filename);
}
using (StreamWriter writer = new StreamWriter(filename))
{
@ -110,7 +110,7 @@ public class StorageCollection<T>
sb.Append(Environment.NewLine);
if (value.Value.Count == 0)
{
continue;
continue;
}
sb.Append(value.Key);
sb.Append(_separatorForKeyValue);
@ -118,10 +118,10 @@ public class StorageCollection<T>
sb.Append(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
{
continue;
continue;
}
sb.Append(data);
sb.Append(_separatorItems);
@ -195,6 +195,7 @@ public class StorageCollection<T>
}
/// <summary>
/// Создание коллекции по типу
/// </summary>