From 6f387189e2e4b345751bf800c4d6e24e56cee631 Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Thu, 13 Feb 2020 10:17:12 +0100 Subject: [PATCH] - add and implement AddEntry and RemoveEntry methods --- GBase/GBase.xml | 28 ++++++++++++++++++++++++++++ GBase/GBaseTable.cs | 29 ++++++++++++++++++++++++++++- GBase/Interfaces/IGBaseTable.cs | 15 +++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/GBase/GBase.xml b/GBase/GBase.xml index 426645e..4e6c105 100644 --- a/GBase/GBase.xml +++ b/GBase/GBase.xml @@ -512,6 +512,20 @@ A to cancel the asynchronous operation True if successful, false if not + + + Add a given to this + + The given + True if successful, false if not + + + + Remove a given from this + + The given + True if successful, false if not + The method @@ -837,6 +851,20 @@ A to cancel the asynchronous operation True if successful, false if not + + + Add a given to this + + The given + True if successful, false if not + + + + Remove a given from this + + The given + True if successful, false if not + Settings of a instance diff --git a/GBase/GBaseTable.cs b/GBase/GBaseTable.cs index c1b1522..dcca848 100644 --- a/GBase/GBaseTable.cs +++ b/GBase/GBaseTable.cs @@ -61,12 +61,39 @@ namespace GBase 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; } + /// + /// Add a given to this + /// + /// The given + /// True if successful, false if not + public bool AddEntry(IGBaseEntry entry) + { + if (Entries.Contains(entry)) + return false; + + Entries.Add(entry); + return true; + } + + /// + /// Remove a given from this + /// + /// The given + /// True if successful, false if not + public bool RemoveEntry(IGBaseEntry entry) + { + if (!Entries.Contains(entry)) + return false; + + return Entries.Remove(entry); + } + /// /// The method /// diff --git a/GBase/Interfaces/IGBaseTable.cs b/GBase/Interfaces/IGBaseTable.cs index f6c11d6..bb52f3e 100644 --- a/GBase/Interfaces/IGBaseTable.cs +++ b/GBase/Interfaces/IGBaseTable.cs @@ -38,5 +38,20 @@ namespace GBase.Interfaces /// A to cancel the asynchronous operation /// True if successful, false if not Task Init(Type type, string name, string databasePath, CancellationToken cancellationToken); + + /// + /// Add a given to this + /// + /// The given + /// True if successful, false if not + bool AddEntry(IGBaseEntry entry); + + /// + /// Remove a given from this + /// + /// The given + /// True if successful, false if not + bool RemoveEntry(IGBaseEntry entry); + } } \ No newline at end of file