Serialize converters were added

This commit is contained in:
Evgeny Redikultsev
2024-09-08 17:47:46 +05:00
parent 408e9f6999
commit 6e0b7b8070
60 changed files with 1713 additions and 443 deletions

View File

@@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataAccess.FileDialogs
{
public class FileDialogOpener
{
public void OpenFileAndRead()
{
// Create an instance of OpenFileDialog
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
// Set filter options and filter index
openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect = false; // Set to true if you want to allow multiple file selection
openFileDialog.Title = "Select a File";
// Show the dialog and get result
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
// Get the path of the selected file
string selectedFilePath = openFileDialog.FileName;
// Read the content of the file
try
{
string fileContent = File.ReadAllText(selectedFilePath);
Console.WriteLine($"File Content of '{selectedFilePath}':");
Console.WriteLine(fileContent);
}
catch (IOException ex)
{
Console.WriteLine($"An error occurred while reading the file: {ex.Message}");
}
}
else
{
Console.WriteLine("File selection was cancelled.");
}
}
}
}
}

View File

@@ -10,10 +10,6 @@ namespace DataAccess.FileDialogs
{
internal class FileStorage
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
public class FileStorageManager
{
@@ -109,30 +105,30 @@ class Program
[STAThread] // Required for OpenFileDialog
static void Main()
{
var fileStorageManager = new FileStorageManager();
//var fileStorageManager = new FileStorageManager();
// Open files and add them to the storage
fileStorageManager.OpenFile();
//// Open files and add them to the storage
//fileStorageManager.OpenFile();
// List all opened files
Console.WriteLine("\nOpened Files:");
fileStorageManager.ListOpenedFiles();
//// List all opened files
//Console.WriteLine("\nOpened Files:");
//fileStorageManager.ListOpenedFiles();
// Example: Read content of the first opened file (if any)
var openedFiles = new List<Guid>(fileStorageManager._openedFiles.Keys);
if (openedFiles.Count > 0)
{
var firstFileId = openedFiles[0];
Console.WriteLine($"\nReading content of the first opened file (ID: {firstFileId}):");
string content = fileStorageManager.ReadFileContent(firstFileId);
Console.WriteLine(content);
}
//// Example: Read content of the first opened file (if any)
//var openedFiles = new List<Guid>(fileStorageManager._openedFiles.Keys);
//if (openedFiles.Count > 0)
//{
// var firstFileId = openedFiles[0];
// Console.WriteLine($"\nReading content of the first opened file (ID: {firstFileId}):");
// string content = fileStorageManager.ReadFileContent(firstFileId);
// Console.WriteLine(content);
//}
// Close all files
foreach (var fileId in openedFiles)
{
fileStorageManager.CloseFile(fileId);
}
//// Close all files
//foreach (var fileId in openedFiles)
//{
// fileStorageManager.CloseFile(fileId);
//}
}
}