diff --git a/ProjectContainerShip/ProjectContainerShip/CollectionGenericObjects/StorageCollection.cs b/ProjectContainerShip/ProjectContainerShip/CollectionGenericObjects/StorageCollection.cs
index 609def5..202a0b0 100644
--- a/ProjectContainerShip/ProjectContainerShip/CollectionGenericObjects/StorageCollection.cs
+++ b/ProjectContainerShip/ProjectContainerShip/CollectionGenericObjects/StorageCollection.cs
@@ -149,47 +149,52 @@ where T : DrawningShip
/// true - загрузка прошла успешно, false - ошибка при загрузке данных
public bool LoadData(string filename)
{
- if (!File.Exists(filename)) return false;
-
- string bufferTextFromFile = "";
- using (FileStream fs = new(filename, FileMode.Open))
+ if (!File.Exists(filename))
{
- byte[] b = new byte[fs.Length];
- UTF8Encoding temp = new(true);
- while (fs.Read(b, 0, b.Length) > 0) bufferTextFromFile += temp.GetString(b);
- }
-
- string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
-
- if (strs == null || strs.Length == 0) return false;
- if (!strs[0].Equals(_collectionKey))
- // Если нет такой записи, то это не те данные
return false;
-
- _storages.Clear();
- foreach (string data in strs)
- {
- string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
- if (record.Length != 4) continue;
-
- CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
- ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType);
-
- if (collection == null) return false;
-
- collection.MaxCount = Convert.ToInt32(record[2]);
-
- string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
- foreach (string elem in set)
- {
- if (elem?.CreateDrawningShip() is T ship)
- {
- if (collection.Insert(ship) == -1) return false;
- }
- }
- _storages.Add(record[0], collection);
}
- return true;
+ using (StreamReader reader = File.OpenText(filename))
+ {
+ string str = reader.ReadLine();
+ if (str == null || str.Length == 0)
+ {
+ return false;
+ }
+ if (!str.StartsWith(_collectionKey))
+ {
+ return false;
+ }
+ _storages.Clear();
+ string strs = "";
+ while ((strs = reader.ReadLine()) != null)
+ {
+ string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
+ if (record.Length != 4)
+ {
+ continue;
+ }
+ CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
+ ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType);
+ if (collection == null)
+ {
+ return false;
+ }
+ collection.MaxCount = Convert.ToInt32(record[2]);
+ string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
+ foreach (string elem in set)
+ {
+ if (elem?.CreateDrawningShip() is T ship)
+ {
+ if (collection.Insert(ship) == -1)
+ {
+ return false;
+ }
+ }
+ }
+ _storages.Add(record[0], collection);
+ }
+ return true;
+ }
}
///
/// Создание коллекции по типу
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs
index 340e51a..f11a4dc 100644
--- a/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs
@@ -26,7 +26,7 @@ public partial class FormShipConfig : Form
///
/// Событие для передачи объекта
///
- private event ShipDelegate? ShipDelegate;
+ private event Action? ShipDelegate;
///
/// Конструктор
@@ -51,7 +51,7 @@ public partial class FormShipConfig : Form
/// Привязка внешнего метода к событию
///
///
- public void AddEvent(ShipDelegate shipDelegate)
+ public void AddEvent(Action shipDelegate)
{
ShipDelegate += shipDelegate;
}