correcting some mistakes in lab 6
This commit is contained in:
parent
17a21a8284
commit
6ec573e2c2
@ -53,7 +53,7 @@ namespace ProjectElectricLocomotive
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningCar">Сохраняемый объект</param>
|
||||
/// <param name="drawningLoco">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawingLocomotive drawningLoco, char separatorForObject)
|
@ -104,8 +104,7 @@ namespace ProjectElectricLocomotive.Generics
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string,
|
||||
LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> record in _locomotivesStorage)
|
||||
foreach (KeyValuePair<string, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> record in _locomotivesStorage)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingLocomotive? elem in record.Value.GetLocomotives)
|
||||
@ -156,19 +155,14 @@ namespace ProjectElectricLocomotive.Generics
|
||||
_locomotivesStorage.Clear();
|
||||
string strs = "";
|
||||
|
||||
bool firstinit = true;
|
||||
|
||||
while ((strs = fs.ReadLine()) != null)
|
||||
{
|
||||
if (strs == null && firstinit)
|
||||
|
||||
if (strs == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (strs == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
firstinit = false;
|
||||
|
||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
@ -182,7 +176,7 @@ namespace ProjectElectricLocomotive.Generics
|
||||
DrawingLocomotive? loco = elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (loco != null)
|
||||
{
|
||||
if ((collection + loco) == -1) // or vice versa
|
||||
if ((collection + loco) == -1) // for my realization it's -1, for eegov's realization it's boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -191,77 +185,7 @@ namespace ProjectElectricLocomotive.Generics
|
||||
_locomotivesStorage.Add(record[0], collection);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*foreach(string data in str)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>
|
||||
collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawingLocomotive? loco =
|
||||
elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (loco != null)
|
||||
{
|
||||
if ((collection + loco) != -1) // or vice versa
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_locomotivesStorage.Add(record[0], collection);
|
||||
}
|
||||
return true;
|
||||
|
||||
}*/
|
||||
/*var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (str == null || str.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].StartsWith("LocomotiveStorage"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
_locomotivesStorage.Clear();
|
||||
foreach (string data in str)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>
|
||||
collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawingLocomotive? loco =
|
||||
elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (loco != null)
|
||||
{
|
||||
if ((collection + loco) != -1) // or vice versa
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_locomotivesStorage.Add(record[0], collection);
|
||||
}
|
||||
return true;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user