lab6
This commit is contained in:
parent
44c56936ff
commit
55c68c2d70
@ -160,21 +160,25 @@ public class StorageCollection<T>
|
||||
return false;
|
||||
}
|
||||
|
||||
string bufferTextFromFile = "";
|
||||
using (FileStream fs = new(filename, FileMode.Open))
|
||||
{
|
||||
using StreamReader streamReader = new StreamReader(fs);
|
||||
string firstString = streamReader.ReadLine();
|
||||
if(firstString == null || firstString.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!firstString.Equals(_collectionKey))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
|
||||
_storages.Clear();
|
||||
while (!streamReader.EndOfStream)
|
||||
{
|
||||
string[] record = streamReader.ReadLine().Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
||||
if(record.Length != 4)
|
||||
{
|
||||
continue;
|
||||
@ -204,7 +208,6 @@ public class StorageCollection<T>
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user