mirror of
https://github.com/EDeev/student_sorter.git
synced 2026-10-07 20:49:42 +03:00
Revert "Своя ReadWrite вместо вузовской библиотеки RSREU.IO"
This reverts commit d937da139f.
This commit is contained in:
parent
d937da139f
commit
713dc51b4d
2 changed files with 5 additions and 31 deletions
|
|
@ -155,6 +155,9 @@
|
||||||
<Image Include="app.ico" />
|
<Image Include="app.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="RSREU.IO">
|
||||||
|
<HintPath>x64\Debug\RSREU.IO.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -10,41 +10,12 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
using namespace RSREU::IO;
|
||||||
using namespace System;
|
using namespace System;
|
||||||
using namespace System::Windows::Forms;
|
using namespace System::Windows::Forms;
|
||||||
using namespace System::Collections::Generic;
|
using namespace System::Collections::Generic;
|
||||||
|
|
||||||
|
|
||||||
// Сохранение и загрузка списка в файл (двоичная сериализация .NET).
|
|
||||||
// Раньше бралось из вузовской библиотеки RSREU.IO, которой нет в репозитории.
|
|
||||||
ref class ReadWrite abstract sealed {
|
|
||||||
public:
|
|
||||||
template<class T>
|
|
||||||
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<T>(formatter->Deserialize(fs));
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fs->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
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]
|
[Serializable]
|
||||||
ref struct Applicant {
|
ref struct Applicant {
|
||||||
String^ surname;
|
String^ surname;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue