|
|
|
|
@ -5,8 +5,11 @@ |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using GBase.Attributes; |
|
|
|
|
using GBase.Factories; |
|
|
|
|
using GBase.FileHandling.Factories; |
|
|
|
|
using GBase.Interfaces; |
|
|
|
|
using GBase.Interfaces.FileHandling; |
|
|
|
|
@ -19,13 +22,15 @@ namespace GBase |
|
|
|
|
public class GBaseTable : IGBaseTable |
|
|
|
|
{ |
|
|
|
|
private readonly IFileHandler _fileHandler; |
|
|
|
|
private readonly IGBaseEntryFactory _gBaseEntryFactory; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// A <see cref="IGBase"/> table |
|
|
|
|
/// </summary> |
|
|
|
|
public GBaseTable(IFileHandlerFactory fileHandlerFactory) |
|
|
|
|
public GBaseTable(IFileHandlerFactory fileHandlerFactory, IGBaseEntryFactory gBaseEntryFactory) |
|
|
|
|
{ |
|
|
|
|
_fileHandler = fileHandlerFactory.Create(); |
|
|
|
|
_gBaseEntryFactory = gBaseEntryFactory; |
|
|
|
|
Entries = new List<IGBaseEntry>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -63,6 +68,15 @@ namespace GBase |
|
|
|
|
await _fileHandler.Init(path, cancellationToken); |
|
|
|
|
|
|
|
|
|
//TODO: Init Entries list depending on GBaseEntryAttributes set for this GBaseTable |
|
|
|
|
foreach (var property in type.GetProperties()) |
|
|
|
|
{ |
|
|
|
|
GBaseEntryAttribute gBaseEntryAttribute = property.GetCustomAttribute<GBaseEntryAttribute>(); |
|
|
|
|
if (gBaseEntryAttribute == null) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
IGBaseEntry gBaseEntry = _gBaseEntryFactory.Create(); |
|
|
|
|
AddEntry(gBaseEntry); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|