#25: start implementing addEntry

pull/27/head
Simon G 5 years ago
parent b10ce3d195
commit 1498a914df
  1. 5
      GBase/Attributes/GBaseTableAttribute.cs
  2. 20
      GBase/FileHandling/FileHandler.cs
  3. 9
      GBase/GBase.cs
  4. 129
      GBase/GBase.xml
  5. 20
      GBase/GBaseTable.cs
  6. 2
      GBase/Interfaces/FileHandling/IFileHandler.cs
  7. 9
      GBase/Interfaces/IGBaseTable.cs
  8. 2
      Test.GBase/GBaseTableIntegrationTest.cs

@ -13,6 +13,11 @@ namespace GBase.Attributes
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class GBaseTableAttribute : Attribute //TODO: Decide how to handle enums (as table or their own type) public class GBaseTableAttribute : Attribute //TODO: Decide how to handle enums (as table or their own type)
{ {
public GBaseTableAttribute(string folderName)
{
FolderName = folderName;
}
public string FolderName { get; }
} }
} }

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GBase.Interfaces; using GBase.Interfaces;
@ -18,7 +19,13 @@ namespace GBase.FileHandling
/// </summary> /// </summary>
public class FileHandler : IFileHandler public class FileHandler : IFileHandler
{ {
/// <summary>
/// The file extension for all GBase tables
/// </summary>
public const string GBASE_TABLE_FILE_EXTENSION = "gb";
private readonly IDataHandlerPool _dataHandlerPool; private readonly IDataHandlerPool _dataHandlerPool;
private string _path;
/// <summary> /// <summary>
/// Internal file handler /// Internal file handler
@ -37,13 +44,22 @@ namespace GBase.FileHandling
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
public async Task<bool> Init(string path, CancellationToken cancellationToken) public async Task<bool> Init(string path, CancellationToken cancellationToken)
{ {
_path = path;
return true; //TODO: is there anything that needs to be initialized here? return true; //TODO: is there anything that needs to be initialized here?
} }
public Task AddEntry<T>(T entry, IGBaseTable table) public async Task AddEntry<T>(T entry, IGBaseTable table, CancellationToken cancellationToken)
{ {
string directoryPath = Path.Combine(_path, table.FolderName);
//create directory if it doesn't exist
Directory.CreateDirectory(directoryPath);
//create new entry file //create new entry file
throw new NotImplementedException(); string filePath = $"{Path.Combine(directoryPath, entry.ToString())}.{GBASE_TABLE_FILE_EXTENSION}";
FileStream entryFile = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
IDataHandler dataHandler = await _dataHandlerPool.RequestDataHandler(this, false, cancellationToken);
} }
public Task<bool> RemoveEntry<T>(T entry) public Task<bool> RemoveEntry<T>(T entry)

@ -21,11 +21,6 @@ namespace GBase
/// </summary> /// </summary>
public class GBase : IGBase public class GBase : IGBase
{ {
/// <summary>
/// The file extension for all GBase tables
/// </summary>
public const string GBASE_TABLE_FILE_EXTENSION = "gb"; //TODO: Find correct place for this const
private readonly IGBaseTableFactory _gBaseTableFactory; private readonly IGBaseTableFactory _gBaseTableFactory;
/// <summary> /// <summary>
@ -76,7 +71,7 @@ namespace GBase
continue; continue;
IGBaseTable gBaseTable = _gBaseTableFactory.Create(type); IGBaseTable gBaseTable = _gBaseTableFactory.Create(type);
await gBaseTable.Init(type, type.Name, Settings.DatabasePath, cancellationToken); await gBaseTable.Init(type, Settings.DatabasePath, gBaseTableAttribute.FolderName, cancellationToken);
AddTable(gBaseTable); AddTable(gBaseTable);
} }
@ -94,7 +89,7 @@ namespace GBase
if (Tables.Contains(table)) if (Tables.Contains(table))
return false; return false;
if (Tables.Any(t => t.Name.Equals(table.Name))) if (Tables.Any(t => t.FolderName.Equals(table.FolderName)))
return false; return false;
Tables.Add(table); Tables.Add(table);

@ -361,6 +361,50 @@
The <see cref="T:System.Type"/> of the passed interface The <see cref="T:System.Type"/> of the passed interface
</summary> </summary>
</member> </member>
<member name="T:GBase.Exceptions.InvalidTableTypeException">
<summary>
<see cref="T:System.Exception"/> that the passed table type doesn't implement <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/>"/>
</summary>
</member>
<member name="M:GBase.Exceptions.InvalidTableTypeException.#ctor(System.Type)">
<summary>
<see cref="T:System.Exception"/> that the passed table type doesn't implement <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/>"/>
</summary>
<param name="type">The table type</param>
</member>
<member name="T:GBase.Exceptions.MissingTableException">
<summary>
<see cref="T:System.Exception"/> that the table for the given <see cref="P:GBase.Exceptions.MissingTableException.Type"/> is missing
</summary>
</member>
<member name="M:GBase.Exceptions.MissingTableException.#ctor(System.Type)">
<summary>
<see cref="T:System.Exception"/> that the table for the given <see cref="P:GBase.Exceptions.MissingTableException.Type"/> is missing
</summary>
</member>
<member name="P:GBase.Exceptions.MissingTableException.Type">
<summary>
The <see cref="P:GBase.Exceptions.MissingTableException.Type"/> that has no table
</summary>
</member>
<member name="T:GBase.Factories.GBaseTableFactory">
<summary>
Factory for the <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
</member>
<member name="M:GBase.Factories.GBaseTableFactory.#ctor(GBase.FileHandling.Factories.IFileHandlerFactory,GBase.Factories.IGBaseColumnFactory)">
<summary>
Factory for the <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<param name="fileHandlerFactory">Factory for the <see cref="T:GBase.Interfaces.FileHandling.IFileHandler"/></param>
<param name="gBaseColumnFactory">Factory for the <see cref="T:GBase.Interfaces.IGBaseColumn"/></param>
</member>
<member name="M:GBase.Factories.GBaseTableFactory.Create(System.Type)">
<summary>
Creates an <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<returns>A newly created instance of the implementation for <see cref="T:GBase.Interfaces.IGBaseTable"/></returns>
</member>
<member name="T:GBase.Factories.IGBaseColumnFactory"> <member name="T:GBase.Factories.IGBaseColumnFactory">
<summary> <summary>
Factory for the <see cref="T:GBase.Interfaces.IGBaseColumn"/> Factory for the <see cref="T:GBase.Interfaces.IGBaseColumn"/>
@ -389,7 +433,7 @@
Factory for the <see cref="T:GBase.Interfaces.IGBaseTable"/> Factory for the <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="M:GBase.Factories.IGBaseTableFactory.Create"> <member name="M:GBase.Factories.IGBaseTableFactory.Create(System.Type)">
<summary> <summary>
Creates an <see cref="T:GBase.Interfaces.IGBaseTable"/> Creates an <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
@ -551,37 +595,54 @@
</summary> </summary>
<returns>A <see cref="T:System.Threading.Tasks.ValueTask"/> to await</returns> <returns>A <see cref="T:System.Threading.Tasks.ValueTask"/> to await</returns>
</member> </member>
<member name="T:GBase.GBaseTable"> <member name="T:GBase.GBaseObject`1">
<summary>
GBase object that supplies inheriting classes with methods to get data from a <see cref="T:GBase.Interfaces.IGBase"/>
</summary>
</member>
<member name="M:GBase.GBaseObject`1.#ctor(GBase.Interfaces.IGBase)">
<summary>
GBase object that allows conversion from <see cref="T:System.String"/>
</summary>
<exception cref="T:GBase.Exceptions.MissingTableException">No table for <typeparamref name="T"/> is existing</exception>
</member>
<member name="M:GBase.GBaseObject`1.InitializeFromString(System.String)">
<summary>
Initialize this <see cref="T:GBase.GBaseObject`1"/> from a given <see cref="T:System.String"/>
</summary>
<param name="string">The given <see cref="T:System.String"/></param>
</member>
<member name="T:GBase.GBaseTable`1">
<summary> <summary>
A <see cref="T:GBase.Interfaces.IGBase"/> table A <see cref="T:GBase.Interfaces.IGBase"/> table
</summary> </summary>
</member> </member>
<member name="M:GBase.GBaseTable.#ctor(GBase.FileHandling.Factories.IFileHandlerFactory,GBase.Factories.IGBaseColumnFactory)"> <member name="M:GBase.GBaseTable`1.#ctor(GBase.FileHandling.Factories.IFileHandlerFactory,GBase.Factories.IGBaseColumnFactory)">
<summary> <summary>
A <see cref="T:GBase.Interfaces.IGBase"/> table A <see cref="T:GBase.Interfaces.IGBase"/> table
</summary> </summary>
</member> </member>
<member name="P:GBase.GBaseTable.Type"> <member name="P:GBase.GBaseTable`1.Type">
<summary> <summary>
The <see cref="T:System.Type"/> of the class that this <see cref="T:GBase.Interfaces.IGBaseTable"/> represents The <see cref="T:System.Type"/> of the class that this <see cref="T:GBase.Interfaces.IGBaseTable"/> represents
</summary> </summary>
</member> </member>
<member name="P:GBase.GBaseTable.Name"> <member name="P:GBase.GBaseTable`1.Name">
<summary> <summary>
The name of this <see cref="T:GBase.Interfaces.IGBaseTable"/> The name of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="P:GBase.GBaseTable.Columns"> <member name="P:GBase.GBaseTable`1.Columns">
<summary> <summary>
The <see cref="T:GBase.Interfaces.IGBaseColumn"/>s of this <see cref="T:GBase.Interfaces.IGBaseTable"/> The <see cref="T:GBase.Interfaces.IGBaseColumn"/>s of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="P:GBase.GBaseTable.Entries"> <member name="P:GBase.GBaseTable`1.Entries">
<summary> <summary>
The entries of this <see cref="T:GBase.Interfaces.IGBaseTable"/> The entries of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="M:GBase.GBaseTable.Init(System.Type,System.String,System.String,System.Threading.CancellationToken)"> <member name="M:GBase.GBaseTable`1.Init(System.Type,System.String,System.String,System.Threading.CancellationToken)">
<summary> <summary>
Initialize this <see cref="T:GBase.Interfaces.IGBase"/> Initialize this <see cref="T:GBase.Interfaces.IGBase"/>
</summary> </summary>
@ -591,35 +652,35 @@
<param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken"/> to cancel the asynchronous operation</param> <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken"/> to cancel the asynchronous operation</param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.AddColumn(GBase.Interfaces.IGBaseColumn)"> <member name="M:GBase.GBaseTable`1.AddColumn(GBase.Interfaces.IGBaseColumn)">
<summary> <summary>
Add a given <see cref="T:GBase.Interfaces.IGBaseColumn"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/> Add a given <see cref="T:GBase.Interfaces.IGBaseColumn"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
<param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param> <param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.RemoveColumn(GBase.Interfaces.IGBaseColumn)"> <member name="M:GBase.GBaseTable`1.RemoveColumn(GBase.Interfaces.IGBaseColumn)">
<summary> <summary>
Remove a given <see cref="T:GBase.Interfaces.IGBaseColumn"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/> Remove a given <see cref="T:GBase.Interfaces.IGBaseColumn"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
<param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param> <param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.AddEntry(GBase.Api.INotifyGBaseEntryChanged)"> <member name="M:GBase.GBaseTable`1.AddEntry(`0)">
<summary> <summary>
Add an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/> Add an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param> <param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.RemoveEntry(GBase.Api.INotifyGBaseEntryChanged)"> <member name="M:GBase.GBaseTable`1.RemoveEntry(`0)">
<summary> <summary>
Remove an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/> Remove an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param> <param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.ModifyEntry(System.Object,System.String,System.Object)"> <member name="M:GBase.GBaseTable`1.ModifyEntry(System.Object,System.String,System.Object)">
<summary> <summary>
Modify the property of a given entry with the given value Modify the property of a given entry with the given value
</summary> </summary>
@ -628,14 +689,14 @@
<param name="value">The new value to set</param> <param name="value">The new value to set</param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.GBaseTable.OnGBaseEntryChanged(System.Object,GBase.Api.GBaseEntryChangedEventArgs)"> <member name="M:GBase.GBaseTable`1.OnGBaseEntryChanged(System.Object,GBase.Api.GBaseEntryChangedEventArgs)">
<summary> <summary>
A <see cref="T:GBase.Interfaces.IGBase"/> entry changed A <see cref="T:GBase.Interfaces.IGBase"/> entry changed
</summary> </summary>
<param name="entry">The entry (sender)</param> <param name="entry">The entry (sender)</param>
<param name="args">The <see cref="T:GBase.Api.GBaseEntryChangedEventArgs"/></param> <param name="args">The <see cref="T:GBase.Api.GBaseEntryChangedEventArgs"/></param>
</member> </member>
<member name="M:GBase.GBaseTable.DisposeAsync"> <member name="M:GBase.GBaseTable`1.DisposeAsync">
<summary> <summary>
The <see cref="M:System.IAsyncDisposable.DisposeAsync"/> method The <see cref="M:System.IAsyncDisposable.DisposeAsync"/> method
</summary> </summary>
@ -985,6 +1046,25 @@
A column of a <see cref="T:GBase.Interfaces.IGBaseTable"/> A column of a <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="P:GBase.Interfaces.IGBaseTable`1.Entries">
<summary>
The entries of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
</member>
<member name="M:GBase.Interfaces.IGBaseTable`1.AddEntry(`0)">
<summary>
Add an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns>
</member>
<member name="M:GBase.Interfaces.IGBaseTable`1.RemoveEntry(`0)">
<summary>
Remove an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns>
</member>
<member name="T:GBase.Interfaces.IGBaseTable"> <member name="T:GBase.Interfaces.IGBaseTable">
<summary> <summary>
A <see cref="T:GBase.Interfaces.IGBase"/> table A <see cref="T:GBase.Interfaces.IGBase"/> table
@ -1005,11 +1085,6 @@
The <see cref="T:GBase.Interfaces.IGBaseColumn"/>s of this <see cref="T:GBase.Interfaces.IGBaseTable"/> The <see cref="T:GBase.Interfaces.IGBaseColumn"/>s of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary> </summary>
</member> </member>
<member name="P:GBase.Interfaces.IGBaseTable.Entries">
<summary>
The entries of this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
</member>
<member name="M:GBase.Interfaces.IGBaseTable.Init(System.Type,System.String,System.String,System.Threading.CancellationToken)"> <member name="M:GBase.Interfaces.IGBaseTable.Init(System.Type,System.String,System.String,System.Threading.CancellationToken)">
<summary> <summary>
Initialize this <see cref="T:GBase.Interfaces.IGBase"/> Initialize this <see cref="T:GBase.Interfaces.IGBase"/>
@ -1034,20 +1109,6 @@
<param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param> <param name="column">The given <see cref="T:GBase.Interfaces.IGBaseColumn"/></param>
<returns>True if successful, false if not</returns> <returns>True if successful, false if not</returns>
</member> </member>
<member name="M:GBase.Interfaces.IGBaseTable.AddEntry(GBase.Api.INotifyGBaseEntryChanged)">
<summary>
Add an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> to this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns>
</member>
<member name="M:GBase.Interfaces.IGBaseTable.RemoveEntry(GBase.Api.INotifyGBaseEntryChanged)">
<summary>
Remove an entry that implements <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/> from this <see cref="T:GBase.Interfaces.IGBaseTable"/>
</summary>
<param name="entry">The entry implementing <see cref="T:GBase.Api.INotifyGBaseEntryChanged"/></param>
<returns>True if successful, false if not</returns>
</member>
<member name="T:GBase.Interfaces.Settings.IGBaseSettings"> <member name="T:GBase.Interfaces.Settings.IGBaseSettings">
<summary> <summary>
Settings of a <see cref="T:GBase.Interfaces.IGBase"/> instance Settings of a <see cref="T:GBase.Interfaces.IGBase"/> instance

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
@ -47,7 +46,7 @@ namespace GBase
/// <summary> /// <summary>
/// The name of this <see cref="IGBaseTable"/> /// The name of this <see cref="IGBaseTable"/>
/// </summary> /// </summary>
public string Name { get; private set; } public string FolderName { get; private set; }
/// <summary> /// <summary>
/// The <see cref="IGBaseColumn"/>s of this <see cref="IGBaseTable"/> /// The <see cref="IGBaseColumn"/>s of this <see cref="IGBaseTable"/>
@ -64,18 +63,15 @@ namespace GBase
/// Initialize this <see cref="IGBase"/> /// Initialize this <see cref="IGBase"/>
/// </summary> /// </summary>
/// <param name="type">The <see cref="System.Type"/> of the class that this <see cref="IGBaseTable"/> represents</param> /// <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="databasePath">The path to the database files</param>
/// <param name="folderName"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the asynchronous operation</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the asynchronous operation</param>
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
public async Task<bool> Init(Type type, string name, string databasePath, CancellationToken cancellationToken) public async Task<bool> Init(Type type, string databasePath, string folderName, CancellationToken cancellationToken)
{ {
Type = type; Type = type;
Name = name; FolderName = folderName;
await _fileHandler.Init(databasePath, cancellationToken);
string fileName = $"{name}.{GBase.GBASE_TABLE_FILE_EXTENSION}";
string path = Path.Combine(databasePath, fileName);
await _fileHandler.Init(path, cancellationToken);
//TODO: Init columns list depending on GBaseColumnAttributes set for this GBaseTable //TODO: Init columns list depending on GBaseColumnAttributes set for this GBaseTable
foreach (var property in type.GetProperties()) foreach (var property in type.GetProperties())
@ -123,12 +119,12 @@ namespace GBase
/// </summary> /// </summary>
/// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param> /// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param>
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
public async Task<bool> AddEntry(T entry) //TODO: Write to file public async Task<bool> AddEntry(T entry)
{ {
Entries.Add(entry); Entries.Add(entry);
entry.GBaseEntryChanged += OnGBaseEntryChanged; entry.GBaseEntryChanged += OnGBaseEntryChanged;
await _fileHandler.AddEntry(entry, this); await _fileHandler.AddEntry(entry, this, TODO);
return true; return true;
} }
@ -138,7 +134,7 @@ namespace GBase
/// </summary> /// </summary>
/// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param> /// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param>
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
public async Task<bool> RemoveEntry(T entry) //TODO: remove from file public async Task<bool> RemoveEntry(T entry)
{ {
if (!Entries.Contains(entry)) if (!Entries.Contains(entry))
return false; return false;

@ -22,7 +22,7 @@ namespace GBase.Interfaces.FileHandling
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
Task<bool> Init(string path, CancellationToken cancellationToken); Task<bool> Init(string path, CancellationToken cancellationToken);
Task AddEntry<T>(T entry, IGBaseTable table); Task AddEntry<T>(T entry, IGBaseTable table, CancellationToken cancellationToken);
Task<bool> RemoveEntry<T>(T entry); Task<bool> RemoveEntry<T>(T entry);

@ -48,7 +48,7 @@ namespace GBase.Interfaces
/// <summary> /// <summary>
/// The name of this <see cref="IGBaseTable"/> /// The name of this <see cref="IGBaseTable"/>
/// </summary> /// </summary>
string Name { get; } string FolderName { get; }
/// <summary> /// <summary>
/// The <see cref="IGBaseColumn"/>s of this <see cref="IGBaseTable"/> /// The <see cref="IGBaseColumn"/>s of this <see cref="IGBaseTable"/>
@ -59,11 +59,12 @@ namespace GBase.Interfaces
/// Initialize this <see cref="IGBase"/> /// Initialize this <see cref="IGBase"/>
/// </summary> /// </summary>
/// <param name="type">The <see cref="System.Type"/> of the class that this <see cref="IGBaseTable"/> represents</param> /// <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="databasePath">The path to the database files</param> /// <param name="folderName"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the asynchronous operation</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the asynchronous operation</param>
/// ///
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
Task<bool> Init(Type type, string name, string databasePath, CancellationToken cancellationToken); Task<bool> Init(Type type, string databasePath, string folderName, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Add a given <see cref="IGBaseColumn"/> to this <see cref="IGBaseTable"/> /// Add a given <see cref="IGBaseColumn"/> to this <see cref="IGBaseTable"/>

@ -27,7 +27,7 @@ namespace Test.GBase
gBaseColumnFactoryMock.Setup(c => c.Create()).Returns(new GBaseColumn()); gBaseColumnFactoryMock.Setup(c => c.Create()).Returns(new GBaseColumn());
IGBaseTable<Foo> table = new GBaseTable<Foo>(fileHandlerFactoryMock.Object, gBaseColumnFactoryMock.Object); IGBaseTable<Foo> table = new GBaseTable<Foo>(fileHandlerFactoryMock.Object, gBaseColumnFactoryMock.Object);
table.Init(typeof(Foo), nameof(Foo), "", CancellationToken.None); table.Init(typeof(Foo), "", TODO, CancellationToken.None);
Foo foo = new Foo("Test"); Foo foo = new Foo("Test");
table.AddEntry(foo); table.AddEntry(foo);

Loading…
Cancel
Save