The File System Interactor is a library designed to facilitate various file system operations, such as reading data from Excel files, interacting with file paths, and handling configuration settings. It provides a set of services and interfaces to streamline these tasks, making it easier for developers to work with file systems in their applications.
- Configuration Service: Retrieve configuration values and column names from configuration settings.
- Excel Reader Service: Read data from Excel files based on specified column names.
- File Interaction Service: Select file paths and handle user input for file selection.
- File Path Service: Get base paths, file paths, and files with specific extensions.
usingDovs.FileSystemInteractor.Interfaces;usingDovs.FileSystemInteractor.Services;usingSystem;usingSystem.Collections.Generic;classProgram{staticvoidMain(){IExcelReaderServiceexcelReaderService=newExcelReaderService();List<string>columnNames=newList<string>{"Name","Age","Email"};stringfilePath="path/to/excel/file.xlsx";try{List<Dictionary<string,string>>data=excelReaderService.ReadData(filePath,columnNames);foreach(varrowindata){Console.WriteLine($"Name: {row["Name"]}, Age: {row["Age"]}, Email: {row["Email"]}");}}catch(Exceptionex){Console.WriteLine($"Error: {ex.Message}");}}}usingDovs.FileSystemInteractor.Interfaces;usingDovs.FileSystemInteractor.Services;usingSystem;classProgram{staticvoidMain(){IConfigurationServiceconfigService=newConfigurationService();stringconfigValue=configService.GetConfigValue("SomeKey");Console.WriteLine($"Config Value: {configValue}");}}IConfigurationService: Interface for configuration service.
string GetConfigValue(string key): Gets the configuration value for the specified key.List<string> GetColumnNames(string key): Gets the column names from the configuration.
IExcelReaderService: Interface for Excel reader service.
List<Dictionary<string, string>> ReadData(string filePath, List<string> columnNames): Reads data from the specified Excel file.
IFileInteractionService: Interface for file interaction service.
string SelectFilePath(IFilePathService filePathService, int levelsToTraverse, string fileExtension): Selects a file path based on user input.
IFilePathService: Interface for file path service.
string GetBasePath(int levelsToTraverse): Gets the base path by traversing the specified number of levels.string GetFilePath(string defaultFilePath): Gets the file path based on user input.string[] GetFiles(string basePath, string fileExtension): Gets an array of file paths with the specified extension from the base path.
ConfigurationService: Service for handling configuration operations.
- Implements
IConfigurationService.
- Implements
ExcelReaderService: Service for reading data from Excel files.
- Implements
IExcelReaderService.
- Implements
FileInteractionService: Service for handling file interactions.
- Implements
IFileInteractionService.
- Implements
FilePathService: Service for handling file path operations.
- Implements
IFilePathService.
- Implements