lab6 Succes
This commit is contained in:
parent
34bc9b98b9
commit
1c65dd299d
@ -105,24 +105,25 @@ public class StorageCollection<T>
|
|||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new();
|
|
||||||
|
|
||||||
sb.Append(_collectionKey);
|
using FileStream fs = new(filename, FileMode.Create);
|
||||||
|
using StreamWriter streamWriter = new StreamWriter(fs);
|
||||||
|
streamWriter.Write(_collectionKey);
|
||||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||||
{
|
{
|
||||||
sb.Append(Environment.NewLine);
|
streamWriter.Write(Environment.NewLine);
|
||||||
// не сохраняем пустые коллекции
|
// не сохраняем пустые коллекции
|
||||||
if (value.Value.Count == 0)
|
if (value.Value.Count == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.Append(value.Key);
|
streamWriter.Write(value.Key);
|
||||||
sb.Append(_separatorForKeyValue);
|
streamWriter.Write(_separatorForKeyValue);
|
||||||
sb.Append(value.Value.GetCollectionType);
|
streamWriter.Write(value.Value.GetCollectionType);
|
||||||
sb.Append(_separatorForKeyValue);
|
streamWriter.Write(_separatorForKeyValue);
|
||||||
sb.Append(value.Value.MaxCount);
|
streamWriter.Write(value.Value.MaxCount);
|
||||||
sb.Append(_separatorForKeyValue);
|
streamWriter.Write(_separatorForKeyValue);
|
||||||
|
|
||||||
foreach (T? item in value.Value.GetItems())
|
foreach (T? item in value.Value.GetItems())
|
||||||
{
|
{
|
||||||
@ -132,15 +133,10 @@ public class StorageCollection<T>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.Append(data);
|
streamWriter.Write(data);
|
||||||
sb.Append(_separatorItems);
|
streamWriter.Write(_separatorItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using FileStream fs = new(filename, FileMode.Create);
|
|
||||||
using StreamWriter streamWriter = new StreamWriter(fs);
|
|
||||||
streamWriter.Write(sb.ToString());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user