From 510b461b60323945c0f642a273d6da1eeed8dcaa Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Thu, 13 Feb 2020 10:04:04 +0100 Subject: [PATCH] - create a fileHandler for every table --- GBase/GBaseTable.cs | 15 +++++++++++++-- GBase/Interfaces/IGBaseTable.cs | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/GBase/GBaseTable.cs b/GBase/GBaseTable.cs index f35fce1..c3ef9ea 100644 --- a/GBase/GBaseTable.cs +++ b/GBase/GBaseTable.cs @@ -4,9 +4,12 @@ using System; using System.Collections.Generic; +using System.IO; using System.Threading; using System.Threading.Tasks; +using GBase.FileHandling.Factories; using GBase.Interfaces; +using GBase.Interfaces.FileHandling; namespace GBase { @@ -15,11 +18,14 @@ namespace GBase /// public class GBaseTable : IGBaseTable { + private readonly IFileHandler _fileHandler; + /// /// A table /// - public GBaseTable() + public GBaseTable(IFileHandlerFactory fileHandlerFactory) { + _fileHandler = fileHandlerFactory.Create(); Entries = new List(); } @@ -44,13 +50,18 @@ namespace GBase /// /// The of the class that this represents /// The name of this + /// The path to the database files /// A to cancel the asynchronous operation /// True if successful, false if not - public async Task Init(Type type, string name, CancellationToken cancellationToken) + public async Task Init(Type type, string name, string databasePath, CancellationToken cancellationToken) { Type = type; Name = name; + string fileName = $"{name}.{GBase.GBASE_TABLE_FILE_EXTENSION}"; + string path = Path.Combine(databasePath, fileName); + await _fileHandler.Init(path, cancellationToken); + //TODO: Init Entries list depending on GBaseEntryAttributes set for this GBaseTable return true; diff --git a/GBase/Interfaces/IGBaseTable.cs b/GBase/Interfaces/IGBaseTable.cs index c0bf8e8..f6c11d6 100644 --- a/GBase/Interfaces/IGBaseTable.cs +++ b/GBase/Interfaces/IGBaseTable.cs @@ -34,8 +34,9 @@ namespace GBase.Interfaces /// /// The of the class that this represents /// The name of this + /// /// The path to the database files /// A to cancel the asynchronous operation /// True if successful, false if not - Task Init(Type type, string name, CancellationToken cancellationToken); + Task Init(Type type, string name, string databasePath, CancellationToken cancellationToken); } } \ No newline at end of file