From 889fe92716e83104ffab75dd40da016745593861 Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Mon, 17 Feb 2020 13:29:56 +0100 Subject: [PATCH] - add first init of entries to table.init --- GBase/GBase.xml | 2 +- GBase/GBaseTable.cs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/GBase/GBase.xml b/GBase/GBase.xml index a31bd2b..61527f0 100644 --- a/GBase/GBase.xml +++ b/GBase/GBase.xml @@ -500,7 +500,7 @@ A table - + A table diff --git a/GBase/GBaseTable.cs b/GBase/GBaseTable.cs index dcca848..571fd3d 100644 --- a/GBase/GBaseTable.cs +++ b/GBase/GBaseTable.cs @@ -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; /// /// A table /// - public GBaseTable(IFileHandlerFactory fileHandlerFactory) + public GBaseTable(IFileHandlerFactory fileHandlerFactory, IGBaseEntryFactory gBaseEntryFactory) { _fileHandler = fileHandlerFactory.Create(); + _gBaseEntryFactory = gBaseEntryFactory; Entries = new List(); } @@ -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(); + if (gBaseEntryAttribute == null) + continue; + + IGBaseEntry gBaseEntry = _gBaseEntryFactory.Create(); + AddEntry(gBaseEntry); + } return true; }