diff --git a/InvestWinApp/InvestWinApp.vcxproj b/InvestWinApp/InvestWinApp.vcxproj index 28662e5..d9efdb3 100644 --- a/InvestWinApp/InvestWinApp.vcxproj +++ b/InvestWinApp/InvestWinApp.vcxproj @@ -155,9 +155,6 @@ - - x64\Debug\RSREU.IO.dll - diff --git a/InvestWinApp/config.h b/InvestWinApp/config.h index 79bb7e9..4476b84 100644 --- a/InvestWinApp/config.h +++ b/InvestWinApp/config.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -10,12 +10,41 @@ #include #include -using namespace RSREU::IO; using namespace System; using namespace System::Windows::Forms; using namespace System::Collections::Generic; +// Сохранение и загрузка списка в файл (двоичная сериализация .NET). +// Раньше бралось из вузовской библиотеки RSREU.IO, которой нет в репозитории. +ref class ReadWrite abstract sealed { +public: + template + static T Load(String^ path) { + if (!System::IO::File::Exists(path)) return nullptr; + System::IO::FileStream^ fs = System::IO::File::OpenRead(path); + try { + auto formatter = gcnew System::Runtime::Serialization::Formatters::Binary::BinaryFormatter(); + return safe_cast(formatter->Deserialize(fs)); + } + finally { + fs->Close(); + } + } + + template + static void Save(T obj, String^ path) { + System::IO::FileStream^ fs = System::IO::File::Create(path); + try { + auto formatter = gcnew System::Runtime::Serialization::Formatters::Binary::BinaryFormatter(); + formatter->Serialize(fs, obj); + } + finally { + fs->Close(); + } + } +}; + [Serializable] ref struct Applicant { String^ surname;