|
|
|
|
@ -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 |
|
|
|
|
/// </summary> |
|
|
|
|
public class GBaseTable : IGBaseTable |
|
|
|
|
{ |
|
|
|
|
private readonly IFileHandler _fileHandler; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// A <see cref="IGBase"/> table |
|
|
|
|
/// </summary> |
|
|
|
|
public GBaseTable() |
|
|
|
|
public GBaseTable(IFileHandlerFactory fileHandlerFactory) |
|
|
|
|
{ |
|
|
|
|
_fileHandler = fileHandlerFactory.Create(); |
|
|
|
|
Entries = new List<IGBaseEntry>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -44,13 +50,18 @@ namespace GBase |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="type">The <see cref="System.Type"/> of the class that this <see cref="IGBaseTable"/> represents</param> |
|
|
|
|
/// <param name="name">The name of this <see cref="IGBaseTable"/></param> |
|
|
|
|
/// <param name="databasePath">The path to the database files</param> |
|
|
|
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the asynchronous operation</param> |
|
|
|
|
/// <returns>True if successful, false if not</returns> |
|
|
|
|
public async Task<bool> Init(Type type, string name, CancellationToken cancellationToken) |
|
|
|
|
public async Task<bool> 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; |
|
|
|
|
|